可观测性#

关于可观测性#

NeMo Retriever 文本嵌入 NIM 支持以 OpenTelemetry 兼容格式导出指标和追踪。此外,该微服务及其底层的 NVIDIA Triton Inference Server 通过 Prometheus 端点公开指标。

要收集这些指标和追踪,请将它们导出到正在运行的 OpenTelemetry Collector 实例,然后该实例可以将它们导出到任何 OTLP 兼容的后端。

指标和追踪#

您可以从 NIM 微服务和 Triton Inference Server 实例中收集指标。

以下环境变量与从 NIM 微服务导出 OpenTelemetry 指标和追踪有关。

变量

描述

OTEL_SERVICE_NAME

指定要在导出的指标中使用的服务名称。

OTEL_EXPORTER_OTLP_ENDPOINT

指定 OTLP gRPC 接收器的端点。

OTEL_METRICS_EXPORTER="otlp"

指定以 OTLP 格式将指标导出到指定的 OTEL_EXPORTER_OTLP_ENDPOINT。默认情况下,指标会打印到容器日志。

OTEL_TRACES_EXPORTER="otlp"

指定以 OTLP 格式将追踪导出到指定的 OTEL_EXPORTER_OTLP_ENDPOINT。默认情况下,追踪会打印到容器日志。

NIM 微服务和 Triton Inference Server 也以 Prometheus 格式公开指标。您可以通过 NIM 微服务 API 在 <nim-host>:8000/v1/metrics 访问这些指标,以及通过 Triton 指标端点在 <nim-host>:8002/metrics 访问这些指标。

启用 OpenTelemetry#

以下示例要求 OpenTelemetry Collector gRPC 接收器在端口 <opentelemetry-collector-grpc-port> 上的 <opentelemetry-collector-host> 上运行。

export IMG_NAME=nvcr.io/nim/nvidia/llama-3.2-nv-embedqa-1b-v2
export IMG_TAG=1.3.0

# Choose a container name for bookkeeping
export CONTAINER_NAME=$(basename $IMG_NAME)

# Set the OTEL environment variables to enable metrics exporting
export OTEL_SERVICE_NAME=$CONTAINER_NAME
export OTEL_METRICS_EXPORTER=otlp
export OTEL_TRACES_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_ENDPOINT="http://<opentelemetry-collector-host>:<opentelemetry-collector-grpc-port>"

docker run --runtime=nvidia -it --rm --name=$CONTAINER_NAME \
  ... \
  -e OTEL_SERVICE_NAME \
  -e OTEL_METRICS_EXPORTER \
  -e OTEL_TRACES_EXPORTER \
  -e OTEL_EXPORTER_OTLP_ENDPOINT \
  ... \
  $IMG_NAME:$IMG_TAG

接收和导出遥测数据#

以下 OpenTelemetry Collector 配置启用指标和追踪导出。

定义了两个接收器

  • 一个 OTLP 接收器,用于接收来自 NIM 微服务的指标和追踪数据。

  • 一个 Prometheus 接收器,用于抓取 Triton Inference Server 指标。

定义了三个导出器

  • 一个 Zipkin 导出器,用于导出到正在运行的 Zipkin 实例。

  • 一个 OTLP gRPC 导出器,用于导出到下游收集器或后端,例如 Datadog。

  • 一个 debug 导出器,用于将接收到的数据打印到控制台。此导出器对于测试和开发目的非常有用。

追踪仅由 OTLP 接收器接收,并由 Zipkin 和 debug 导出器导出。指标由 OTLP 和 Prometheus 接收器接收。指标由 OTLP 和 debug 导出器导出。

receivers:
  otlp:
    protocols:
      grpc:
      http:
        cors:
          allowed_origins:
            - "*"
  prometheus:
    config:
      scrape_configs:
        - job_name: nim-triton-metrics
          scrape_interval: 10s
          static_configs:
            - targets: ["<nim-endpoint>:8002"]
exporters:
  # NOTE: Prior to v0.86.0 use `logging` instead of `debug`.
  zipkin:
    endpoint: "<zipkin-endpoint>:<zipkin-port>/api/v2/spans"
  otlp:
    endpoint: "<otlp-metrics-endpoint>:<otlp-metrics-port>"
    tls:
      insecure: true
  debug:
    verbosity: detailed
service:
  pipelines:
    traces:
      receivers: [otlp]
      exporters: [debug, zipkin]
    metrics:
      receivers: [otlp, prometheus]
      exporters: [debug, otlp]