没有监控的 Milvus 集群就是黑箱。本节介绍 Milvus 的监控指标体系、日志管理和告警配置,帮助你在生产环境中保持系统的可观测性。
Milvus 内置了 Prometheus 格式的指标导出,各组件默认暴露 /metrics 端口。

| 指标 | 含义 | 告警阈值建议 |
|---|---|---|
milvus_proxy_req_count |
Proxy 请求总数 | - |
milvus_proxy_req_latency |
请求延迟分布 | P99 > 500ms |
milvus_querynode_search_latency |
搜索延迟 | P99 > 200ms |
milvus_querynode_sq_latency |
单条查询延迟 | P99 > 100ms |
milvus_datanode_flush_rows |
刷盘行数/秒 | 持续为 0 |
milvus_indexnode_build_index_latency |
索引构建耗时 | > 30 分钟 |
milvus_querynode_collection_num |
加载的 Collection 数 | 接近上限 |
process_resident_memory_bytes |
进程内存 | > 80% limit |
process_cpu_seconds_total |
CPU 使用 | > 80% |
# 直接获取 Prometheus 指标 curl http://localhost:9091/metrics # Kubernetes 环境中 kubectl port-forward svc/milvus-proxy 9091:9091 -n milvus curl http://localhost:9091/metrics | grep milvus_proxy
Milvus 官方提供了 Grafana Dashboard 模板,直接导入即可:
# 下载 Dashboard JSON wget https://raw.githubusercontent.com/milvus-io/milvus/master/deployments/monitor/grafana/milvus-dashboard.json # 在 Grafana UI 中导入 JSON 文件
推荐的关键面板:
Milvus 支持以下日志级别:debug、info、warn、error、fatal。
默认 level 是 info。生产环境一般用 info 或 warn,排查问题时临时改为 debug。
log: level: info file: maxSize: 300 # 单个日志文件最大 MB maxBackups: 20 # 保留的历史日志文件数 maxAge: 10 # 历史日志保留天数 format: text # text 或 json
关键日志信息:
Kubernetes 环境建议用 Filebeat 或 Fluentd 收集日志到 Elasticsearch/Loki:
# filebeat 配置片段 filebeat.inputs: - type: container paths: - /var/log/containers/milvus-*.log processors: - add_kubernetes_metadata: host: ${NODE_NAME} matchers: - logs_path: logs_path: "/var/log/containers/"
groups: - name: milvus_alerts rules: - alert: MilvusHighSearchLatency expr: histogram_quantile(0.99, sum(rate(milvus_proxy_req_latency_bucket[5m])) by (le)) > 0.5 for: 5m labels: severity: warning annotations: summary: "Milvus 搜索 P99 延迟超过 500ms" - alert: MilvusQueryNodeHighMemory expr: container_memory_working_set_bytes{pod=~"milvus-querynode.*"} / container_spec_memory_limit_bytes{pod=~"milvus-querynode.*"} > 0.85 for: 3m labels: severity: critical annotations: summary: "QueryNode 内存使用超过 85%" - alert: MilvusIndexBuildBacklog expr: milvus_datacoord_index_task_count - milvus_datacoord_index_task_completed_count > 10 for: 10m labels: severity: warning annotations: summary: "索引构建积压超过 10 个任务"
推荐使用 AlertManager 配置通知渠道(钉钉、企业微信、Slack 等):
alertmanager: alertmanagers: - static_configs: - targets: ['alertmanager:9093'] receivers: - name: 'dingtalk' webhook_configs: - url: 'https://oapi.dingtalk.com/robot/send?access_token=YOUR_TOKEN'
Milvus 各组件暴露了健康检查端点:
# Proxy 健康检查 curl http://localhost:9091/healthz # 返回 200 OK 表示正常
Kubernetes 的 liveness 和 readiness probe 配置:
livenessProbe: httpGet: path: /healthz port: 9091 initialDelaySeconds: 30 periodSeconds: 10 readinessProbe: httpGet: path: /healthz port: 9091 initialDelaySeconds: 10 periodSeconds: 5
Attu 是 Milvus 的官方 Web 管理界面,可以直观地查看:
docker run -d --name attu \ -p 8000:3000 \ -e MILVUS_URL=host.docker.internal:19530 \ zilliz/attu:v2.4
访问 `「相关地址请参见官方文档」 即可使用。
Birdwatcher 是 Milvus 的命令行诊断工具,可以直接查看 etcd 中的元数据:
# 安装 go install github.com/milvus-io/birdwatcher@latest # 使用 birdwatcher --root-path=milvus --etcdAddr=127.0.0.1:2379 # 常用命令 show segment -collection 445713950057878364 # 查看 Collection 的 Segment show channel-watch # 查看消息队列消费状态
Milvus 的监控基于 Prometheus 指标,核心关注搜索延迟、写入吞吐和内存水位。日志按组件区分,推荐用 JSON 格式方便日志平台解析。告警规则至少覆盖高延迟、高内存和索引积压三个场景。Attu 和 Birdwatcher 是日常诊断的常用工具。