thanos-io/thanos · error

unsupported metric type

Error message

unsupported metric type

What it means

FromMetrics switches over pmetric.MetricType and every known case (Gauge, Sum, Histogram, ExponentialHistogram, Summary) is handled; hitting the default branch means the payload carries a metric type this translator does not recognize — either a newer OTLP metric type than this Prometheus build supports, or a corrupted/zero-value Metric.

Solutions

  1. Upgrade Prometheus to a version whose pmetric library supports the new metric type
  2. Check the OTLP producer's version and disable the unsupported metric type there
  3. Verify the OTLP payload is not corrupted (re-encode/re-send)
  4. Confirm no manually built pmetric.Metric is left with an unset type

Example fix

// before
// prometheus built against older pmetrics, producer sends new type
// after
// go get go.opentelemetry.io/collector/pdata@latest && upgrade prometheus
// or drop the new type on the collector:
// transform processor: delete_metric where metric.type == "new_type"
Defensive patterns

Strategy: validation

Validate before calling

// pre-check metric types against what this Prometheus supports:
supported := map[pmetric.MetricType]bool{
    pmetric.MetricTypeGauge: true, pmetric.MetricTypeSum: true,
    pmetric.MetricTypeHistogram: true, pmetric.MetricTypeExponentialHistogram: true,
    pmetric.MetricTypeSummary: true,
}
for i := 0; i < metrics.Len(); i++ {
    if !supported[metrics.At(i).Type()] { log.Warn("unsupported metric type, dropping", metrics.At(i).Name()) }
}

Type guard

func isSupportedMetricType(m pmetric.Metric) bool {
    switch m.Type() {
    case pmetric.MetricTypeGauge, pmetric.MetricTypeSum, pmetric.MetricTypeHistogram,
        pmetric.MetricTypeExponentialHistogram, pmetric.MetricTypeSummary:
        return true
    }
    return false
}

Try / catch

errs := translator.FromMetrics(ctx, metrics, ...)
if errs != nil {
    for _, err := range errs.Errors() {
        if strings.Contains(err.Error(), "unsupported metric type") {
            log.Warn("unsupported metric type; upgrade Prometheus or drop at collector", "err", err)
        }
    }
}

Prevention

When it happens

Trigger: An OTLP export contains a Metric whose Type() is a newer enum value (e.g. a future pmetric type) not compiled into this Prometheus version, or a nil/unset metric in the slice.

Common situations: Version skew: newer OpenTelemetry collector or SDK exporting metric types the receiving Prometheus predates; corrupted OTLP payloads; manually constructed pmetric slices with unset type.

Related errors


AI-assisted analysis of thanos-io/thanos@35b8b99117 (2026-09-07). Data as JSON: /api/errors/86de8a4a14d17379. Report an issue: GitHub.

Appendix: source

Thrown at pkg/receive/otlptranslator/metrics_to_prw.go:170

						errs.Add(err)
						if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
							return
						}
					}
				case pmetric.MetricTypeSummary:
					dataPoints := metric.Summary().DataPoints()
					if dataPoints.Len() == 0 {
						errs.Add(fmt.Errorf("empty data points. %s is dropped", metric.Name()))
						break
					}
					if err := c.addSummaryDataPoints(ctx, dataPoints, resource, settings, promName); err != nil {
						errs.Add(err)
						if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
							return
						}
					}
				default:
					errs.Add(errors.New("unsupported metric type"))
				}
			}
		}
		addResourceTargetInfo(resource, settings, mostRecentTimestamp, c)
	}

	return annots, errs
}

func isSameMetric(ts *prompb.TimeSeries, lbls []labelpb.ZLabel) bool {
	if len(ts.Labels) != len(lbls) {
		return false
	}
	for i, l := range ts.Labels {
		if l.Name != ts.Labels[i].Name || l.Value != ts.Labels[i].Value {
			return false
		}
	}

View on GitHub (pinned to 35b8b99117)