The Count Connector counts trace spans, trace span events, metrics, metric data points, and log records in exporter pipelines.
|
The Count Connector is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
|
The following are the default metric names:
-
trace.span.count
-
trace.span.event.count
-
metric.count
-
metric.datapoint.count
-
log.record.count
You can also expose custom metric names.
OpenTelemetry Collector custom resource (CR) with an enabled Count Connector
# ...
config: |
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
exporters:
prometheus:
endpoint: 0.0.0.0:8889
connectors:
count:
service:
pipelines: (1)
traces/in:
receivers: [otlp]
exporters: [count] (2)
metrics/out:
receivers: [count] (3)
exporters: [prometheus]
# ...
1 |
It is important to correctly configure the Count Connector as an exporter or receiver in the pipeline and to export the generated metrics to the correct exporter. |
2 |
The Count Connector is configured to receive spans as an exporter. |
3 |
The Count Connector is configured to emit generated metrics as a receiver.
|
If the Count Connector is not generating the expected metrics, you can check whether the OpenTelemetry Collector is receiving the expected spans, metrics, and logs, and whether the telemetry data flow through the Count Connector as expected. You can also use the Debug Exporter to inspect the incoming telemetry data.
|
|
The Count Connector can count telemetry data according to defined conditions and expose those data as metrics when configured by using such fields as spans
, spanevents
, metrics
, datapoints
, or logs
. See the next example.
Example OpenTelemetry Collector CR for the Count Connector to count spans by conditions
# ...
config: |
connectors:
count:
spans: (1)
<custom_metric_name>: (2)
description: "<custom_metric_description>"
conditions:
- 'attributes["env"] == "dev"'
- 'name == "devevent"'
# ...
1 |
In this example, the exposed metric counts spans with the specified conditions. |
2 |
You can specify a custom metric name such as cluster.prod.event.count .
|
Write conditions correctly and follow the required syntax for attribute matching or telemetry field conditions. Improperly defined conditions are the most likely sources of errors.
|
|
The Count Connector can count telemetry data according to defined attributes when configured by using such fields as spans
, spanevents
, metrics
, datapoints
, or logs
. See the next example. The attribute keys are injected into the telemetry data. You must define a value for the default_value
field for missing attributes.
Example OpenTelemetry Collector CR for the Count Connector to count logs by attributes
# ...
config: |
connectors:
count:
logs: (1)
<custom_metric_name>: (2)
description: "<custom_metric_description>"
attributes:
- key: env
default_value: unknown (3)
# ...
1 |
Specifies attributes for logs. |
2 |
You can specify a custom metric name such as my.log.count . |
3 |
Defines a default value when the attribute is not set. |