Adding Metrics Using the Metrics Expression Builder

The Metrics Expression Builder feature allows you to build metrics expressions in Observe. For instance, you might want to visualize CPU usage for an application. You can add metrics to a new worksheet or dashboard or an existing worksheet or dashboard.

Accessing the Expression Builder

You can access the Expression Builder using one of three methods:

From a Metrics dataset

  1. In Observe, under Investigate, click Metrics, and then select a metric from the list of Metrics, such as cpu_utilization(Server/Telegraf CPU Metrics).

Select Metrics.

Figure 1 - The Metrics landing page

2. Click +Add Expression.

3. To add Expression A, select a filter in the Where field to narrow it down to a specific parameter.

4. Repeat for Expression B.

For both Expression A and Expression B, you can select from the following options:

  • Raw - display raw data.

  • Table - display the data in a table format.

  • Visualize - display the data in a visualization of the data.

When you select Visualize, choose one of the available types of visualization:

  • Line Chart - then select the type of plot and by a specific parameter.

  • Bar Chart - then select the type of plot and by a specific parameter.

  • Stacked Area - then select the type of plot and by a specific parameter.

  • Single Stat - then select the type of plot and by a specific parameter.

  • Pie Chart - then select the type of plot and by a specific parameter.

  • List - then select the type of plot and by a specific parameter.

  • Value Over Time - then select the type of plot and by a specific parameter.

Select Metrics.

Figure 1 - The Metrics landing page

Add a metric to a Worksheet

To add a metric to a worksheet, use the following steps:

  1. Open an existing worksheet or create a new one from an event dataset.

  2. Click Add Content and select Metrics.

  3. Select a metric from the list of related metrics.

Select Metrics.

Figure 3 - Adding Metrics to a Worksheet

Access from Dashboard

Access the Expression Builder from a Dashboard card:

  1. In Observe, click Explore: Dashboards.

  2. Select a Dashboard from the list.

  3. On a card with metrics, click the More icon, and select Open in Worksheet.

  4. Click Add Content and select Metrics.

  5. Select a metric, such as cpu_utilization, and click Select.

  6. Locate the Expression Builder tab underneath the displayed data.

Overview of Expression Builder

Section One - Expression Builder

  • Metric - When you click Metric under Add Content, Observe displays a list of available metrics that you can select to add.

Metrics list

Figure 4 - Select from a list of available metrics.

  • where - select from a list of available filters for the metric. This is an optional parameter.

  • Sum by - the default value for the OPAL function is Sum by. You can select from the following list of available OPAL functions:

    • Any - Return any value of one column across a group.

    • Any not null - Return any non-null value of one column across a group. Can still return null if all values in the group are null

    • Average - Calculate the arithmetic average of the input expression across the group.

    • Count Values - Count the number of non-null items in the group.

    • Count Distinct Fast - Estimate the approximate number of distinct values in the input using hyper-log-log.

    • Count Distinct Exact - Count the exact number of distinct values in the input using complete enumeration.

    • Maximum - Compute the maximum of one column across a group (with one argument) or the scalar greatest value of its arguments (with more than one argument).

    • Median* - Return the fast approximate median value of one column.

    • Median Exact - Return the exact median value of one column.

    • Minimum - Compute the minimum of one column across a group with one argument or the scalar least value of its arguments with more than one argument.

    • Percentile(99) - Returns an approximated value for the specified percentile of the input expression across the group. percentile(@."*metric*", .99

    • Percentile(95) - Returns an approximated value for the specified percentile of the input expression across the group. percentile(@."*metric*", .95

    • Percentile(90) - Returns an approximated value for the specified percentile of the input expression across the group. percentile(@.”metric”, .90`

    • Percentile(75) - Returns an approximated value for the specified percentile of the input expression across the group. percentile(@.”metric”, .75`

    • Percentile(50) - Returns an approximated value for the specified percentile of the input expression across the group. percentile(@.”metric”, .50`

    • Prometheus Quantile(99) - Returns a value for 99th percentile distribution.

    • Prometheus Quantile(95) - Returns a value for 95th percentile distribution.

    • Prometheus Quantile(90) - Returns a value for 90th percentile distribution.

    • Prometheus Quantile(75) - Returns a value for 75th percentile distribution.

    • Prometheus Quantile(50) - Returns a value for 50th percentile distribution.

    • Standard Deviation - Calculate the standard deviation across the group.

    • Sum - Calculate the sum of the argument across the group or the scalar arguments if more than one.

    • Don’t Aggregate - Do not aggregate metrics.

Note

You can only use Prometheus Quantile parameters with Prometheus metrics ending in _bucket.

For more information about OPAL functions, see All OPAL functions.

  • by - Select a field from the list of available fields to filter the metric.

  • Add metric - Add additional metrics to monitor.

  • Add formula - Add a formula to further refine your data. For instance, you can add A*100 to multiply your results by 100.

  • Multiple Alerts - you can select if you want to receive multiple alerts or a single alert for alert conditions.

If you click the More icon next to Field, you can see the following options:

Other Options

Figure 5 - More options for metric expressions

  • Add function>TopK - Selects all data for each of top k ranked groups.

  • Adjust alignment - Aggregates the metric to an average of the data over a minute. Automatically enabled by default.

Note

If your metric is continually increasing, and never decreases, it is likely a counter metric.

In order to convert it to a gauge metric, which can increase and decrease, set the aggregation function within Alignment to rate. This will calculate the rate of change over time.

  • Adjust resolution - Set the length of time to collect data. Automatically enabled by default.

  • Delete - Removes the metric expression from the monitor.

Adding CPU Utilization Metrics to a Worksheet

  1. In Observe, click Explore: Datasets.

  2. From the list of datasets, select CPU Metrics.

  3. Click the Worksheet icon to create a worksheet from the metrics.

  4. Click Add Content and then select Metric.

  5. In the Search field of the metrics, enter cpu_utilization, and select it from the list.

  6. A new stage, Stage 2, displays on the worksheet.

  7. The Expression Builder displays the data using Sum, however, selecting Average shows the average CPU usage. Select the type of average from the by list.

  8. The metrics average by Host by default, but you can select from the following parameters:

    • cpu

    • host

    • datacenter

    • field

    • value

CPU Utilization metrics

Figure 6 - Adding CPU utilization to the CPU Metrics worksheet.

Usage per User Sum by Host

Figure 7 - Usage per User with Sum by Host

You can also filter the metric using JSON and parameters contained in columns.

Filter metric using JSON

Figure 8 - Filtering the CPU Utilization metric using JSON in the field column.