[fix] name_prefix invalid to prometheus sample
This commit is contained in:
parent
efdbf5c5e6
commit
fe549740ae
|
@ -64,10 +64,6 @@ func NewSamples(fields map[string]interface{}, labels ...map[string]string) []*t
|
||||||
|
|
||||||
func PushSamples(slist *list.SafeList, fields map[string]interface{}, labels ...map[string]string) {
|
func PushSamples(slist *list.SafeList, fields map[string]interface{}, labels ...map[string]string) {
|
||||||
for metric, value := range fields {
|
for metric, value := range fields {
|
||||||
floatValue, err := conv.ToFloat64(value)
|
slist.PushFront(NewSample(metric, value, labels...))
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
slist.PushFront(NewSample(metric, floatValue, labels...))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package prometheus
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"flashcat.cloud/categraf/pkg/conv"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"math"
|
"math"
|
||||||
|
@ -116,11 +115,7 @@ func (p *Parser) handleHistogram(m *dto.Metric, tags map[string]string, metricNa
|
||||||
func (p *Parser) handleSample(m *dto.Metric, tags map[string]string, metricName string, slist *list.SafeList) {
|
func (p *Parser) handleSample(m *dto.Metric, tags map[string]string, metricName string, slist *list.SafeList) {
|
||||||
fields := getNameAndValue(m, metricName)
|
fields := getNameAndValue(m, metricName)
|
||||||
for metric, value := range fields {
|
for metric, value := range fields {
|
||||||
floatValue, err := conv.ToFloat64(value)
|
slist.PushFront(inputs.NewSample(prom.BuildMetric(p.NamePrefix, metric, ""), value, tags))
|
||||||
if err != nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
slist.PushFront(inputs.NewSample(prom.BuildMetric(p.NamePrefix, metric, ""), floatValue, tags))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue