度量

Observing Dapr metrics in Kubernetes

Dapr 公开了一个 Prometheus 指标终结点,您可以扫描该终结点,以更深入地了解 Dapr 的行为方式,针对特定条件设置警报。

Configuration (配置)

默认情况下,指标终结点处于启用状态,您可以通过命令行参数 --enable-metrics=false 传递给 Dapr 系统进程来禁用它。

默认指标端口为 9090。 This can be overridden by passing the command line argument --metrics-port to Daprd. Additionally, the metrics exporter can be disabled for a specific application by setting the dapr.io/enable-metrics: "false" annotation to your application deployment. With the metrics exporter disabled, daprd will not open the metrics listening port.

  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: nodeapp
  5. labels:
  6. app: node
  7. spec:
  8. replicas: 1
  9. selector:
  10. matchLabels:
  11. app: node
  12. template:
  13. metadata:
  14. labels:
  15. app: node
  16. annotations:
  17. dapr.io/enabled: "true"
  18. dapr.io/app-id: "nodeapp"
  19. dapr.io/app-port: "3000"
  20. dapr.io/enable-metrics: "true"
  21. dapr.io/metrics-port: "9090"
  22. spec:
  23. containers:
  24. - name: node
  25. image: dapriosamples/hello-k8s-node:latest
  26. ports:
  27. - containerPort: 3000
  28. imagePullPolicy: Always

To disable the metrics collection in the Dapr side cars running in a specific namespace, you can use the metric spec configuration and set enabled: false to disable the metrics in the Dapr runtime.

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Configuration
  3. metadata:
  4. name: tracing
  5. namespace: default
  6. spec:
  7. tracing:
  8. samplingRate: "1"
  9. metric:
  10. enabled: true

度量

默认情况下,每个 Dapr 系统进程都会发出 Go 运行时/进程指标,并有自己的指标:

参考资料