You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

非FedRAMP用户用gRPC发OTLP指标至New Relic遭丢弃,求排查

问题描述

作为New Relic新用户,我尝试用Python代码向New Relic发送OTLP指标,但遇到了问题。

初始化代码:

otlp_metric_reader = PeriodicExportingMetricReader(
    OTLPMetricExporter(
        endpoint="https://otlp.eu01.nr-data.net:4317",
        headers={"api-key": "..."},
    )
)
provider = MeterProvider(metric_readers=[otlp_metric_reader])
metrics.set_meter_provider(provider)

meter = metrics.get_meter("my_service")

指标配置:

my_histogram = meter.create_histogram(
    "my_histogram",
    unit="ms",
    description="...",
)

上报逻辑:

start_time = perf_counter_ns()
try:
    await foo()
finally:
    my_histogram.record((perf_counter_ns() - start_time) / 1_000_000, {"foo": "bar"})

执行错误排查查询:

SELECT message, metricName, name 
FROM NrIntegrationError 
WHERE newRelicFeature = 'Metrics' 
SINCE 5 HOURS AGO 
LIMIT 100

得到错误提示:

One or more OTLP metric data point(s) were dropped because New Relic does not fully support cumulative metrics over GRPC for FedRAMP customers. Histograms will be dropped and Sums will be ingested as Gauges. Try sending over HTTP instead.

我使用欧洲OTLP端点,用了gRPC,但并非FedRAMP用户。请问这是New Relic的异常问题,还是我操作有误?


解决建议
  • 切换到HTTP协议上报
    New Relic的gRPC端点对累积型指标(比如直方图)的支持存在限制,即使是非FedRAMP用户也可能触发这个误判提示。切换到HTTP exporter即可解决,修改代码如下:

    from opentelemetry.exporter.otlp.proto.http.metric_exporter import OTLPMetricExporter
    
    otlp_metric_reader = PeriodicExportingMetricReader(
        OTLPMetricExporter(
            endpoint="https://otlp.eu01.nr-data.net/v1/metrics",
            headers={"api-key": "..."},
        )
    )
    

    注意HTTP端点需添加/v1/metrics后缀,无需指定端口(默认443)。

  • 调整指标聚合模式
    直方图默认是累积型(cumulative),可以尝试改为增量型(delta),部分场景下能兼容gRPC端点:

    from opentelemetry.sdk.metrics import AggregationType
    
    my_histogram = meter.create_histogram(
        "my_histogram",
        unit="ms",
        description="...",
        aggregation_type=AggregationType.DELTA
    )
    

    需确保使用的OpenTelemetry版本支持该参数。

  • 验证账号与端点匹配
    确认API密钥属于欧洲区账号,避免跨区域密钥导致的隐性错误。

  • 关于误判问题
    你收到针对FedRAMP用户的提示属于New Relic的错误提示逻辑问题,切换HTTP协议后指标应该能正常上报,该误判可反馈给New Relic支持团队。

内容的提问来源于stack exchange,提问作者Victor

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 21:37:47