mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-06-03 05:49:25 +00:00
allow partial overrides of summary_options in mappings
Signed-off-by: glightfoot <glightfoot@rsglab.com>
This commit is contained in:
parent
38fdc17c42
commit
0ea986a974
|
@ -422,7 +422,7 @@ By setting this to `true`, `glob` match type will not honor the occurance of rul
|
|||
|
||||
Setting `buckets` or `quantiles` in the defaults is deprecated in favor of `histogram_options` and `summary_options`, which will override the deprecated values.
|
||||
|
||||
NOTE: If `summary_options` is present in a mapping config, it will override all of the `summary_options` set in the `defaults` section.
|
||||
If `summary_options` is present in a mapping config, it will only override the fields set in the mapping. Unset fields in the mapping will take the values from the defaults.
|
||||
|
||||
```yaml
|
||||
defaults:
|
||||
|
|
|
@ -22,8 +22,9 @@ import (
|
|||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/common/log"
|
||||
"github.com/prometheus/statsd_exporter/pkg/mapper/fsm"
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/prometheus/statsd_exporter/pkg/mapper/fsm"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -100,7 +101,7 @@ func (m *MetricMapper) GetDefaultHistogramOptions() HistogramOptions {
|
|||
r.Buckets = prometheus.DefBuckets
|
||||
} else {
|
||||
r = m.Defaults.HistogramOptions.Clone()
|
||||
if m.Defaults.HistogramOptions != nil && len(m.Defaults.HistogramOptions.Buckets) == 0 {
|
||||
if len(m.Defaults.HistogramOptions.Buckets) == 0 {
|
||||
r.Buckets = prometheus.DefBuckets
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +116,7 @@ func (m *MetricMapper) GetDefaultSummaryOptions() SummaryOptions {
|
|||
r.Quantiles = defaultQuantiles
|
||||
} else {
|
||||
r = m.Defaults.SummaryOptions.Clone()
|
||||
if m.Defaults.SummaryOptions != nil && len(m.Defaults.SummaryOptions.Quantiles) == 0 {
|
||||
if len(m.Defaults.SummaryOptions.Quantiles) == 0 {
|
||||
r.Quantiles = defaultQuantiles
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import (
|
|||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/common/model"
|
||||
|
||||
"github.com/prometheus/statsd_exporter/pkg/clock"
|
||||
"github.com/prometheus/statsd_exporter/pkg/mapper"
|
||||
"github.com/prometheus/statsd_exporter/pkg/metrics"
|
||||
|
@ -300,11 +301,19 @@ func (r *Registry) GetSummary(metricName string, labels prometheus.Labels, help
|
|||
metricsCount.WithLabelValues("summary").Inc()
|
||||
summaryOptions := r.Mapper.GetDefaultSummaryOptions()
|
||||
if mapping != nil && mapping.SummaryOptions != nil {
|
||||
summaryOptions = *mapping.SummaryOptions
|
||||
}
|
||||
|
||||
if mapping != nil && mapping.SummaryOptions != nil && len(mapping.SummaryOptions.Quantiles) > 0 {
|
||||
summaryOptions.Quantiles = mapping.SummaryOptions.Quantiles
|
||||
tmp := mapping.SummaryOptions.Clone()
|
||||
if len(tmp.Quantiles) > 0 {
|
||||
summaryOptions.Quantiles = tmp.Quantiles
|
||||
}
|
||||
if tmp.BufCap != 0 {
|
||||
summaryOptions.BufCap = tmp.BufCap
|
||||
}
|
||||
if tmp.AgeBuckets != 0 {
|
||||
summaryOptions.AgeBuckets = tmp.AgeBuckets
|
||||
}
|
||||
if tmp.MaxAge != 0 {
|
||||
summaryOptions.MaxAge = tmp.MaxAge
|
||||
}
|
||||
}
|
||||
|
||||
objectives := make(map[float64]float64)
|
||||
|
|
Loading…
Reference in a new issue