opentelemetry-collector-contrib
opentelemetry-collector-contrib copied to clipboard
[receiver/statsd] Add Option to Aggregate on IP/Host
Description: <Describe what has changed.>
The statsdreceiver
only aggregates metrics on protocol+host+ip
, this leads to issues or inconsistencies when dealing with clients that constantly switch tcp/udp ports. To address the issue, this PR adds a configuration option enableIPOnlyAggregation
that allows the use to specify if they want to aggregate on the IP
instead of IP+Port
.
For example:
otel_config.yaml:
receivers:
statsd:
endpoint: "0.0.0.0:8125"
enable_metric_type: true
is_monotonic_counter: false
aggregation_interval: 10s
enable_ip_only_aggregation: true # <-- enable ip only aggregation
timer_histogram_mapping:
- statsd_type: "timing"
observer_type: "histogram"
histogram:
max_size: 50
exporters:
debug:
verbosity: detailed
service:
pipelines:
metrics:
receivers:
- statsd
exporters:
- debug
run:
STATSD_HOST="localhost"
STATSD_PORT=8125
for port in {10000..10010}; do
echo -n "my.metric:1|c" | nc -w 1 -u -p $port ${STATSD_HOST} ${STATSD_PORT}
echo "Sent from port $port"
done
result:
2024-08-26T23:36:00.224+0200 info ResourceMetrics #0
Resource SchemaURL:
ScopeMetrics #0
ScopeMetrics SchemaURL:
InstrumentationScope otelcol/statsdreceiver 0.103.0-dev
Metric #0
Descriptor:
-> Name: -n my.metric
-> Description:
-> Unit:
-> DataType: Sum
-> IsMonotonic: false
-> AggregationTemporality: Delta
NumberDataPoints #0
Data point attributes:
-> metric_type: Str(counter)
StartTimestamp: 2024-08-26 21:35:50.223101 +0000 UTC
Timestamp: 2024-08-26 21:36:00.224252 +0000 UTC
Value: 7
{"kind": "exporter", "data_type": "metrics", "name": "debug"}
2024-08-26T23:36:10.224+0200 info MetricsExporter {"kind": "exporter", "data_type": "metrics", "name": "debug", "resource metrics": 1, "metrics": 1, "data points": 1}
2024-08-26T23:36:10.224+0200 info ResourceMetrics #0
Resource SchemaURL:
ScopeMetrics #0
ScopeMetrics SchemaURL:
InstrumentationScope otelcol/statsdreceiver 0.103.0-dev
Metric #0
Descriptor:
-> Name: -n my.metric
-> Description:
-> Unit:
-> DataType: Sum
-> IsMonotonic: false
-> AggregationTemporality: Delta
NumberDataPoints #0
Data point attributes:
-> metric_type: Str(counter)
StartTimestamp: 2024-08-26 21:36:00.224252 +0000 UTC
Timestamp: 2024-08-26 21:36:10.224607 +0000 UTC
Value: 4
{"kind": "exporter", "data_type": "metrics", "name": "debug"}
Instead of generating 11 metrics for each port that was used to send, only 2 metrics are blocks are returned, who's values total 11.
Link to tracking Issue: #23809
Testing:
- [x] Added unit tests
Documentation: <Describe the documentation added.>
- [x] Added information to the statsdreceiver
README.md
describing the option.