Managed Service for Prometheus accepts OpenTelemetry metrics through OTLP/HTTP endpoints. Configure your OpenTelemetry SDK or Collector to export metrics to these endpoints, then query and visualize the data in Grafana.
Before you begin
Create a Prometheus instance for your environment:
Limits
Protocol: Only HTTP is supported. gRPC is not supported.
Serialization: Configure the
application/protobufserialization method for the Content-Encoding header. Theapplication/jsonserialization method is not supported.Unsupported metric types: Histogram(delta) and Exponential Histogram are not supported. Use Histogram(cumulative) instead.
Supported regions
| Region | Region ID |
|---|---|
| China (Hangzhou) | cn-hangzhou |
| China (Shanghai) | cn-shanghai |
| China (Shenzhen) | cn-shenzhen |
| China (Heyuan) | cn-heyuan |
| China (Guangzhou) | cn-guangzhou |
| China (Qingdao) | cn-qingdao |
| China (Beijing) | cn-beijing |
| China (Zhangjiakou) | cn-zhangjiakou |
| China (Hohhot) | cn-huhehaote |
| China (Ulanqab) | cn-wulanchabu |
| China (Chengdu) | cn-chengdu |
| China (Hong Kong) | cn-hongkong |
| Singapore | ap-southeast-1 |
OpenTelemetry-to-Prometheus metric type mapping
When Managed Service for Prometheus ingests OpenTelemetry metrics, it maps them to Prometheus metric types as follows:
| OpenTelemetry | Prometheus |
|---|---|
| Sum (monotonic, cumulative) | Counter |
| Sum (monotonic, delta) | Gauge |
| Sum (non-monotonic, cumulative) | Gauge |
| Gauge | Gauge |
| Histogram (cumulative) | Histogram |
| Histogram (delta) | Not supported |
| Exponential Histogram | Not supported |
| Summary | Summary |
Step 1: Get the OpenTelemetry endpoint
-
Log on to the ARMS console.
-
In the left navigation pane, choose .
In the top navigation bar, select the region of your Prometheus instance, find the instance, and click Settings in the Actions column.
On the Settings page, copy the endpoint URL. Choose the endpoint based on your network environment:
Public endpoint: Use this when your application accesses Managed Service for Prometheus over the internet.
Internal endpoint: Use this when your application runs within the same Alibaba Cloud region and connects through the internal network.
Step 2: Configure your OpenTelemetry exporter
Configure your OpenTelemetry metric exporter to send data to the endpoint from Step 1.
Configure with environment variables (all languages)
Set the standard OpenTelemetry environment variables to configure the exporter for any language SDK or the OpenTelemetry Collector:
# Required: Set the OTLP endpoint from Step 1
export OTEL_EXPORTER_OTLP_ENDPOINT=<your-opentelemetry-endpoint>
# Required: Use HTTP/protobuf protocol (gRPC is not supported)
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
# Recommended: Enable gzip compression to reduce network usage
export OTEL_EXPORTER_OTLP_COMPRESSION=gzipReplace <your-opentelemetry-endpoint> with the endpoint URL copied from the ARMS console in Step 1.
Configure with the Java SDK
Replace the endpoint in OtlpHttpMetricExporterBuilder with the endpoint from Step 1:
import io.opentelemetry.exporter.otlp.http.metrics.OtlpHttpMetricExporter;
OtlpHttpMetricExporter exporter = OtlpHttpMetricExporter.builder()
.setEndpoint("<your-opentelemetry-endpoint>") // Endpoint from Step 1
.setCompression("gzip") // Recommended: reduce network usage
.build();For a complete, runnable example, see the sample code on GitHub.
Optional parameters
| Parameter | Requirement | Description |
|---|---|---|
Compression | Recommended | Set to gzip to reduce network consumption. Disabled by default. |
metricNamespace | Optional | Add a prefix to all metric names when reporting to Managed Service for Prometheus. Set this through a custom header. |
skipGlobalLabel | Optional | Set to true through a custom header to prevent Managed Service for Prometheus from attaching default OpenTelemetry scope labels to your metrics. |
To configure metricNamespace and skipGlobalLabel, add them as custom HTTP headers in your exporter configuration. For implementation details, see the sample code.
Step 3: Verify metrics in Grafana
After your application starts sending metrics, verify the data is arriving by querying it in Grafana.
-
Log on to the ARMS console. In the left-side navigation pane, choose .
On the Workspace Management page, click Grafana shared edition. On the Workspace Information page, select a public endpoint and click Log On.
In the left-side navigation pane of Grafana, click the Explore icon.
In the data source dropdown at the top of the Explore page, select the Prometheus instance that corresponds to the endpoint you configured in Step 1.
ImportantSelect your Prometheus instance as the data source, not a different data source.
Enter a PromQL query to search for your metrics. For example, if your application exports a metric named
http_requests_total, typehttp_requests_totalin the query editor and click Run query.