Skip to content

Commit 5ba61d6

Browse files
authored
6473 – Update collector configuration to allow multiple services (#110)
Updates the collector configuration to deal with receiving and exporting metrics from multiple services. ### Important **When thinking about adding multiple receivers/exporters, we need to take into consideration:** - unlike most otel-collector's receivers and exporters, we can't add multiple prometheus receivers by aliasing, e.g.: `prometheus/service_1`, `prometheus/service_2`. We can have only one receiver, which can have multiple jobs. - unlike when sending traces, we need to specify the dataset when exporting metrics to honeycomb via the otlp exporter. **The way we dealt with this is by using the routing connector:** - we have a pipeline with the prometheus receiver, and the connector functioning as the exporter - we have a second pipeline with the connector functioning as the receiver, and otlp set up as the exporter - inside the connector we have a table where we use the service name to decide into which pipeline it should go - the prometheus receiver sets the service name from the job_name **If we want to send prometheus metrics from another service, we would need to:** - add the endpoint variable to the otel-collector configuration in the docker-compose file (local development) - add a new job to prometheus' scrape_config, - add another item to the routing connector table - add another exporter `otlp/service_metrics`, with the correct Dataset (considering we are also sending metrics to Honeycomb) - add another pipeline `metrics/service` with the new exporter **Notes** - This does add some duplication, but seems the most straightforward way to deal with this, at least for now - There is a tool to dynamically allocate targets for the prometheus receiver, but it is specific to kubernetes, so not useful for us right now - Regarding the connector and debugging: the default_pipelines is where anything that is not matched is sent. We currently only use it when debugging. To debug the connector, you can also use the debug pipeline (commented out), and use the debug exporter. **References** - [Routing Connector](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/connector/routingconnector) - [Sending metrics to honeycomb](https://docs.honeycomb.io/send-data/opentelemetry/collector/#metrics-and-logs-signals) - [Prometheus Receiver](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/prometheusreceiver) - [Prometheus Receiver Configuration](https://github.com/prometheus/prometheus/blob/v2.28.1/docs/configuration/configuration.md#scrape_config) - [Two Prometheus receivers can't be defined](open-telemetry/opentelemetry-operator#3034) - [Target Allocator](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/prometheusreceiver#opentelemetry-operator)
1 parent f2aa02b commit 5ba61d6

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,12 @@ services:
169169
# volumes:
170170
# - ./otel-collector-config.yaml:/etc/otelcol-contrib/config.yaml
171171
# environment:
172+
# pender_metrics_endpoint: "pender:3200"
172173
# x_honeycomb_team: ${X_HONEYCOMB_TEAM} # Set this env var in your shell before running docker-compose
173174
# RAILS_ENV: development
174175
# SERVER_PORT: 3200
175176
# networks:
176-
# - dev
177+
# - dev
177178
web:
178179
build: check-web
179180
platform: linux/x86_64

otel-collector-config.yaml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ receivers:
22
prometheus:
33
config:
44
scrape_configs:
5-
- job_name: "prometheus"
5+
- job_name: "pender_metrics"
66
scrape_interval: 15s
77
static_configs:
8-
- targets: ["pender:3200"]
8+
- targets: ["${env:pender_metrics_endpoint}"]
9+
metrics_path: /metrics
910

1011
processors:
1112
memory_limiter:
@@ -17,19 +18,39 @@ processors:
1718
send_batch_size: 8192
1819

1920
exporters:
20-
otlp/metrics:
21+
otlp/pender_metrics:
2122
endpoint: "api.honeycomb.io:443" # US instance
2223
#endpoint: "api.eu1.honeycomb.io:443" # EU instance
2324
headers:
2425
"x-honeycomb-team": ${env:x_honeycomb_team} # Honeycomb API KEY
2526
"x-honeycomb-dataset": "pender"
27+
# for debugging purposes only
28+
# debug:
29+
# verbosity: normal
30+
31+
connectors:
32+
routing:
33+
default_pipelines: []
34+
# for debugging purposes only
35+
# default_pipelines: [metrics/debug]
36+
table:
37+
- context: resource
38+
condition: attributes["service.name"] == "pender_metrics"
39+
pipelines: [metrics/pender_honeycomb]
2640

2741
service:
2842
# telemetry:
2943
# logs:
3044
# level: "debug"
3145
pipelines:
32-
metrics:
46+
metrics/prometheus:
3347
receivers: [prometheus]
48+
exporters: [routing]
49+
metrics/pender_honeycomb:
50+
receivers: [routing]
3451
processors: [memory_limiter, batch]
35-
exporters: [otlp/metrics]
52+
exporters: [otlp/pender_metrics]
53+
# for debugging purposes only
54+
# metrics/debug:
55+
# receivers: [routing]
56+
# exporters: [debug]

0 commit comments

Comments
 (0)