Data transmission via OpenTelemetry Collector
OpenTelemetry Collector (OTel Collector) is an agent that collects, processes, and exports telemetry data based on the OpenTelemetry
Setting up transfer of metrics from an app
-
Add the Monium project name to the
MONIUM_PROJECTenvironment variable.The project name format is
folder__{folder_id}, wherefolder_idis the ID of the Yandex Cloud folder containing your app.The folder must have the
monitoring.editorrole or higher assigned to it. -
In this folder, create a service account and API key with the
yc.monitoring.manageandyc.logging.writescopes. -
Add the API key to the
MONIUM_API_KEYenvironment variable. -
Add the OpenTelemetry SDK
to your app. -
Install
OTel Collector. -
In the
otel-collector.yamlconfiguration file, configure data transfer to Monium:-
In the
x-monium-projectheader, specify the project name: theMONIUM_PROJECTorfolder__{folder_id}variable. -
Add to the configuration the
cumulativetodeltaprocessorprocessor to provide monotonically increasing sums as aRATEtype metric. -
Optionally, enable
zstdcompression to reduce CPU consumption compared to the defaultgzipmethod.Example of a minimal
otel-collector.yamlconfiguration:receivers: # Configuration of input data (metrics, logs, traces) otlp: # Target type: OTLP (OpenTelemetry Protocol) protocols: # List of protocols the Collector will await data on: grpc: # gRPC, default port 4317 http: # HTTP, default port 4318 processors: cumulativetodelta: exporters: # Receiving system parameters: Monium otlp/monium: compression: zstd endpoint: ingest.monium.yandex.cloud:443 headers: Authorization: Api-Key ${env:MONIUM_API_KEY} x-monium-project: ${env:MONIUM_PROJECT} service: # Routing of data processing in Collector pipelines: metrics: # Transfer of metrics, you can also add traces and logs receivers: [ otlp ] processors: [ batch, cumulativetodelta ] exporters: [ otlp/monium ]
-
-
Add the name of your app or service to the
OTEL_SERVICE_NAMEenvironment variable. -
Run the app.
-
View the submitted metrics.
-
Open the shard list:
https://monium.yandex.cloud/projects/<project_name>/shards/Where
<project_name>is the${MONIUM_PROJECT}variable or thefolder__{folder_id}record. -
Select the shard of your application or service.
-
Distribution of metrics across shards
Monium stores data in shards with the project, cluster, and service keys. The shard key is selected based on a priority table, with priority decreasing from left to right.
| header | resource attribute | resource attribute | constant |
|---|---|---|---|
x-monium-project |
— | — | — |
x-monium-cluster |
cluster |
deployment.name |
default |
x-monium-service |
service |
service.name |
default |
Example of adding telemetry
In this example, you will add telemetry tools to the Spring Pet Clinic
-
Install and set up OTel Collector.
-
Download the repository and build the app:
git clone https://github.com/spring-projects/spring-petclinic cd spring-petclinic ./mvnw clean package -
Download the Java agent for telemetry collection:
curl -L 'https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar' > opentelemetry-javaagent.jar -
Configure the
service.nameresource attribute via theOTEL_SERVICE_NAMEenvironment variable. -
Run the application with the Java agent sending data to the locally installed otel-collector:
OTEL_SERVICE_NAME=pet-clinic java -javaagent:opentelemetry-javaagent.jar -jar target/spring-petclinic-*-SNAPSHOT.jar -
View the submitted metrics in the shard at the following link:
https://monium.yandex.cloud/projects/<project_name>/shards/<project_name>_default_pet-clinicWhere
<project_name>is the${MONIUM_PROJECT}variable or thefolder__{folder_id}record.OTel Collector transmits data within one minute.