Skip to content
This repository has been archived by the owner on Jul 9, 2022. It is now read-only.

Commit

Permalink
Use coded name for exporter names
Browse files Browse the repository at this point in the history
  • Loading branch information
arbulu89 committed Feb 23, 2022
1 parent f3a890b commit 0a1e5eb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
8 changes: 7 additions & 1 deletion web/services/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,13 @@ func (s *hostsService) GetExportersState(hostname string) (map[string]bool, erro
}

for _, r := range resultVector {
jobsState[string(r.Metric["job"])] = (int(r.Value) == 1)
var name string
if _, ok := r.Metric["exporter_name"]; ok {
name = string(r.Metric["exporter_name"])
} else {
name = string(r.Metric["job"])
}
jobsState[name] = (int(r.Value) == 1)
}

return jobsState, nil
Expand Down
6 changes: 5 additions & 1 deletion web/services/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ import (
prometheusModel "github.com/prometheus/common/model"
)

const nodeExporterPort = 9100
const (
nodeExporterPort = 9100
nodeExporterName = "Node Exporter"
)

//go:generate mockery --name=PrometheusService --inpackage --filename=prometheus_mock.go
type PrometheusService interface {
Expand Down Expand Up @@ -46,6 +49,7 @@ func (p *prometheusService) GetHttpSDTargets() (models.PrometheusTargetsList, er
Labels: map[string]string{
"agentID": host.AgentID,
"hostname": host.Name,
"exporter_name": nodeExporterName,
},
}
targetsList = append(targetsList, targets)
Expand Down

0 comments on commit 0a1e5eb

Please sign in to comment.