Managed Service for OpenTelemetry can receive trace, metric, and log data from your applications. Data can be reported directly or forwarded through an OpenTelemetry Collector.
Before you begin
-
To report log data, you must first activate Simple Log Service (SLS), create a Project and a Logstore, and create an AccessKey pair for log data reporting.
-
Obtain the required endpoints and authentication credentials. The following table lists all configuration variables used in this topic. Prepare the values based on your data type and reporting method. For more information, see Preparations.
Use case
Parameter
Description
Example
Report trace and metric data
Report data via gRPC
${GRPC_ENDPOINT}
The gRPC endpoint for Managed Service for OpenTelemetry, used to report trace and metric data.
If your service is deployed on Alibaba Cloud in the same region as Managed Service for OpenTelemetry, we recommend that you use the internal endpoint. Otherwise, use the public endpoint.
-
Internal endpoint: http://tracing-analysis-dc-hz-internal.aliyuncs.com:8090
-
Public endpoint: http://tracing-analysis-dc-hz.aliyuncs.com:8090
${GRPC_AUTHENTICATION_TOKEN}
The authentication token required to report data to Managed Service for OpenTelemetry over gRPC. For more information about how to obtain the token, see Preparations.
abcdef1234@abcdef****56789_abcdef1234@abcdef****56789
Report data via HTTP
${HTTP_TRACES_ENDPOINT}
The HTTP endpoint for Managed Service for OpenTelemetry, used to report trace data.
If your service is deployed on Alibaba Cloud in the same region as Managed Service for OpenTelemetry, we recommend that you use the internal endpoint. Otherwise, use the public endpoint.
-
Internal endpoint: http://tracing-analysis-dc-hz-internal.aliyuncs.com/adapt_***_***/api/otlp/traces
-
Public endpoint: http://tracing-analysis-dc-hz.aliyuncs.com/adapt_***_***/api/otlp/traces
${HTTP_METRICS_ENDPOINT}
The HTTP endpoint for Managed Service for OpenTelemetry, used to report metric data.
If your service is deployed on Alibaba Cloud in the same region as Managed Service for OpenTelemetry, we recommend that you use the internal endpoint. Otherwise, use the public endpoint.
-
Internal endpoint: http://tracing-analysis-dc-hz-internal.aliyuncs.com/adapt_***_***/api/otlp/metrics
-
Public endpoint: http://tracing-analysis-dc-hz.aliyuncs.com/adapt_***_***/api/otlp/metrics
Report log data
${SLS_ENDPOINT}
The endpoint of the Simple Log Service (SLS) Project, required only for reporting log data. For information on how to obtain an endpoint, see Service Endpoints.
test-project.cn-hangzhou.log.aliyuncs.com
${SLS_PROJECT}
The name of the Simple Log Service (SLS) Project, required only for reporting log data.
test-project
${SLS_LOGSTORE}
The name of the Simple Log Service (SLS) Logstore, required only for reporting log data.
test-logstore
${ALIYUN_ACCESS_KEY_ID}
The AccessKey ID of your Alibaba Cloud account, required only for reporting log data.
We recommend that you use the AccessKey pair of a RAM user that has only the write permissions on the Simple Log Service (SLS) Project. An AccessKey pair consists of an AccessKey ID and an AccessKey secret. For more information about how to grant a RAM user permissions to write data to a specific Project, see RAM custom policy examples. For more information about how to obtain an AccessKey pair, see AccessKey pair.
N/A
${ALIYUN_ACCESS_KEY_SECRET}
The AccessKey secret of your Alibaba Cloud account, required only for reporting log data.
We recommend that you use the AccessKey pair of a RAM user.
N/A
-
Direct reporting
Report trace and metric data directly to Managed Service for OpenTelemetry by configuring the endpoint and authentication information in your OpenTelemetry agent or SDK.
Option 1: Configure in code
The following Java examples configure the endpoints for Managed Service for OpenTelemetry to report data over HTTP or gRPC. For complete integration code and demos, visit the Integration Center or see Report 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 for 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 for Managed Service for OpenTelemetry.
.build()).build())
.setResource(resource)
.build();
...
Option 2: Configure with environment variables
You can also configure data reporting endpoints with environment variables. The following table lists the required variables for reporting data to Managed Service for OpenTelemetry. For more information, see OTLP Exporter Configuration.
|
Environment variable |
Description |
Example |
|
OTEL_SERVICE_NAME |
The application name. |
export OTEL_SERVICE_NAME=opentelemetry-demo-service |
|
OTEL_EXPORTER_OTLP_PROTOCOL |
The protocol for reporting data. Traces can be reported over Metrics can be reported over If you select a gRPC endpoint, set this variable to |
export OTEL_EXPORTER_OTLP_PROTOCOL=grpc |
|
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT |
The endpoint for reporting traces. Both HTTP and gRPC endpoints are supported. Use the ${GRPC_ENDPOINT} or ${HTTP_TRACES_ENDPOINT} value from the Before you begin section. |
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://tracing-analysis-dc-hz-internal.aliyuncs.com/adapt_***_***/api/otlp/traces
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://tracing-analysis-dc-hz-internal.aliyuncs.com:8090 |
|
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT |
The endpoint for reporting metrics. Both HTTP and gRPC endpoints are supported. Use the ${GRPC_ENDPOINT} or ${HTTP_METRICS_ENDPOINT} value from the Before you begin section. |
export OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://tracing-analysis-dc-hz-internal.aliyuncs.com/adapt_***_***/api/otlp/metrics
export OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=http://tracing-analysis-dc-hz-internal.aliyuncs.com:8090 |
|
OTEL_EXPORTER_OTLP_HEADERS |
The request headers for gRPC reporting, which are primarily used for authentication. Use the |
export OTEL_EXPORTER_OTLP_HEADERS=Authentication=abcdef1234@abcdef****56789_abcdef1234@abcdef****56789 |
Forwarding data via OpenTelemetry Collector
Collector editions
-
OpenTelemetry Collector (Core): Reports trace and metric data.
-
OpenTelemetry Collector (Contrib): Reports trace, metric, and log data.
Option 1: Deploy from ACK Marketplace
The ACK Marketplace provides only the OpenTelemetry Collector (Core) edition, not the Contrib edition. If you need to collect log data, use another deployment method.
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, then click Deploy in the upper-right corner of the page. -
On the Create page, select the cluster and namespace for deploying
opentelemetry-collector, and then click Next. The default namespace isotel-collector. -
On the Parameter Configurations page, set the
modeparameter todeploymentordaemonset, and then click OK.
Step 2: Configure collector parameters
-
On the Clusters page, click the target cluster.
-
In the left-side navigation pane, choose .
-
Select the namespace where the opentelemetry-collector is located. The default is
otel-collector. -
On the Configuration Item page, find opentelemetry-collector and click YAML.
-
Configure the
exporters,processors,receivers, andservicesections as shown in the following YAML examples, and then click OK.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 to check memory usage. You can change the value as needed. limit_percentage: 80 # The maximum memory usage as a percentage. You can change the value as needed. spike_limit_percentage: 25 # The additional memory as a percentage that is allowed for spikes. You can 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]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. You can change the value as needed. processors: batch: {} memory_limiter: check_interval: 5s # The interval at which to check memory usage. You can change the value as needed. limit_percentage: 80 # The maximum memory usage as a percentage. You can change the value as needed. spike_limit_percentage: 25 # The additional memory as a percentage that is allowed for spikes. You can 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 you complete the configuration, manually restart the opentelemetry-collector pod.
Option 2: Deploy with Docker
Step 1: Pull the image
OpenTelemetry Collector (Core)
For specific image versions, see https://hub.docker.com/r/otel/opentelemetry-collector/tags.
docker pull otel/opentelemetry-collector:latest
OpenTelemetry Collector (Contrib)
For specific image versions, see https://hub.docker.com/r/otel/opentelemetry-collector-contrib/tags.
docker pull otel/opentelemetry-collector-contrib:latest
Step 2: Prepare a configuration file
Create a config.yaml file and add the required configuration.
gRPC reporting (Core)
# 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 to check memory usage. You can change the value as needed.
limit_percentage: 80 # The maximum memory usage as a percentage. You can change the value as needed.
spike_limit_percentage: 25 # The additional memory as a percentage that is allowed for spikes. You can change the value as needed.
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317 # The default value is localhost:4317. You can change the value as needed.
http:
endpoint: 0.0.0.0:4318 # The default value is localhost:4318. You can 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]
HTTP reporting (Core)
# 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. You can change the value as needed.
processors:
batch: {}
memory_limiter:
check_interval: 5s # The interval at which to check memory usage. You can change the value as needed.
limit_percentage: 80 # The maximum memory usage as a percentage. You can change the value as needed.
spike_limit_percentage: 25 # The additional memory as a percentage that is allowed for spikes. You can change the value as needed.
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317 # The default value is localhost:4317. You can change the value as needed.
http:
endpoint: 0.0.0.0:4318 # The default value is localhost:4318. You can 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]
gRPC reporting (Contrib)
# config.yaml
exporters:
otlp:
endpoint: "${GRPC_ENDPOINT}"
headers:
Authentication: "${GRPC_AUTHENTICATION_TOKEN}"
tls:
insecure: true
# Optional: Configure the log exporter.
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 to check memory usage. You can change the value as needed.
limit_percentage: 80 # The maximum memory usage as a percentage. You can change the value as needed.
spike_limit_percentage: 25 # The additional memory as a percentage that is allowed for spikes. You can change the value as needed.
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317 # The default value is localhost:4317. You can change the value as needed.
http:
endpoint: 0.0.0.0:4318 # The default value is localhost:4318. You can 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]
# Optional: Configure the log data processing pipeline.
logs:
exporters: [alibabacloud_logservice/logs]
processors: [memory_limiter, batch]
receivers: [otlp]
HTTP reporting (Contrib)
# 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. You can change the value as needed.
# Optional: Configure the log exporter.
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 to check memory usage. You can change the value as needed.
limit_percentage: 80 # The maximum memory usage as a percentage. You can change the value as needed.
spike_limit_percentage: 25 # The additional memory as a percentage that is allowed for spikes. You can change the value as needed.
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317 # The default value is localhost:4317. You can change the value as needed.
http:
endpoint: 0.0.0.0:4318 # The default value is localhost:4318. You can 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]
# Optional: Configure the log data processing pipeline.
logs:
exporters: [alibabacloud_logservice/logs]
processors: [memory_limiter, batch]
receivers: [otlp]
Step 3: Mount the config and run
OpenTelemetry Collector (Core)
docker run -v $(pwd)/config.yaml:/etc/otelcol/config.yaml otel/opentelemetry-collector:latest
OpenTelemetry Collector (Contrib)
docker run -v $(pwd)/config.yaml:/etc/otelcol-contrib/config.yaml otel/opentelemetry-collector-contrib:latest