Skip to main content

prometheus (Sink)

This sink publishes events processed by Stream App into Prometheus metrics and exposes them to the Prometheus server at the specified URL. The created metrics can be published to Prometheus via server or pushGateway, depending on your preference. The metric types that are supported by the Prometheus sink are counter, gauge, histogram, and summary. The values and labels of the Prometheus metrics can be updated through the events.

Syntax

CREATE SINK <NAME> WITH (type="prometheus", map.type="<STRING>", job="<STRING>", publish.mode="<STRING>", push.url="<STRING>", server.url="<STRING>", metric.type="<STRING>", metric.help="<STRING>", metric.name="<STRING>", buckets="<STRING>", quantiles="<STRING>", quantile.error="<DOUBLE>", value.attribute="<STRING>", push.operation="<STRING>", grouping.key="<STRING>")

Query Parameters

NameDescriptionDefault ValuePossible Data TypesOptionalDynamic
jobThis parameter specifies the job name of the metric. This must be the same job name that is defined in the Prometheus configuration file.stream processor JobSTRINGYesNo
publish.modeThe mode in which the metrics need to be exposed to the Prometheus server.The possible publishing modes are server and pushgateway.The server mode exposes the metrics through an HTTP server at the specified URL, and the pushGateway mode pushes the metrics to the pushGateway that needs to be running at the specified URL.serverSTRINGYesNo
push.urlThis parameter specifies the target URL of the Prometheus pushGateway. This is the URL at which the pushGateway must be listening. This URL needs to be defined in the Prometheus configuration file as a target before it can be used here.http://localhost:9091STRINGYesNo
server.urlThis parameter specifies the URL where the HTTP server is initiated to expose metrics in the server publish mode. This URL needs to be defined in the Prometheus configuration file as a target before it can be used here.http://localhost:9080STRINGYesNo
metric.typeThe type of Prometheus metric that needs to be created at the sink. The supported metric types are counter, gauge, histogram and summary.STRINGNoNo
metric.helpA brief description of the metric and its purpose.STRINGYesNo
metric.nameThis parameter allows you to assign a preferred name for the metric. The metric name must match the regex format, i.e., [a-zA-Z:][a-zA-Z0-9:]*.STRINGYesNo
bucketsThe bucket values preferred by the user for histogram metrics. The bucket values must be in the string format with each bucket value separated by a comma as shown in the example below. "2,4,6,8"nullSTRINGYesNo
quantilesThis parameter allows you to specify quantile values for summary metrics as preferred. The quantile values must be in the string format with each quantile value separated by a comma as shown in the example below. "0.5,0.75,0.95"nullSTRINGYesNo
quantile.errorThe error tolerance value for calculating quantiles in summary metrics. This must be a positive value, but less than 1.0.001DOUBLEYesNo
value.attributeThe name of the attribute in the stream definition that specifies the metric value. The defined value attribute must be included in the stream definition. The system increases the metric value for the counter and gauge metric types by the value of the value attribute. The system observes the value of the value attribute for the calculations of summary and histogram metric types.valueSTRINGYesNo
push.operationThis parameter defines the mode for pushing metrics to the pushGateway. The available push operations are push and pushadd. The operations differ according to the existing metrics in pushGateway where push operation replaces the existing metrics, and pushadd operation only updates the newly created metrics.pushaddSTRINGYesNo
grouping.keyThis parameter specifies the grouping key of created metrics in key-value pairs. The grouping key is used only in pushGateway mode in order to distinguish the metrics from already existing metrics. The expected format of the grouping key is as follows: "key1:value1,key2:value2"STRINGYesNo

System Parameters

NameDescriptionDefault ValuePossible Parameters
jobNameThis property specifies the default job name for the metric. This job name must be the same as the job name defined in the Prometheus configuration file.stream processor JobAny string
publishModeThe default publish mode for the Prometheus sink for exposing metrics to the Prometheus server. The mode can be either server or pushgateway.serverserver or pushgateway
serverURLThis property configures the URL where the HTTP server is initiated to expose metrics. This URL needs to be defined in the Prometheus configuration file as a target to be identified by Prometheus before it can be used here. By default, the HTTP server is initiated at http://localhost:9080.http://localhost:9080Any valid URL
pushURLThis property configures the target URL of the Prometheus pushGateway (where the pushGateway needs to listen). This URL needs to be defined in the Prometheus configuration file as a target to be identified by Prometheus before it can be used here.http://localhost:9091Any valid URL
groupingKeyThis property configures the grouping key of created metrics in key-value pairs. Grouping key is used only in pushGateway mode in order to distinguish these metrics from already existing metrics under the same job. The expected format of the grouping key is as follows: "key1:value1,key2:value2" .nullAny key value pairs in the supported format

Example 1

CREATE SINK FooCountStream WITH (type='prometheus',job='fooOrderCount', server.url ='http://localhost:9080', publish.mode='server', metric.type='counter', metric.help= 'Number of foo orders', map.type='keyvalue') (Name String, quantity int, value int);

In the above example, the Prometheus-sink creates a counter metric with the stream name and defined attributes as labels. The metric is exposed through an HTTP server at the target URL.

Example 2

CREATE SINK InventoryLevelStream WITH (type='prometheus',job='inventoryLevel', push.url='http://localhost:9080', publish.mode='pushGateway', metric.type='gauge', metric.help= 'Current level of inventory', map.type='keyvalue') (Name String, value int);

In the above example, the Prometheus-sink creates a gauge metric with the stream name and defined attributes as labels.The metric is pushed to the Prometheus pushGateway at the target URL.