Tags: jobop/prometheus
Tags
Provide extended action capabilities for relabel, allowing developers… … to customize relabel actions when integrating promtherus. Once developers want to relabel some labels,bug the buildin actions can not meet their needs,they can register their own action function to handle it. For example, we want to add prefix to all label values,we can register our action function like this testPreFixAction := relabel.Action("testprefixaction") relabel.Predicates[testPreFixAction] = func(cfg *Config) bool { return true } relabel.CustomerActions[testPreFixAction] = func(lb *labels.Builder, cfg *Config, val string) (bool, bool) { prefix := cfg.Ext lb.Range(func(l labels.Label) { lb.Set(l.Name, prefix+l.Value) }) return true, true } then we can config the relabel config like this metric_relabel_configs: - action: testprefixaction ext: 'test-' then all label values will be added a prefix 'test-' Signed-off-by: jobop <zw19860913@163.com>