OpenTelemetry Metrics
Send the metrics your services already produce with OpenTelemetry (request counts, latencies, queue depths, resource usage) to Moesif, and chart them next to your API analytics. Moesif accepts metrics over OTLP/HTTP, stores them for each Moesif application, and lets you explore them in the Metrics Explorer, save charts to workspaces, and add them to dashboards.
This page covers metrics. To send traces and logs, see the OpenTelemetry integration.
How it works
- Your OpenTelemetry SDK or OpenTelemetry Collector exports metrics over OTLP/HTTP to
https://api.moesif.net/v1/metrics, with your Moesif Application ID in a header. - Moesif checks the Application ID and stores the metrics for that application only. Metrics from one application are never visible from another, and nothing in the request can change which application they belong to.
- You open the Metrics Explorer in that application to chart them.
Before you begin
You need:
- A Moesif account and the Application ID of the application that should hold the metrics. To find it, select the account icon, then Installation or API Keys, and copy the Collector Application ID.
- An application instrumented with an OpenTelemetry SDK, or an OpenTelemetry Collector, that can export metrics over OTLP/HTTP.
Two settings matter more than any others:
- Cumulative temporality
- Moesif stores cumulative metrics only. Metrics exported with delta temporality are not stored, and other metrics in the same export can be lost with them. Some SDKs default to delta; set the temporality preference to cumulative as shown below.
- OTLP over HTTP, not gRPC
- Moesif accepts OTLP/HTTP with protobuf (
application/x-protobuf) or JSON (application/json) bodies, optionally gzip-compressed. OTLP/gRPC is not accepted. In the OpenTelemetry Collector, use theotlphttpexporter, nototlp(which is gRPC).
Send metrics to Moesif
Option 1: OpenTelemetry SDK (environment variables)
Most OpenTelemetry SDKs read these standard environment variables:
export OTEL_EXPORTER_OTLP_METRICS_ENDPOINT="https://api.moesif.net/v1/metrics"
export OTEL_EXPORTER_OTLP_METRICS_HEADERS="X-Moesif-Application-Id=<your Moesif Application ID>"
export OTEL_EXPORTER_OTLP_METRICS_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE="cumulative"
export OTEL_METRIC_EXPORT_INTERVAL="60000" # milliseconds; see "Limits" below
export OTEL_SERVICE_NAME="checkout-api" # shown as the job label in Moesif
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT is the full URL, including /v1/metrics.
Option 2: OpenTelemetry Collector
Add an otlphttp exporter for Moesif and use it in your metrics pipeline:
exporters:
otlphttp/moesif:
metrics_endpoint: https://api.moesif.net/v1/metrics
headers:
X-Moesif-Application-Id: '<your Moesif Application ID>'
compression: gzip
service:
pipelines:
metrics:
receivers: [otlp]
processors: [batch]
exporters: [otlphttp/moesif]
If some of your sources produce delta metrics, convert them before they reach Moesif with the
Collector’s deltatocumulative processor (OpenTelemetry Collector Contrib):
processors:
deltatocumulative: {}
service:
pipelines:
metrics:
receivers: [otlp]
processors: [deltatocumulative, batch]
exporters: [otlphttp/moesif]
Check that it works
A successful export returns HTTP 200. If Moesif had to drop some data points, the response is still
200 but carries an OTLP partial_success with the number of rejected data points and the reason
(see Limits). Most SDKs and the Collector log that message.
Then open your application in Moesif and go to Create new > OpenTelemetry > Metrics Explorer. New metrics appear in the metric picker within a few minutes.
How your metrics are stored
Moesif follows the OpenTelemetry-to-Prometheus compatibility rules, so metric names and labels can differ from what you exported.
Metric types
| OpenTelemetry instrument | Stored as | Name in Moesif (example) |
|---|---|---|
| Counter (monotonic Sum) | counter | http_requests_total (_total added) |
| UpDownCounter (non-monotonic Sum) | gauge | queue_items |
| Gauge | gauge | cpu_temperature |
| Histogram | _bucket, _sum and _count series |
http_duration_seconds_bucket, ..._sum, ..._count |
| Exponential histogram | one histogram series | payload_bytes |
| Summary | one series per quantile, plus _sum and _count |
db_query_seconds with a quantile label |
Names
- Counters get
_totaladded. - The unit is added to the name: a histogram
http.durationwith unitsbecomeshttp_duration_seconds. - Characters that are not letters, digits or
_(for example.) become_.
If you search for the exact name you exported and do not find it, look for the converted name.
Labels and resource attributes
- Data point attributes become labels, for example
routeorstatus_code. service.namebecomes thejoblabel (as<service.namespace>/<service.name>whenservice.namespaceis set), andservice.instance.idbecomesinstance.- Other resource attributes (for example
deployment.environmentorhost.nameset on the resource) are not added to each metric. They are kept on a separatetarget_infoseries. If you want to filter or split a metric by one of them, also set it as a data point attribute.
Explore metrics in Moesif
Open your application and go to Create new > OpenTelemetry > Metrics Explorer. From the Trace Explorer or Log Explorer you can also switch to it with Transition to.
Build a query
- Metric
- Pick a metric. A badge shows its type. For histograms and summaries, the
_countand_sumseries are listed too and behave like counters. - Calculate
- How each series is turned into a value over time. The choices depend on the type:
Type Functions Default Counter Rate (/s), Increase Rate (/s) Gauge Average, Latest, Max, Min, Change per second Average UpDownCounter Average, Latest, Max, Min, Change per second Latest Histogram, exponential histogram p50, p75, p90, p95, p99, Average p95 Summary the quantiles you exported (for example p50, p90, p99), Average the quantile closest to p95 Looking back sets the window each value is calculated over: Auto, 5 min, 15 min or 1 hour. Auto adapts to the chart’s time range. A longer window gives a smoother line.
- Aggregate, then split by
- Combine series with Sum, Average, Max, Min or Count of series, or keep every series with
None (every series). Gauges default to Average, other types to Sum. Optionally split the
result by up to three labels, for example
route. Histograms and summaries have no aggregation choice: the percentile or average already combines their series. A summary’s exported quantiles cannot be split by label. - Where
- Filter on label values: contains, does not contain, starts with, ends with, is one of, is not one of, exists, does not exist.
Several queries and formulas
Add up to four queries to one chart, and up to two formulas that combine them, for example
a / b * 100 for an error percentage. Each query or formula can use its own Y-axis.
A chart shows up to eight series. When a query returns more, the chart shows the eight largest and says so; aggregate or filter to see the rest.
PromQL
If you know PromQL, you can write the query directly instead of using the builder. Every query must name a metric, and it only ever reads your application’s own metrics.
Time range, gaps and display
- Pick a time range or a rolling window such as Last 1 hour, up to 90 days. The chart refreshes as new data arrives.
- Where no data came in, the chart shows a gap instead of joining the points.
- A query that returns a single series can be shown as a number.
Save and share
Save a chart to a workspace, and add it to a dashboard, as with other Moesif views.
Limits
To keep the service fast and fair for everyone, each application has these limits. Data over a limit is dropped, and the export response says how many data points were rejected and why.
| Limit | Default | What happens over it | Reason in partial_success |
|---|---|---|---|
| Active series per application | 2,000 | Data points that would create new series are dropped; existing series keep working | would create new series beyond this application's active series limit |
| Send rate per application | twice the active series limit in data points per minute (4,000 at the default limit): one data point per series per minute, with 2x headroom | That request is dropped, and so are later ones until the minute ends | exceeded this application's send rate (one data point per series per minute) |
| Per request | 100,000 data points, 200,000 series (a histogram counts one series per bucket, plus _sum and _count), 64 attributes on one data point |
The whole request is dropped | exceeded the per-request limits |
| Size of one metric | about 900 KB encoded, for one metric in one request | That metric’s data points are dropped | exceeded the maximum payload size |
- An active series is one combination of metric name and label values that has received data recently. Labels with many distinct values (user IDs, request IDs, full URLs) create many series; avoid them as attributes.
- An export interval of 60 seconds fits the send-rate limit. Exporting every 15 seconds sends four data points per series per minute, so it hits the limit once you have more than half as many series as your series limit (1,000 series at the default).
- If you need a higher series limit, contact Moesif support.
If Moesif answers HTTP 503 (“Metrics limits are loading, retry shortly”), retry; the SDKs and the Collector retry automatically.
Data retention and late data
| Full-resolution data | 90 days |
| Downsampled data (5-minute and 1-hour) | 1 year |
Charts over long ranges read the downsampled data automatically.
Data that arrives late is stored if it is less than one hour older than the newest data Moesif already holds for your application. Older data points are dropped. If an exporter is offline for more than an hour, the data it buffered from more than an hour before it reconnects is not stored.
Limitations
- Metrics only on this endpoint. Traces and logs have their own endpoints; see the OpenTelemetry integration.
- Cumulative temporality only. Delta metrics are not stored.
- OTLP/HTTP only. OTLP/gRPC, Prometheus remote write and scraping of your endpoints are not supported; metrics are pushed to Moesif.
- One application per export. Each export goes to the application named by its Application ID; queries cannot combine metrics from several applications.
- Resource attributes other than
service.nameandservice.instance.idare not labels on each metric (see Labels and resource attributes).
Troubleshooting
- No metrics in the picker
- Check that the exporter uses
https://api.moesif.net/v1/metricsover OTLP/HTTP (not gRPC), that theX-Moesif-Application-Idheader holds the right Application ID, and that you opened the same application in Moesif. Check the exporter’s own logs for errors. - HTTP 401
- The Application ID is missing or not valid. Copy the Collector Application ID again (account icon, then Installation or API Keys).
- HTTP 415
- The body type is not supported. Use
application/x-protobuforapplication/json. - HTTP 400
- The body could not be read as an OTLP metrics request. Check that the
Content-Typematches the body (protobuf or JSON). - HTTP 202, 402, 403 or 410
- Your account or application cannot store data right now: over its plan’s quota (202), payment needed (402), data collection paused (403), or the application was deleted (410). Metrics sent with these responses are not stored. Check your account’s billing and plan in Moesif.
- Some metrics never appear
- They may use delta temporality. Set
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=cumulativeor add thedeltatocumulativeprocessor. Also look for the converted name (see Names). - A label I set is missing
- It was probably a resource attribute. Set it as a data point attribute instead.
- Export responses report rejected data points
- The
partial_successmessage names the limit. See Limits. - Gaps after an outage
- Data more than one hour older than your newest data is not stored. See Data retention and late data.