mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-06-03 05:49:25 +00:00
feat: support inject global labels
Signed-off-by: macro <macrohe@tencent.com>
This commit is contained in:
parent
fae515f739
commit
72d3d21351
|
@ -68,6 +68,11 @@ func (b *Exporter) Listen(e <-chan event.Events) {
|
|||
return
|
||||
}
|
||||
for _, event := range events {
|
||||
if b.Mapper.GlobalLabels != nil {
|
||||
for k, v := range b.Mapper.GlobalLabels {
|
||||
event.Labels()[k] = v
|
||||
}
|
||||
}
|
||||
b.handleEvent(event)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,8 @@ type MetricMapper struct {
|
|||
MappingsCount prometheus.Gauge
|
||||
|
||||
Logger log.Logger
|
||||
|
||||
GlobalLabels map[string]string `yaml:"global_labels"`
|
||||
}
|
||||
|
||||
type SummaryOptions struct {
|
||||
|
@ -85,6 +87,10 @@ func (m *MetricMapper) InitFromYAMLString(fileContents string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
if len(n.GlobalLabels) > 0 {
|
||||
m.GlobalLabels = n.GlobalLabels
|
||||
}
|
||||
|
||||
if len(n.Defaults.HistogramOptions.Buckets) == 0 {
|
||||
n.Defaults.HistogramOptions.Buckets = prometheus.DefBuckets
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue