The correction is integrated into the TP (See the green boxes)
What you will learn in this TP
- Configure a Collector to the New Relic OTLP endpoint
- Remove a sensitive attribute before sending
- Convert metrics to delta temporality
- Find an OpenTelemetry entity in New Relic
All steps and instructions are shown. Recommended for this lab: semi-guided
Introduction #
Context. The payment team chose OpenTelemetry so as not to depend on any vendor. You route its telemetry through a Collector that removes customer e-mails and sends it to New Relic.
Prerequisites: a free New Relic account (license key), a machine with Docker, curl and jq, Lab 1 (optional) · Estimated time: 40 min
Apaiement-tp service visible in New Relic with traces, metrics and logs, without any e-mail address.Setup #
Guided steps, with their solution.
1. Configure the Collector
Why? A Collector centralizes authentication, masking and backend choice: applications no longer need to know about New Relic.
Write the configuration (OTLP receiver,resource,attributes/pii,cumulativetodeltaprocessors,otlphttpexport with theapi-keyheader) and runotelcol.See the correction
mkdir -p ~/nr-otel && cd ~/nr-otel cat > collector.yaml <<'EOF' receivers: otlp: protocols: grpc: { endpoint: 0.0.0.0:4317 } http: { endpoint: 0.0.0.0:4318 } processors: memory_limiter: { check_interval: 1s, limit_mib: 400 } resource: attributes: - { key: deployment.environment, value: tp, action: upsert } attributes/pii: actions: - { key: user.email, action: delete } cumulativetodelta: {} batch: {} exporters: otlphttp/newrelic: endpoint: https://otlp.nr-data.net # EU account : https://otlp.eu01.nr-data.net headers: api-key: ${env:NEW_RELIC_LICENSE_KEY} service: pipelines: traces: { receivers: [otlp], processors: [memory_limiter, resource, attributes/pii, batch], exporters: [otlphttp/newrelic] } metrics: { receivers: [otlp], processors: [memory_limiter, resource, cumulativetodelta, batch], exporters: [otlphttp/newrelic] } logs: { receivers: [otlp], processors: [memory_limiter, resource, attributes/pii, batch], exporters: [otlphttp/newrelic] } EOF docker network create nr-otel 2>/dev/null docker run -d --name otelcol --network nr-otel -e NEW_RELIC_LICENSE_KEY \ -v $PWD/collector.yaml:/etc/otelcol-contrib/config.yaml:ro otel/opentelemetry-collector-contrib:0.165.0 sleep 5 && docker logs otelcol 2>&1 | tail -32. Generate telemetry
Why? telemetrygen simulates an instrumented service, with an e-mail attribute to test masking.
Send traces (withuser.email), metrics and logs for two minutes as thepaiement-tpservice.See the correction
TG=ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:v0.165.1 docker run --rm --network nr-otel $TG traces --otlp-endpoint otelcol:4317 --otlp-insecure \ --service paiement-tp --duration 120s --rate 5 --child-spans 3 --otlp-attributes 'user.email="alice@exemple.fr"' & docker run --rm --network nr-otel $TG metrics --otlp-endpoint otelcol:4317 --otlp-insecure --service paiement-tp --duration 120s --rate 2 & docker run --rm --network nr-otel $TG logs --otlp-endpoint otelcol:4317 --otlp-insecure --service paiement-tp --duration 120s --rate 3 --body 'paiement accepté' & wait3. Find the service
Why? The entity is created from
service.name: a wrong name creates an orphan entity.Open APM & Services, filter on OpenTelemetry and openpaiement-tp. Check traces, logs and thedeployment.environmentattribute.See the correction
SELECT count(*) FROM Span WHERE service.name = 'paiement-tp' FACET name SINCE 15 minutes ago SELECT count(*) FROM Log WHERE service.name = 'paiement-tp' SINCE 15 minutes ago SELECT uniques(deployment.environment) FROM Span WHERE service.name = 'paiement-tp' SINCE 15 minutes ago4. Check masking
Why? Personal data stored at a vendor is hard to erase: you must prove it never left.
Check that no span carriesuser.email. What would you add to also mask an e-mail present in a log body?See the correction
SELECT count(*) FROM Span WHERE service.name = 'paiement-tp' AND user.email IS NOT NULL SINCE 15 minutes ago -- expected result: 0 -- For log bodies: transform processor with replace_pattern(body, "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+", "***") -- or a log obfuscation rule in New Relic5. Clean up
Why? Stopped containers send nothing more: free tier consumption stays under control.
Stop the Collector and remove the network. Keep the Lab 1boutiqueapplication for the next lab.See the correction
docker rm -f otelcol && docker network rm nr-otel
Validate your work
Check that each goal above is reached and that you get the result described in the introduction.
Difficulty level : ●●●○○ (3/5)
My progress
Sign in to track your progress and take notes. Sign in
💬 Questions about this lesson
No questions yet: be the first to ask for help or share your configuration.
Recommended Articles
New Relic APM: agents, OpenTelemetry and distributed traces
Instrumenting applications with New Relic: language agents, configuration, transactions and Apdex...
Infrastructure, logs and Kubernetes with New Relic
Monitoring servers, containers and Kubernetes with New Relic: infrastructure agent, on-host integ...
New Relic: the observability platform at a glance
Discover New Relic: history, the unified platform and NRDB, MELT data types, entities and golden ...
OpenTelemetry and Dynatrace: OTLP, collector and instrumentation
Integrate OpenTelemetry with Dynatrace: OTLP endpoint and tokens, Dynatrace OTel Collector, trace...
NRQL: querying all your New Relic data
Mastering NRQL, New Relic's query language: SELECT … FROM structure, filters, aggregation functio...
New Relic dashboards: building, sharing and analysing
Building useful dashboards in New Relic: NRQL widgets, chart choice, template variables, facet li...
Alerts, service levels and incidents in New Relic
Setting up useful alerting in New Relic: policies and NRQL conditions, static and anomaly thresho...
Automating New Relic and controlling costs
Managing New Relic as code and keeping the bill under control: NerdGraph API, newrelic CLI, newre...
New Relic best practices
Best practices to succeed with New Relic: adoption approach, account organization, naming and tag...