Skip to content

Commit

Permalink
fix: add grouping key to avoid data override
Browse files Browse the repository at this point in the history
  • Loading branch information
WangYihang committed May 7, 2024
1 parent cd6d6d0 commit b586b5a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func prometheusPusher(url, job string, statusChan <-chan Status, wg *sync.WaitGr
runner.Runner.IP,
)
registry := NewRegistryWithLabels(map[string]string{
"instance": instance,
"gojob_version": version.Version,
"gojob_runner_ip": runner.Runner.IP,
"gojob_runner_country": runner.Runner.Country,
Expand All @@ -100,7 +99,9 @@ func prometheusPusher(url, job string, statusChan <-chan Status, wg *sync.WaitGr
numFailed.Set(float64(status.NumFailed))
numSucceed.Set(float64(status.NumSucceed))
numFinished.Set(float64(status.NumFinished))
if err := push.New(url, job).Gatherer(registry).Push(); err != nil {
if err := push.New(url, job).Grouping(
"instance", instance,
).Gatherer(registry).Push(); err != nil {
slog.Error("error occurred while pushing to prometheus", slog.String("error", err.Error()))
}
}
Expand Down

0 comments on commit b586b5a

Please sign in to comment.