Splunk Developer Day: Watch all Sessions!Access the Playlist here

histogram()

Creates a histogram stream object based on the input parameters.

Syntax

histogram(metric=<metric_name> [,filter=<filter_dict>][,resolution=<resolution>])

Parameter definitions

Parameter
Type
Description
metric
string
Name of a metric, or * wildcard that matches one or more metrics.
filter
dict
Dictionary containing dimension key-value pairs, using Python syntax. The conditions on the different keys are combined via AND.
The values in the dictionary can be lists, which are then combined with an OR.
Only data that has the specified dimensions appears in the output stream.
The default value is None, which means no filter is applied.
You can also specify this parameter using a call to the filter() function.
resolution
number, string, or duration
Data resolution for the data block. The maximum resolution supported is 1d. Use one of the following formats:
- Number: a number in multiples of 1000 milliseconds (1 second).
- String: a number followed by a single character that specifies the time unit. For example, 1s. The unit character is one of the following: s (seconds), m (minutes), h (hours), d (days).
- Duration: a duration object created by the duration() function.
For more information, see the Using the resolution parameter section.

Return value

Returns a histogram stream object.

Note: You can't publish a histogram stream. If you want to publish the result of your histogram() function, you must use one of the supported methods to create a scalar value, which can then be published. To learn more, see the Examples with supported methods section.

Use the resolution parameter

Use the resolution parameter to request a data resolution for the histogram block.

Because a SignalFlow job has only one resolution, other histogram blocks such as transformations might change the overall resolution for the job. In this case, the resolution parameter has no visible effect.

Histogram block resolution and job resolution

The resolution parameter lets you set the resolution of the histogram block. In addition to the resolution of the histogram block, SignalFlow uses analytic transformations, lasting() clauses, and the resolution of other histogram blocks to compute the resolution of the entire SignalFlow job.

SignalFlow usually determines the single resolution for a job by following these steps:

  1. Analysis of the resolution of incoming metric time series.
  2. Determining the resolution for long transformation windows or time shifts that retrieve data, for which only a coarser resolution is available.

Using the resolution parameter lets you statically set the histogram block resolution for the first step, but the second step can cause the SignalFlow job to run at a more coarse resolution. You can set the minimum resolution of an entire SignalFlow job using the API, by calling the SignalFlow POST /v2/execute(Opens new window) endpoint and providing the resolution field in the request body. You can also set the minimum resolution using language-specific SDKs such as the SignalFx client library for Python(Opens new window), which provide a flow object with an execute() method. This method has a resolution parameter you can use to set the minimum job resolution.

Examples

Basic examples

These examples show how to call the histogram() function.

# Fetch all histogram time series with a metric named service_latency
histogram('service_latency')
 
 
# Fetch all histogram time series with a metric that begin with "service."
histogram('service.*')
 

Examples with supported methods

The histogram() function supports the following methods.

When used with the histogram() function, all these methods return scalar values. For all supported methods, you can perform aggregation and transformation in a single function or call.

These examples show how to call the histogram() function using supported methods.

# Use the percentile() method to find the 90th percentile value from the distribution of the histogram stream, grouped by sf_service over a period of 5 minutes
histogram('service_latency').percentile(90, by='sf_service', over='5m')
 
# Use the cdf() method to compute the CDF of the stream by env
histogram('service_latency').cdf(50, by='env')
 
# Use the min() method to find the min value of the stream
histogram('service_latency').min()

This example demonstrates how to create a chart from the histogram() stream object.

# Publish a chart for the service_latency metric
histogram('service_latency')
.percentile(90, by='sf_service', over='5m')
.publish(label='5-min p90 latency by service')
 

Examples with the filter() function

Use the filter() function(Opens new window) to simplify your queries. For example, the query

histogram('service_latency', filter={'host': ['hostA', 'hostB'], 'AWSUniqueId': 'i-0403'})

is equivalent to

histogram('service_latency', filter=filter('host', 'hostA', 'hostB') and filter('AWSUniqueId', 'i-0403'))