# Adding Metrics Using the Expression Builder¶

The 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, click Explore , and then click Metrics.

Figure 1 - The Metrics landing page

2. Select a metric from the list of available metrics.

3. On the Metric Selected card, click Open In Worksheet.

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

Figure 2 - Metrics Worksheet with Expression Builder

### 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.

Figure 3 - Adding Metrics to a Worksheet

### Access from Dashboard¶

Access the Expression Builder from a Dashboard card:

1. In Observe, click Explore, and then 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.

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.

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

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

If you click the More icon next to Field, you can see the following 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.

• 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 , and then click 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

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

Figure 7 - Usage per User with Sum by Host

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

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