can receive trace, metric, and log data from your applications. It supports two reporting methods: direct reporting, and forwarding through an OpenTelemetry Collector.
Choose a reporting method
You can report telemetry data directly to Managed Service for OpenTelemetry, or forward it through an OpenTelemetry Collector. Choose a method based on the type of telemetry data that you want to report.
| Reporting method | Supported data types |
| Direct reporting | Traces and metrics |
| OpenTelemetry Collector (Core) | Traces and metrics |
| OpenTelemetry Collector (Contrib) | Traces, metrics, and logs |
Log data is forwarded through an OpenTelemetry Collector (Contrib) to Simple Log Service (SLS). If you want to report log data, use the Collector forwarding method with the Contrib edition.
If you forward data through an OpenTelemetry Collector, choose a deployment option. The OpenTelemetry Collector is available in two editions:
OpenTelemetry Collector (Core): supports reporting trace and metric data.
OpenTelemetry Collector (Contrib): supports reporting trace, metric, and log data.
The following table compares the deployment options described in this topic.
| Deployment option | Supported edition | Supported data types |
| Deploy to an ACK cluster from the ACK Marketplace | OpenTelemetry Collector (Core) | Traces and metrics |
| Deploy with Docker | OpenTelemetry Collector (Core) and OpenTelemetry Collector (Contrib) | Traces and metrics (Core). Traces, metrics, and logs (Contrib). |
| Other installation and deployment methods | See Other installation and deployment methods. | Varies by method |
Before you begin
To report log data, first activate Simple Log Service (SLS), create a Project and a Logstore, and create an AccessKey pair for log data reporting.
Obtain the endpoints and authentication credentials. The following table lists all configuration variables used in this topic. In code and configuration examples in this topic, placeholders in the
${VAR}format must be replaced with the actual values that you prepare. Prepare the endpoints and credentials that your scenario requires, based on the type of data you report and the reporting method you use. For more information, see Get started with Managed Service for OpenTelemetry.
| Use case | Variable | Description | Example |
| Report trace and metric data over gRPC | ${GRPC_ENDPOINT} | The gRPC endpoint of Managed Service for OpenTelemetry, which supports reporting trace and metric data. If your service runs on Alibaba Cloud in the same region as the endpoint region you select, use the Alibaba Cloud internal endpoint. Otherwise, use the public endpoint. |
|
| Report trace and metric data over gRPC | ${GRPC_AUTHENTICATION_TOKEN} | The authentication token required to report data over gRPC to Managed Service for OpenTelemetry. For information about how to obtain the token, see Get started with Managed Service for OpenTelemetry. | abcdef1234@abcdef****56789_abcdef1234@abcdef****56789 |
| Report trace and metric data over HTTP | ${HTTP_TRACES_ENDPOINT} | The HTTP endpoint of Managed Service for OpenTelemetry, which supports reporting trace data. If your service runs on Alibaba Cloud in the same region as the endpoint region you select, use the Alibaba Cloud internal endpoint. Otherwise, use the public endpoint. |
|
| Report trace and metric data over HTTP | ${HTTP_METRICS_ENDPOINT} | The HTTP endpoint of Managed Service for OpenTelemetry, which supports reporting metric data. If your service runs on Alibaba Cloud in the same region as the endpoint region you select, use the Alibaba Cloud internal endpoint. Otherwise, use the public endpoint. |
|
| Report log data | ${SLS_ENDPOINT} | The endpoint of the SLS Project. Required only when you report log data. For the steps to obtain the endpoint, see Endpoint. | test-project.cn-hangzhou.log.aliyuncs.com |
| Report log data | ${SLS_PROJECT} | The name of the SLS Project. Required only when you report log data. | test-project |
| Report log data | ${SLS_LOGSTORE} | The name of the SLS Logstore. Required only when you report log data. | test-logstore |
| Report log data | ${ALIYUN_ACCESS_KEY_ID} | The AccessKey ID of your Alibaba Cloud account. Required only when you report log data. We recommend that you use the AccessKey pair, which consists of an AccessKey ID and an AccessKey secret, of a Resource Access Management (RAM) user that has write permissions only on the SLS Project. For information about how to grant a RAM user permissions to write data to a specific Project, see RAM custom policy examples. For information about how to obtain an AccessKey pair, see AccessKey pair. | N/A |
| Report log data | ${ALIYUN_ACCESS_KEY_SECRET} | The AccessKey secret of your Alibaba Cloud account. Required only when you report log data. We recommend that you use the AccessKey pair of a RAM user that has write permissions only on the SLS Project. | N/A |
Direct reporting
Configure the reporting endpoint and the authentication information in the OpenTelemetry Agent or SDK to send the trace and metric data that OpenTelemetry collects directly to the Managed Service for OpenTelemetry server.
Option 1: Configure the reporting settings in code (Java example)
The following Java code examples show how to configure the endpoints of Managed Service for OpenTelemetry, which supports reporting over HTTP or gRPC. To view the complete integration code and demos, visit the Integration Center or see Report trace data from Java applications by using OpenTelemetry.
HTTP reporting
...
// Report trace data
SdkTracerProvider sdkTracerProvider = SdkTracerProvider.builder()
.addSpanProcessor(BatchSpanProcessor.builder(OtlpHttpSpanExporter.builder()
.setEndpoint("${HTTP_TRACES_ENDPOINT}") // Set the HTTP traces endpoint to report trace data to Managed Service for OpenTelemetry.
.build()).build())
.build();
// Report metric data
SdkMeterProvider sdkMeterProvider = SdkMeterProvider.builder()
.registerMetricReader(PeriodicMetricReader.builder(OtlpHttpMetricExporter.builder()
.setEndpoint("${HTTP_METRICS_ENDPOINT}") // Set the HTTP metrics endpoint to report metric data to Managed Service for OpenTelemetry.
.build()).build())
.build();
...gRPC reporting
...
// Report trace data
SdkTracerProvider sdkTracerProvider = SdkTracerProvider.builder()
.addSpanProcessor(BatchSpanProcessor.builder(OtlpGrpcSpanExporter.builder()
.setEndpoint("${GRPC_ENDPOINT}") // Set the gRPC endpoint to report trace data to Managed Service for OpenTelemetry.
.addHeader("Authentication","${GRPC_AUTHENTICATION_TOKEN}") // Set the authentication token of Managed Service for OpenTelemetry.
.build()).build())
.setResource(resource)
.build();
// Report metric data
SdkMeterProvider sdkMeterProvider = SdkMeterProvider.builder()
.registerMetricReader(PeriodicMetricReader.builder(OtlpGrpcMetricExporter.builder()
.setEndpoint("${GRPC_ENDPOINT}") // Set the gRPC endpoint to report metric data to Managed Service for OpenTelemetry.
.addHeader("Authentication", "${GRPC_AUTHENTICATION_TOKEN}") // Set the authentication token of Managed Service for OpenTelemetry.
.build()).build())
.setResource(resource)
.build();
...Option 2: Configure the reporting settings with environment variables
OpenTelemetry also supports configuring the data reporting endpoint with environment variables. The following table lists the environment variables required to report data to Managed Service for OpenTelemetry. For more OpenTelemetry OTLP environment variables, see OTLP Exporter Configuration.
Forwarding data through an OpenTelemetry Collector
An OpenTelemetry Collector receives trace, metric, and log data from your applications and forwards the data to Managed Service for OpenTelemetry based on its exporter configuration.
Option 1: Deploy to an ACK cluster from the ACK Marketplace
In this option, you deploy the collector to a Container Service for Kubernetes (ACK) cluster from the ACK Marketplace. The ACK Marketplace currently provides only the OpenTelemetry Collector (Core) edition, not the Contrib edition. To collect log data, use one of the other deployment methods.
Step 1: Deploy the collector
-
Log on to the ACK console. In the left navigation pane, click .
In the Marketplace, search for and click
opentelemetry-collector, and then click Deploy in the upper-right corner of the page.On the Create page, select the cluster and the namespace in which you want to deploy
opentelemetry-collector. The default namespace is otel-collector. Then, click Next.On the Parameter Configurations page, set the mode parameter to
deploymentordaemonset, and then click OK.
Step 2: Configure the collector parameters
On the Clusters page, click the target cluster.
In the left-side navigation pane, choose .
Select the namespace in which opentelemetry-collector is deployed. The default namespace is otel-collector.
On the Configuration Item page, find opentelemetry-collector, and then click YAML.
Configure the exporters, processors, receivers, and service sections based on the following YAML content, and then click OK.
opentelemetry-collector configuration item (gRPC reporting)
exporters: otlp: endpoint: "${GRPC_ENDPOINT}" headers: Authentication: "${GRPC_AUTHENTICATION_TOKEN}" tls: insecure: true processors: batch: {} memory_limiter: check_interval: 5s # The interval at which memory usage is checked. Change the value as needed. limit_percentage: 80 # The maximum memory usage as a percentage. Change the value as needed. spike_limit_percentage: 25 # The additional memory as a percentage that is allowed for spikes. Change the value as needed. receivers: otlp: protocols: grpc: endpoint: ${env:MY_POD_IP}:4317 http: endpoint: ${env:MY_POD_IP}:4318 service: pipelines: traces: exporters: [otlp] processors: [memory_limiter, batch] receivers: [otlp] metrics: exporters: [otlp] processors: [memory_limiter, batch] receivers: [otlp]opentelemetry-collector configuration item (HTTP reporting)
exporters: otlphttp: traces_endpoint: "${HTTP_TRACES_ENDPOINT}" metrics_endpoint: "${HTTP_METRICS_ENDPOINT}" tls: insecure: true timeout: 5s # The timeout period. The default value is 5s. Change the value as needed. processors: batch: {} memory_limiter: check_interval: 5s # The interval at which memory usage is checked. Change the value as needed. limit_percentage: 80 # The maximum memory usage as a percentage. Change the value as needed. spike_limit_percentage: 25 # The additional memory as a percentage that is allowed for spikes. Change the value as needed. receivers: otlp: protocols: grpc: endpoint: ${env:MY_POD_IP}:4317 http: endpoint: ${env:MY_POD_IP}:4318 service: pipelines: traces: exporters: [otlphttp] processors: [memory_limiter, batch] receivers: [otlp] metrics: exporters: [otlphttp] processors: [memory_limiter, batch] receivers: [otlp]After the configuration is complete, manually restart opentelemetry-collector.
Option 2: Deploy with Docker
In this option, you run the collector as a Docker container. Both the Core and Contrib editions are available.
Step 1: Pull the image
opentelemetry-collector
To specify an image version, visit https://hub.docker.com/r/otel/opentelemetry-collector/tags.
docker pull otel/opentelemetry-collector:latestopentelemetry-collector-contrib
To specify an image version, visit https://hub.docker.com/r/otel/opentelemetry-collector-contrib/tags.
docker pull otel/opentelemetry-collector-contrib:latestStep 2: Prepare the configuration file
Create a config.yaml file and configure the related parameters. In the following examples, placeholders in the ${VAR} format must be replaced with the values that you prepared in Before you begin. These placeholders are different from the Collector-native ${env:...} expansion syntax, such as ${env:MY_POD_IP}, which the Collector resolves from environment variables at runtime.
opentelemetry-collector configuration item (gRPC reporting)
# config.yaml
exporters:
otlp:
endpoint: "${GRPC_ENDPOINT}"
headers:
Authentication: "${GRPC_AUTHENTICATION_TOKEN}"
tls:
insecure: true
processors:
batch: {}
memory_limiter:
check_interval: 5s # The interval at which memory usage is checked. Change the value as needed.
limit_percentage: 80 # The maximum memory usage as a percentage. Change the value as needed.
spike_limit_percentage: 25 # The additional memory as a percentage that is allowed for spikes. Change the value as needed.
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317 # The default value is localhost:4317. Change the value as needed.
http:
endpoint: 0.0.0.0:4318 # The default value is localhost:4318. Change the value as needed.
service:
pipelines:
traces:
exporters: [otlp]
processors: [memory_limiter, batch]
receivers: [otlp]
metrics:
exporters: [otlp]
processors: [memory_limiter, batch]
receivers: [otlp]opentelemetry-collector configuration item (HTTP reporting)
# config.yaml
exporters:
otlphttp:
traces_endpoint: "${HTTP_TRACES_ENDPOINT}"
metrics_endpoint: "${HTTP_METRICS_ENDPOINT}"
tls:
insecure: true
timeout: 5s # The timeout period. The default value is 5s. Change the value as needed.
processors:
batch: {}
memory_limiter:
check_interval: 5s # The interval at which memory usage is checked. Change the value as needed.
limit_percentage: 80 # The maximum memory usage as a percentage. Change the value as needed.
spike_limit_percentage: 25 # The additional memory as a percentage that is allowed for spikes. Change the value as needed.
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317 # The default value is localhost:4317. Change the value as needed.
http:
endpoint: 0.0.0.0:4318 # The default value is localhost:4318. Change the value as needed.
service:
pipelines:
traces:
exporters: [otlphttp]
processors: [memory_limiter, batch]
receivers: [otlp]
metrics:
exporters: [otlphttp]
processors: [memory_limiter, batch]
receivers: [otlp]opentelemetry-collector-contrib configuration item (gRPC reporting)
# config.yaml
exporters:
otlp:
endpoint: "${GRPC_ENDPOINT}"
headers:
Authentication: "${GRPC_AUTHENTICATION_TOKEN}"
tls:
insecure: true
# Log exporter configuration (optional)
alibabacloud_logservice/logs:
endpoint: "${SLS_ENDPOINT}"
project: "${SLS_PROJECT}"
logstore: "${SLS_LOGSTORE}"
access_key_id: "${ALIYUN_ACCESS_KEY_ID}"
access_key_secret: "${ALIYUN_ACCESS_KEY_SECRET}"
processors:
batch: {}
memory_limiter:
check_interval: 5s # The interval at which memory usage is checked. Change the value as needed.
limit_percentage: 80 # The maximum memory usage as a percentage. Change the value as needed.
spike_limit_percentage: 25 # The additional memory as a percentage that is allowed for spikes. Change the value as needed.
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317 # The default value is localhost:4317. Change the value as needed.
http:
endpoint: 0.0.0.0:4318 # The default value is localhost:4318. Change the value as needed.
service:
pipelines:
traces:
exporters: [otlp]
processors: [memory_limiter, batch]
receivers: [otlp]
metrics:
exporters: [otlp]
processors: [memory_limiter, batch]
receivers: [otlp]
# Log data processing pipeline (optional)
logs:
exporters: [alibabacloud_logservice/logs]
processors: [memory_limiter, batch]
receivers: [otlp]opentelemetry-collector-contrib configuration item (HTTP reporting)
# config.yaml
exporters:
otlphttp:
traces_endpoint: "${HTTP_TRACES_ENDPOINT}"
metrics_endpoint: "${HTTP_METRICS_ENDPOINT}"
tls:
insecure: true
timeout: 5s # The timeout period. The default value is 5s. Change the value as needed.
# Log exporter configuration (optional)
alibabacloud_logservice/logs:
endpoint: "${SLS_ENDPOINT}"
project: "${SLS_PROJECT}"
logstore: "${SLS_LOGSTORE}"
access_key_id: "${ALIYUN_ACCESS_KEY_ID}"
access_key_secret: "${ALIYUN_ACCESS_KEY_SECRET}"
processors:
batch: {}
memory_limiter:
check_interval: 5s # The interval at which memory usage is checked. Change the value as needed.
limit_percentage: 80 # The maximum memory usage as a percentage. Change the value as needed.
spike_limit_percentage: 25 # The additional memory as a percentage that is allowed for spikes. Change the value as needed.
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317 # The default value is localhost:4317. Change the value as needed.
http:
endpoint: 0.0.0.0:4318 # The default value is localhost:4318. Change the value as needed.
service:
pipelines:
traces:
exporters: [otlphttp]
processors: [memory_limiter, batch]
receivers: [otlp]
metrics:
exporters: [otlphttp]
processors: [memory_limiter, batch]
receivers: [otlp]
# Log data processing pipeline (optional)
logs:
exporters: [alibabacloud_logservice/logs]
processors: [memory_limiter, batch]
receivers: [otlp]Step 3: Mount the custom configuration file and run the collector
The -p flags publish the receiver ports so that your applications can send data to the collector. Adjust the port mapping to match the receiver endpoints in your configuration file.
opentelemetry-collector
docker run -p 4317:4317 -p 4318:4318 -v $(pwd)/config.yaml:/etc/otelcol/config.yaml otel/opentelemetry-collector:latestopentelemetry-collector-contrib
docker run -p 4317:4317 -p 4318:4318 -v $(pwd)/config.yaml:/etc/otelcol-contrib/config.yaml otel/opentelemetry-collector-contrib:latestFor other deployment methods, see Other installation and deployment methods.