Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions exporter/gmond_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/prometheus/node_exporter/exporter/ganglia"
"io"
"net"
"strings"
"regexp"
"time"
)

Expand All @@ -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{
Expand Down Expand Up @@ -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, "_")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are omitting the lowercasing. Is that intended?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me, the regex looks good. The ^ negates the whole character group.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, capitals are legal.
On Aug 15, 2013 1:23 PM, "Matt T. Proud" notifications@github.com wrote:

In exporter/gmond_collector.go:

@@ -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, "_")
    

You are omitting the lowercasing. Is that intended?


Reply to this email directly or view it on GitHubhttps://github.com//pull/3/files#r5787896
.


var labels = map[string]string{
"cluster": cluster.Name,
Expand Down