2. Collecting: OpenTelemetry and Alloy #
What to send, and how.
The collection pipeline #
- An open standard: OTLP and Prometheus exporters.
- A collector between sources and databases.
- Consistent attributes and controlled cardinality: no user ID or raw URL as a label.
- Correlation:
trace_id/span_idin logs, exemplars on histograms.
Instrumenting with OpenTelemetry #
export OTEL_SERVICE_NAME=checkout
export OTEL_RESOURCE_ATTRIBUTES="service.namespace=boutique,service.version=1.8.2,deployment.environment.name=prod,service.criticality=high"
export OTEL_EXPORTER_OTLP_ENDPOINT=http://alloy:4318
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf# Java
java -javaagent:opentelemetry-javaagent.jar -jar app.jar
# Python
pip install opentelemetry-distro opentelemetry-exporter-otlp
opentelemetry-bootstrap -a install
opentelemetry-instrument python app.py
# Node.js
npm install @opentelemetry/auto-instrumentations-node
node --require @opentelemetry/auto-instrumentations-node/register app.jsBest practice : Start with automatic instrumentation, then add business spans and metrics. For the service map, enable the collector'sservicegraphconnector or Tempo'smetrics-generator.
Grafana Alloy and fleet management #
Alloy, the recommended collector with Observa, combines Prometheus scraping, logs, OpenTelemetry components and profiles. Observa can manage a fleet of Alloy instances remotely: inventory and central configuration, through the remotecfg block.
remotecfg {
url = "https://observa.example.com/api/fleet"
bearer_token = sys.env("OBSERVA_FLEET_TOKEN")
id = constants.hostname
attributes = { "env" = "prod", "role" = "vcenter-collector", "os" = constants.os }
}| Component | Collection |
|---|---|
| Linux / Windows | prometheus.exporter.unix, loki.source.journal · prometheus.exporter.windows, loki.source.windowsevent |
| VMware vCenter | otelcol.receiver.vcenter with a read-only account |
| Kubernetes | k8s-monitoring Helm chart |
| Databases | prometheus.exporter.postgres, mysql, mssql, oracledb |
| Network | prometheus.exporter.snmp (SNMPv3 recommended) |
| Sites and certificates | prometheus.exporter.blackbox |
Good to know : As soon as a component's metrics land in Prometheus, the matching built-in alerts turn on in auto mode: collecting a PostgreSQL exporter is enough to get its alerts.Sources #
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
Grafana Alloy: collecting and transforming telemetry
Learn how to use Grafana Alloy to collect, transform and route logs, metrics and traces. Discover...
Collecting logs into Loki: Alloy, Promtail, Docker and OpenTelemetry
Send logs to Loki: Grafana Alloy, Promtail, the Docker driver, OTLP, good labels, parsing and enr...
OpenTelemetry Collector, Grafana Alloy and Bindplane: comparing three approaches to telemetry pipelines
Detailed comparison of three ways to manage telemetry pipelines: the OpenTelemetry Collector in Y...
Grafana Alloy best practices: optimizing your telemetry collection
Discover the golden rules for configuring Grafana Alloy robustly: modularity, secrets management,...
Fleet Management in Grafana Cloud
Fleet Management in Grafana Cloud: remotely managing a fleet of Grafana Alloy and OpenTelemetry c...
Grafana Alloy environment variables: GOMEMLIMIT, sys.env and OTEL_RESOURCE_ATTRIBUTES
Which variables does Grafana Alloy actually read? GOMEMLIMIT, HTTP_PROXY, sys.env, OTEL_RESOURCE_...
Fleet Management, Kubernetes Monitoring and the OpenTelemetry engine: Alloy at scale
Manage hundreds of Alloys with remotecfg and Fleet Management, deploy the k8s-monitoring v4 Helm ...
Grafana Alloy: collecting system metrics and local logs
Learn how to configure Grafana Alloy to monitor the server it runs on, with a focus on configurat...
Grafana Alloy vs OpenTelemetry Collector: Which One Should You Choose?
A detailed comparison between Grafana Alloy and the OpenTelemetry Collector. Discover the strengt...