可观测性#

关于可观测性#

Llama 3.1 NemoGuard 8B TopicControl 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-host><opentelemetry-collector-grpc-port> 端口上运行。

export IMG_NAME=nvcr.io/nim/nvidia/llama-3.1-nemoguard-8b-topic-control
export IMG_TAG=1.0.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 -d --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]