Skip to content

Commit

Permalink
add env attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
IvannKurchenko committed Feb 21, 2024
1 parent 9d0e80f commit 8cc6267
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions blog/BLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,12 @@ collector processors.

https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/filterprocessor - filter processor;
show example - filter traces and metrics for health checks
https://opentelemetry.io/docs/collector/transforming-telemetry/#basic-filtering

https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/attributesprocessor
- attributes processor;
Add attribute - environment=prod for all signals.
https://opentelemetry.io/docs/collector/transforming-telemetry/#adding-or-deleting-attributes

## Links and further reading
Code source for this blog post can be found [here](TODO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ processors:
span:
- 'attributes["http.route"] == "/health"'

# Filter metrics for `GET /health` requests logs because of spam.
# Filter logs for `GET /health` requests logs because of spam.
# Log line body to filter example: `Health check API invoked!`
# See documentation for more details:
# https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/filterprocessor
Expand All @@ -44,6 +44,15 @@ processors:
bodies:
- '.*Health check API invoked!.*'

# Add environment attribute to all telemetry signals.
# See documentation for more details:
# https://opentelemetry.io/docs/collector/transforming-telemetry/#adding-or-deleting-attributes
attributes/add-environment:
actions:
- key: environment
value: development
action: insert

# Exporters' configuration section
# See for more details following documentation: https://opentelemetry.io/docs/collector/configuration/#exporters
# Important note: exporter name patter is following - `{protocol}/{exporter_name}`.
Expand Down Expand Up @@ -71,6 +80,7 @@ service:
processors:
- memory_limiter
- filter/exclude-health-api-traces
- attributes/add-environment
exporters:
- otlphttp/jaeger
- otlphttp/grafana-agent
Expand All @@ -79,6 +89,7 @@ service:
- otlp
processors:
- memory_limiter
- attributes/add-environment
exporters:
- prometheus
- otlphttp/grafana-agent
Expand All @@ -88,5 +99,6 @@ service:
processors:
- memory_limiter
- filter/exclude-health-api-logs
- attributes/add-environment
exporters:
- otlphttp/grafana-agent
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ services:
image: otel/opentelemetry-collector-contrib:0.93.0
hostname: otel-collector
volumes:
- ./mount/otel-collector-config-prometheus-jaeger-grafana-filter.yaml:/etc/otelcol-contrib/config.yaml
- ./mount/otel-collector-config-prometheus-jaeger-grafana-process.yaml:/etc/otelcol-contrib/config.yaml
networks:
- products

Expand Down

0 comments on commit 8cc6267

Please sign in to comment.