三亩地 三亩地SAN MU DI · CODE DIARY
ARTICLE DETAIL

日记详情

真实记录编程学习的某一天,欢迎挑你感兴趣的翻一翻。

Go语言Prometheus Operator:自定义监控

Go语言Prometheus Operator:自定义监控

Go语言Prometheus Operator:自定义监控

1. Operator实现

package operator import ( "github.com/prometheus/client_golang/prometheus" ) var ( CustomMetric = promauto.NewGauge(prometheus.GaugeOpts{ Name: "custom_metric", Help: "A custom metric", }) ) func RecordCustomMetric(value float64) { CustomMetric.Set(value) }

2. 总结

Prometheus Operator简化了K8s环境下的监控配置,Go应用可以方便地集成自定义指标。

← 返回列表