Skip to main content

Publish Metrics

So far, we've created two aggregations: a count Function, and a sum Function. Now, we need to transform the data into a metrics payload that can be delivered to our target system.

We will use the Publish Metrics function to define the metrics that will be published. This function allows us to rename the metrics and define their type for the downstream system.

We will rename the count field as request.count, and the bytes_sum field as request.bytes. We'll also specify our three dimensions (request_method, status, referer).

important
  1. In the access_combined_metrics Pipeline, click Add Function, and select Publish Metrics from the Advanced menu (or type in Publish Metrics in the search field).
  2. Click Add to List.
  3. Under Event Field Name, enter count, and under Metric Name Expression, enter 'request.count', and make sure that the Metric Type is set to Gauge.
  4. Click Add to List to create another metric line.
  5. In the Event Field Name, enter bytes_sum, and in the second column, enter 'request.bytes', and column three needs to be Gauge.
  6. In the Add Dimensions field, delete the default values (by clicking on the X next to the value) and enter the fields request_method, status, and referer. In this field, type in each one individually, separated by carriage returns.
  7. Click Save.

Your function configuration should look something like this: Publish Metrics Function Config

note

While we're only entering a fixed string (that's why we need the single quotes around 'request.count' and 'request.bytes') in the Metric Name Expression field, this field is a JavaScript expression, so it can be used to programatically generate the metric field name. If you haven't yet, we recommend you also take the JavaScript Expressions tutorial.

In the Sample Data pane, click on the Simple Preview to see that all of the original events are stricken out. If you scroll down in the right pane to the bottom, your sample data should now look something like this:

Publish Metrics

Metrics are highlighted in the aqua/teal color, and the dimensions are highlighted in lavender.

Now that we have metrics coming out of this Pipeline, we need to change the Route to point to the the InfluxDB Destination (named as influxdb:influxdb2 in our config).

important
  1. Select the Routing submenu, then click Data Routes.
  2. Click on the access-combined-metrics route.
  3. Change the Output to influxdb:influxdb2.
  4. Click Save.

Your Route configuration should now look something like this:

Route Configuration

On the top menu, click the InfluxDB tab and log in to the InfluxDB interface:

UsernamePassword
admincribldemo

Once logged in, click Dashboards in the InfluxDB left nav, and then on Access Combined Dashboard - you should now see data start to flow to the dashboard.

note

We recommend that you change the time window in the InfluxDB UI for the dashboard from past 1h to past 5m - it makes seeing changes as they occur a little easier.