Chronosphere recommends not sending OTLP metrics directly from the OpenTelemetry
Client SDK.
Prerequisites
To use the OpenTelemetry Collector, you need to create a restricted service account, which generates an API token you use to authenticate with Observability Platform. The access you provide for the service account depends on how you use the OpenTelemetry Collector.| Use case | Read access | Write access |
|---|---|---|
| Collect metrics | ||
| Remote head sampling only | ||
| Collect traces plus remote head sampling |
$API_TOKEN. Binding a Secret to
an environment variable on the Pod is a well-supported, secure pattern in Kubernetes.
Configure the OpenTelemetry Collector
To configure the OpenTelemetry Collector to ingest metric and trace data:-
Pull the OpenTelemetry Docker image
to run the OpenTelemetry Collector in a Docker container:
Replace
VERSIONwith the version of the OpenTelemetry Collector you want to run, which must be version 0.83 or later. -
In the OpenTelemetry Collector
config.yamlfile, apply the following settings to modify theexporterYAML collection. Specify anendpointthat points to your Observability Platform tenant, and include the Chronosphere API key you created as an HTTP header. You can modify the OpenTelemetry Collector configuration if you want to change the defaults. For example, you can reference aconfig.yamlin a different location, such as a Kubernetes ConfigMap.-
endpoint: Your organization name prefixed to your Observability Platform tenant’s address that ends in.chronosphere.io:443. For example,MY_COMPANY.chronosphere.io:443. -
timeout: Set to30sto prevent larger requests from timing out, because the upstream system might require more time for internal batching. -
retry_on_failure: Setenabledtotrueto enable retries for all retryable errors. -
sending_queue: Setnum_consumersto the number of consumers that dequeue batches from the sending queue. Increase the value ofnum_consumersif the exporter queue size demonstrates variability over time. A healthy sending queue metric depicts a small number of batches that shouldn’t experience spikes over time. Chronosphere recommends setting this to 50 for gateway deployments of OTel Collectors. -
compression: The compression method to apply. The Chronosphere OpenTelemetry endpoint supportssnappy,gzip, andzstdcompression, ornone. -
API-Token: The API token generated from your service account, specified as an HTTP header. Chronosphere recommends calling this value as an environment variable. -
Chronosphere-Metrics-Validation-Response: TheErrorMessageverbosity for rejected metrics. Default:SHORT. Valid values are:SHORT, which reports the number of rejected metrics.SUMMARY, which also includes counts of rejection reasons.DETAILED, which also includes a sample of rejected metrics.
-
-
Configure
batch processing.
Sending telemetry in batches improves data compression and reduces the number of
outgoing connections required to transmit the data.
For example, the following configuration enforces a maximum batch size limit of
2000spans without introducing any artificial delays:Thetimeout,batch size, andbatch max sizeare default recommendations. Monitor the exporter send and enqueueing failure metrics to tune these parameters based on your workload. -
Add the OTLP exporter and the batch processor to the metrics and traces exporters
definition.
-
Instruct the OpenTelemetry Collector to load the API token from an environment
variable.
-
Save your OpenTelemetry Collector
config.yamlfile.
Map resource attributes to Prometheus job and instance
Observability Platform uses the OpenTelemetryservice.namespace, service.name
and service.instance.id resource attributes as the values for the Prometheus
job and instance source labels.
service.namespace/service.name -> job: Recommended. Observability Platform sets the job label value as a concatenation ofservice.namespaceandservice.nameattribute values. If onlyservice.nameis set, thenjob = "service.name". If neitherservice.namespaceorservice.nameare present as resource attributes, then Observability Platform doesn’t create a job label as part of the conversion.service.instance.id -> instance: Required. Observability Platform sets the instance label value to theservice.instance.idattribute value. Observability Platform rejects the metric if theservice.instance.idresource attribute is missing.
service.instance.id attribute, copy an existing,
unique resource attribute, such as host.name or pod.id, as the unique instance
identifier value for service.instance.id.
To define a default service.instance.id resource attribute:
-
Add a resource detection processor. Use the resource detection processor can to
detect resource information from the environment. Append or override the resource
value in telemetry data with this information. Configure the resource detection
processor based on the environment where you’ve deployed the Collector. Review the
resource detection processor documentation
to select the processor for your environment. For example, if the Collector is
deployed on a host, the system processor is the best option to gather information
about the host.
-
Define a resource attribute processor.
In the processors ConfigMap, define a rule to add the
service.instance.id. The following example maps thehost.nameresource attribute to a newservice.instance.idresource attribute. Depending on how resource detection is configured, your environment might have other resource attributes available, such ask8s.node.uid, which can serve as the instance identifier. -
Add the resource detection and resource attribute processors to your metrics
processors pipeline. In the
service.pipelines.metrics.processorsConfigMap, add the resource attribute processor defined in the previous step:
Send operational metrics about the OpenTelemetry Collector
The OpenTelemetry Collector exposes metrics about its operations using a Prometheus scrape endpoint. Observability Platform uses OpenTelemetry Collector metrics in the OpenTelemetry Ingestion & Health dashboard to describe Collector health. To send operational metrics about your OpenTelemetry Collectors to Observability Platform:-
Define a Prometheus receiver to scrape the endpoint receiver:
-
Add the Prometheus receiver to the metrics pipeline:
-
Add the metrics service to the Service ConfigMap:
Next steps
Observability Platform should begin ingesting data. Verify the Collector is receiving metrics and traces. You can also configure head sampling to determine whether to drop a span or trace as early as possible. If you encounter issues, see the troubleshooting page.OpenTelemetry configuration example
The following example is the entire configuration file, containing all of the previously provided required sections:copy