自定义指标
只需实现 Collector 接口并完成注册即可。
type Collector interface {
Update() ([]*Data, error)
}
创建
在 core/metrics/your-new-metric 目录创建 Collector 接口的结构体:
type exampleMetric struct{}
注册
func init() {
tracing.RegisterEventTracing("example", newExample)
}
func newExample() (*tracing.EventTracingAttr, error) {
return &tracing.EventTracingAttr{
TracingData: &exampleMetric{},
Flag: tracing.FlagMetric, // 标记为 Metric 类型
}, nil
}
实现 Update
func (c *exampleMetric) Update() ([]*metric.Data, error) {
// do something
return []*metric.Data{
metric.NewGaugeData("example", value, "description of example", nil),
}, nil
}
框架提供的丰富底层接口,包括 eBPF, Procfs, Cgroups, Storage, Utils, Pods 等。
页面反馈
此页面对您有帮助吗?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.