mirror of
https://github.com/prometheus/node_exporter
synced 2024-12-28 00:52:07 +00:00
Escape all illegal chars in metric names.
E.g. right now there are some metrics with dashes in their names, which cannot be queried through the UI.
This commit is contained in:
parent
9ea37d8b44
commit
4fcd1a9b38
@ -8,7 +8,7 @@ import (
|
||||
"github.com/prometheus/node_exporter/exporter/ganglia"
|
||||
"io"
|
||||
"net"
|
||||
"strings"
|
||||
"regexp"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -25,6 +25,8 @@ type gmondCollector struct {
|
||||
registry prometheus.Registry
|
||||
}
|
||||
|
||||
var illegalCharsRE = regexp.MustCompile(`[^a-zA-Z0-9_]`)
|
||||
|
||||
// Takes a config struct and prometheus registry and returns a new Collector scraping ganglia.
|
||||
func NewGmondCollector(config config, registry prometheus.Registry) (collector gmondCollector, err error) {
|
||||
collector = gmondCollector{
|
||||
@ -84,7 +86,7 @@ func (c *gmondCollector) Update() (updates int, err error) {
|
||||
for _, host := range cluster.Hosts {
|
||||
|
||||
for _, metric := range host.Metrics {
|
||||
name := strings.Replace(strings.ToLower(metric.Name), ".", "_", -1)
|
||||
name := illegalCharsRE.ReplaceAllString(metric.Name, "_")
|
||||
|
||||
var labels = map[string]string{
|
||||
"cluster": cluster.Name,
|
||||
|
Loading…
Reference in New Issue
Block a user