可观测性#
关于可观测性#
NVIDIA NemoGuard JailbreakDetect NIM 支持以 OpenTelemetry 兼容的格式导出指标和追踪。此外,该微服务及其底层的 NVIDIA Triton Inference Server 通过 Prometheus 端点暴露指标。
为了收集这些指标和追踪,请将它们导出到一个正在运行的 OpenTelemetry Collector 实例,然后该实例可以将它们导出到任何兼容 OTLP 的后端。
指标和追踪#
您可以从 NIM 微服务和 Triton Inference Server 实例收集指标。
以下环境变量与从 NIM 微服务导出 OpenTelemetry 指标和追踪有关。
变量 |
描述 |
---|---|
|
指定在导出的指标中使用的服务名称。 |
|
指定 OTLP gRPC 接收器的端点。 |
|
指定以 OTLP 格式将指标导出到指定的 |
|
指定以 OTLP 格式将追踪导出到指定的 |
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/nemoguard-jailbreak-detect
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]