Define Dataset Schema

Define Schema 

The Schema tab allows you to select whether nested JSON automatically unpacks, and lists the Dataset’s Unique Fields and Calculated Fields.

Unique Fields lists all the unique fields seen in events from this dataset. You can modify a field’s data type here if needed.

Tip
If you change the type of a field in the Schema page and then later send an event where the data type does not match, then Honeycomb will try to coerce the value. If Honeycomb cannot coerce the value, it will get set to zero (0) rather than dropping the value.

Calculated Fields 

Each Dataset allows you to define unique calculated fields for use within it.

What are Calculated Fields? 

Otherwise known as Derived Columns, calculated fields are computed properties that are calculated by a formula.

The field’s value is based on the result of a formula, which can contain functions, mathematical and/or logical operations on other field values, and constants and literals, similar to expressions defined in a spreadsheet. To learn more about syntax and available functions, visit Calculated Field Formula Reference.

Uses 

Though functionally different, you can use calculated fields in Honeycomb just as you would use other fields in your data (building queries; defining Triggers and Service Level Objectives (SLOs)). For example, you can use calculated fields to express:

  • an event detail in a more human-readable way
  • business measures that may change over time
  • common field across services with different implementations

Some examples include:

Use a Calculated Field in a Query to Compare Values

Example scenario: Your team manages a web server that handles requests with varying sizes of content. Querying with GROUP BY content_length returns a time series graph that displays the count for each value of content_length. You want to compare small requests to all other requests. Your team internally categorizes a small request as having a content_length of less than or equal to 1000.

Solution: Create a Calculated Field named smallRequest with the function LTE($content_length, 1000).

When you query in Honeycomb with a GROUP BY clause of smallRequest, you receive a time series graph that displays the small requests alongside the other requests.

Use a Calculated Field across Multiple Datasets

Example scenario: Your team has an Environment named “Production”, which contains Datasets named “PaymentService”, “CheckoutService”, and “SupportService”. You have defined a calculated field with the same name in each Dataset:

Dataset Calculated Field Name Formula
PaymentService total_amount_in_usd COALESCE($usd_total, ADD(MUL($tax_rate, $item_total), $fees))
CheckoutService total_amount_in_usd MUL($cart_total, $tax_rate)
SupportService total_amount_in_usd SUM(0)

When you query across the Production Environment in Honeycomb, you receive:

  • data for the PaymentService with the total_amount_in_usd values calculated with its expression
  • data for the CheckoutService with the total_amount_in_usd values calculated with its expression
  • data for the SupportService with the total_amount_in_usd values calculated with its expression

You cannot define an Environment-level Calculated Field for “Production” with the name total_amount_in_usd because the name is already used by a Dataset-level Calculated Field in one or more datasets.

Solution: Name the Environment-level Calculated Field something unique to your Environment or change your instrumentation to rename the Calculated Fields in the Datasets.

Create Calculated Field 

To create a Calculated Field:

  1. Log in to the Honeycomb UI.

  2. Select the Environments label on the top-left, then select the Environment that contains the Dataset to which you would like to add a Calculated Field.

  3. In the left navigation menu, select Manage Data.

  4. In the list, locate and select Datasets.

  5. In the list, locate the Dataset to which you would like to add a Calculated Field, and select its name to view the available settings.

  6. Navigate to the Schema view.

  7. Select Add new Calculated Field.

  8. In the modal, enter a Display Name, which will show as the field name in the Query Builder.

    Tip

    Enter a display name that is unique across the Dataset and its containing Environment. Your Calculated Field name should not match the name of any other Calculated Field or any other field in any Dataset contained within the Environment.

    Although Honeycomb tries to prevent duplicate field names, they can still occur. To learn more about behaviors related to name collision and solutions, visit Common Issues with Queries: Calculated Fields.

  9. In the editor, define the formula for your Calculated Field. To learn more about syntax and available functions, and to explore some example formulas, visit Calculated Field Formula Reference.

    Hover over any syntax errors (red underlines or red triangles) for assistance with correcting them.

  10. Select Save.

Change Calculated Field 

Warning
Changes to a Calculated Field may affect Boards, Triggers, or SLOs.

To change a Calculated Field:

  1. Log in to the Honeycomb UI.

  2. Select the Environments label on the top-left, then select the Environment that contains the Dataset for which you would like to change a Calculated Field.

  3. In the left navigation menu, select Manage Data.

  4. In the list, locate and select Datasets.

  5. In the list, locate the Dataset for which you would like to change a Derived Colum, and select its name to view the available settings.

  6. Navigate to the Define Schema view.

  7. In the list, locate the Calculated Field that you want to edit, and select Edit.

    If any dependencies exist, Honeycomb will prompt you to choose whether to clone or continue editing the Calculated Field. If you are unsure about whether to clone or edit, reach out to the Calculated Field’s most recent editor.

  8. In the modal, modify the pre-populated name and formula as needed. To learn more about syntax and available functions, and to explore some example formulas, visit Calculated Field Formula Reference.

  9. Select Save.

Clone Calculated Field 

If you have a Calculated Field that is similar to one you want to create, you can clone it and use it as the base for a new Calculated Field. To clone a Calculated Field:

  1. Log in to the Honeycomb UI.

  2. Select the Environments label on the top-left, then select the Environment that contains the Dataset for which you would like to clone a Calculated Field.

  3. In the left navigation menu, select Manage Data.

  4. In the list, locate and select Datasets.

  5. In the list, locate the Dataset that contains the Calculated Field you want to clone, and select its name to view the available settings.

  6. Navigate to the Define Schema view.

  7. In the list, locate the Calculated Field that you want to clone, and select Clone.

  8. In the modal, modify the pre-populated name and formula as needed. To learn more about syntax and available functions, and to explore some example formulas, visit Calculated Field Formula Reference.

  9. Select Save.

Delete Calculated Field 

Warning

Deleting a Calculated Field may affect Boards, Triggers, or SLOs.

Only the calculated field’s creator or a Team Owner can delete a calculated field in the Honeycomb UI.

  1. Log in to the Honeycomb UI.

  2. Select the Environments label on the top-left, then select the Environment that contains the Dataset for which you want to delete a Calculated Field.

  3. In the left navigation menu, select Manage Data.

  4. In the list, locate and select Datasets.

  5. In the list, locate the Dataset that contains the Calculated Field you want to delete, and select its name to view the available settings.

  6. Navigate to the Define Schema view.

  7. In the list, locate the Calculated Field that you want to delete, and select Delete.

    If any dependencies exist, you will see a list of dependencies that you must remove to continue. If you are unsure about whether to remove the dependencies, reach out to each dependency’s most recent editor. After removing all dependencies, select Refresh Dependencies.

  8. From the modal, select Delete.

    Delete a calculated field confirmation modal

    Queries that use your Calculated Field will continue to work, but the alias will no longer appear in the Query Builder.