Count Telemetry
This feature is only available in BindPlane OP Enterprise. Learn more here.
Count Telemetry Processor
The Count Telemetry Processor can count the number of logs, metric datapoints, or trace spans matching some filter, and create a metric with that value.
Both the name and units of the created metric can be configured. Additionally, fields from matching logs can be preserved as metric attributes.
Supported Types
Metrics | Logs | Traces |
---|---|---|
✓ | ✓ | ✓ |
Supported Agent Versions
v1.22.0
+
Configuration
Field | Type | Default | Description |
---|---|---|---|
enable_logs | bool | false | Enables or disables counting of logs. |
log_match | string | true | A boolean expression used to match which logs to count. By default, all logs are counted. |
log_metric_name | string | log.count | The name of the metric created. |
log_metric_units | string | {logs} | The unit of the metric created. See Unified Code for Units of Measure for available units. |
log_attributes | map | {} | The mapped attributes of the metric created. Each key is an attribute name. Each value is an expression that extracts data from the log. |
enable_metrics | bool | false | Enables or disables counting of metric datapoints. |
datapoint_match | string | true | A boolean expression used to match which datapoints to count. By default, all datapoints are counted. |
datapoint_metric_name | string | datapoint.count | The name of the metric created. |
datapoint_metric_units | string | {datapoints} | The unit of the metric created. See Unified Code for Units of Measure for available units. |
datapoint_attributes | map | {} | The mapped attributes of the metric created. Each key is an attribute name. Each value is an expression that extracts data from the datapoint. |
enable_traces | bool | false | Enables or disables counting of trace spans. |
span_match | string | true | A boolean expression used to match which spans to count. By default, all spans are counted. |
span_metric_name | string | span.count | The name of the metric created. |
span_metric_units | string | {spans} | The unit of the metric created. See Unified Code for Units of Measure for available units. |
span_attributes | map | {} | The mapped attributes of the metric created. Each key is an attribute name. Each value is an expression that extracts data from the span. |
interval | int | 60 | The interval, in seconds, at which metrics are created. Telemetry counters will reset after each interval. |
Expression Language
In order to match or extract values from telemetry, the following keys
are reserved and can be used to traverse the data model.
Logs
Key | Description |
---|---|
body | Used to access the body of the log. |
attributes | Used to access the attributes of the log. |
resource | Used to access the resource of the log. |
severity_enum | Used to access the severity enum of the log. |
severity_number | Used to access the severity number of the log. |
Datapoints
Key | Description |
---|---|
attributes | Used to access the attributes of the datapoint. |
resource | Used to access the resource of the datapoint. |
metric_name | Used to access the name of the metric that contains the datapoint. |
datapoint_value | Used to access the value of Sum and Gauge metrics. |
Spans
Key | Description |
---|---|
attributes | Used to access the attributes of the datapoint. |
resource | Used to access the resource of the datapoint. |
trace_status_message | Used to access the status message of the span. |
trace_status_code | Used to access the status code enum of the span. Values may be "ok", "error", or "unset". |
trace_kind | Used to access the kind enum of the span. Values may be "unspecified", "internal", "client", "server", "consumer", or "producer". |
span_duration_ms | Used to access the duration of the span, in milliseconds. |
Syntax
In order to access embedded values, use JSON dot notation. For example, body.example.field
can be used to access a field two levels deep on the log body.
However, if a key already possesses a literal dot, users will need to use bracket notation to access that field. For example, when the field service.name
exists on the log's resource, users will need to use resource["service.name"]
to access this value.
For more information about syntax and available operators, see the Expression Language Definition.
Example Configurations
Count all telemetry
By default, enabling metrics, traces, or logs will count all of their respective telemetry types.
Count all logs
Count all datapoints
Count all spans
Count HTTP Requests by Status (logs)
In this configuration, we want to parse our HTTP server logs to count how many requests were completed, broken down by status code. Our logs are JSON with the following structure:
{
"level": "warn",
"host": "10.0.10.0",
"datetime":"2022-12-07T13:21",
"method": "POST",
"request": "/api/create",
"protocol": "HTTP/1.1",
"status": 500
}
The match expression will exclude all logs without a status code in its body:
body.status != nil
We'll name this metric http.request.count
, then we'll use the status code for the status_code
metric attribute on the created metric:
log_attributes:
status_code: body.status
Updated about 1 month ago