Use Calculated Fields

Calculated fields, otherwise known as Derived Columns, allow you to compute properties in a Dataset or an Environment. The field’s value is based on the result of an expression that performs functions, mathematical, and/or logical operations on other fields’ values; similar to expressions defined in a spreadsheet.

These calculated fields are equivalent to other fields in your data. Use in query builder, boards, triggers, and Service Level Objectives (SLOs).

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 (example scenario)

Access a Calculated Field 

Calculated fields exist in the schema of a Dataset or an Environment.

  1. In Datasets, select a Dataset.

    The Dataset Settings page displays several tabs.

  2. Select the Schema tab.

  3. Select Calculated Fields to expand.

    The schema displays a button to create a new calculated field, a search box, and a list of any existing calculated fields.

    Navigating through the UI to the schema of a Dataset
  1. In the left navigation bar under the Honeycomb logo, select the Environments banner. A menu appears with Manage Environments and a list of existing Environments.

  2. Select Manage Environments. The next screen displays a list of Environments and details about each Environment.

  3. In the row of the target Environment, select the target Environment’s name. The next screen displays the Environment Settings page with several tabs.

  4. Select the Schema tab.

    The schema displays a button to create a new calculated field, a search box, and a list of any existing calculated fields.

    Navigating through the UI to the schema of an Environment

Create a Calculated Field 

Any team owner or member can create a calculated field in the Honeycomb UI.

Create calculated fields by accessing the Dataset’s schema, the Environment’s schema, or through query builder.

  1. In Query Builder, select the GROUP BY clause.

    A list of suggested fields appears automatically when selected with a mouse/trackpad or by pressing the down arrow on the keyboard.

  2. Select Create Calculated Field.

    The “Create a Calculated Field” editor appears.

    Calculated field selector

Edit a Calculated Field 

Any team owner or member can edit a calculated field in the Honeycomb UI.

Edit calculated fields by accessing the Dataset’s schema or the Environment’s schema.

  1. Select Edit for the calculated field.

    Edit calculated field

    Changes to a calculated field may effect boards, triggers, or SLOs.

    If a dependency exists, an “Edit Calculated Field” modal appears first and presents the choice to clone or continue with editing the calculated field. If you are unsure whether to clone or edit the column, reach out to the most recent editor of the calculated field.

    Edit a calculated field modal with a dependency
  2. Select Clone or Continue.

    Clone creates an unsaved copy of the calculated field with a new name in the editor. Continue opens the existing calculated field in the editor.

Clone a Calculated Field 

Any team owner or member can clone a calculated field in the Honeycomb UI.

Clone calculated fields by accessing the Dataset’s schema or the Environment’s schema.

Clone a calculated field from the table
  1. Select Clone next to the target calculated field. The calculated field editor appears.

  2. An unsaved copy of the target calculated field populates in the editor.

  3. Modify the calculated field name and formula as needed.

  4. Select Continue to save.

Calculated Field Editor 

Note
If creating or editing a calculated field for an Environment, a banner at the top of the editor informs that this calculated field will be shared across all datasets in your Environment.

The editor displays the following elements:

Display Name
The display name defines an alias that the query builder treats as a field. This alias is unique to its dataset and the environment that this dataset exists.
Tip
Calculated field names must be unique. Honeycomb tries to prevent situations where a calculated field and a regular field share the same name, but name collisions can still occur. See our Troubleshooting Calculated Fields section for more information.
Description
This provides additional information to help provide context or purpose for the calculated field.
Function
Define your calculated field expression here. Refer to the Calculated Field Reference for syntax and a list of available functions. If syntax errors exist, errors in the expression appear underlined in red or with a red triangle. Hover over each error marker to display details about the error or refer to the error message displayed by the editor. Calculated field syntax error for a function
Preview Data
Preview the results of the function below the expression editor. Sample data selected used here helps verify the expression before it is saved. Calculated field preview data for a function
Save
After selection, the saved calculated field appears in the schema.

Delete a Calculated Field 

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

Delete calculated fields by accessing the Dataset’s schema or the Environment’s schema.

  1. Select Delete for the calculated field.

    Delete calculated field

    Queries that use a calculated field continue to work, but the alias no longer appears in the query builder. Changes to a calculated field may effect boards, triggers, or SLOs. If any dependency exists, a “Delete Calculated Field” modal presents a list of its dependencies.

    Delete a calculated field modal with dependent objects shown
  2. To continue deletion, remove any objects dependent on the calculated field.

    Each object links directly to their respective editor. If you are unsure whether to remove the dependencies, reach out to the most recent editor of the dependent object.

  3. Select Refresh Dependencies to reload the list after removing all dependencies.

    A modal appears to confirm deletion of the calculated field.

  4. Select Delete to confirm deletion of the calculated field.

    Delete a calculated field confirmation modal

Calculated Field Example - Query 

A web server handles requests with varying sizes of content.

A query with GROUP BY content_length returns a time series graph that displays the count for each value of content_length.

The operations team wants to compare small requests to all other requests. The team internally categorizes a small request as having a content_length of less than or equal to 1000.

The team creates a calculated field named smallRequest with the function LTE($content_length, 1000).

A query with GROUP BY smallRequest returns a time series graph that displays the small requests alongside the other requests.

Calculated Field Example Scenario Query

Calculated Field Example - Multiple Datasets 

An Environment named Production contains three Datasets named PaymentService, CheckoutService, and SupportService. The datasets all define a calculated field with the same alias.

Dataset Calculated Field Alias Expression
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)

A query across the Production Environment returns data for the:

  • PaymentService with the total_amount_in_usd values calculated with its expression.
  • CheckoutService with the total_amount_in_usd values calculated with its expression.
  • SupportService with the total_amount_in_usd values calculated with its expression.

The Production Environment cannot define a calculated field with the alias total_amount_in_usd because the alias is already used by a calculated field in one or more datasets.