mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-21 15:45:01 +00:00
lib/promscrape: add a comment explaining the logic behind adding exported_
perfix to metric names
This is a follow-up for 7b87fac8e7
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3557
Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3406
This commit is contained in:
parent
3c1e455805
commit
ac695f36bb
1 changed files with 18 additions and 8 deletions
|
@ -904,14 +904,24 @@ func (sw *scrapeWork) addAutoTimeseries(wc *writeRequestCtx, name string, value
|
||||||
|
|
||||||
func (sw *scrapeWork) addRowToTimeseries(wc *writeRequestCtx, r *parser.Row, timestamp int64, needRelabel bool) {
|
func (sw *scrapeWork) addRowToTimeseries(wc *writeRequestCtx, r *parser.Row, timestamp int64, needRelabel bool) {
|
||||||
metric := r.Metric
|
metric := r.Metric
|
||||||
if needRelabel && isAutoMetric(metric) {
|
|
||||||
if !sw.Config.HonorLabels && len(r.Tags) == 0 {
|
// Add `exported_` prefix to metrics, which clash with the automatically generated
|
||||||
bb := bbPool.Get()
|
// metric names only if the following conditions are met:
|
||||||
bb.B = append(bb.B, "exported_"...)
|
//
|
||||||
bb.B = append(bb.B, metric...)
|
// - The `honor_labels` option isn't set to true in the scrape_config.
|
||||||
metric = bytesutil.InternBytes(bb.B)
|
// If `honor_labels: true`, then the scraped metric name must remain unchanged
|
||||||
bbPool.Put(bb)
|
// because the user explicitly asked about it in the config.
|
||||||
}
|
// - The metric has no labels (tags). If it has labels, then the metric value
|
||||||
|
// will be written into a separate time series comparing to automatically generated time series.
|
||||||
|
//
|
||||||
|
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3557
|
||||||
|
// and https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3406
|
||||||
|
if needRelabel && !sw.Config.HonorLabels && len(r.Tags) == 0 && isAutoMetric(metric) {
|
||||||
|
bb := bbPool.Get()
|
||||||
|
bb.B = append(bb.B, "exported_"...)
|
||||||
|
bb.B = append(bb.B, metric...)
|
||||||
|
metric = bytesutil.InternBytes(bb.B)
|
||||||
|
bbPool.Put(bb)
|
||||||
}
|
}
|
||||||
labelsLen := len(wc.labels)
|
labelsLen := len(wc.labels)
|
||||||
targetLabels := sw.Config.Labels.GetLabels()
|
targetLabels := sw.Config.Labels.GetLabels()
|
||||||
|
|
Loading…
Reference in a new issue