Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
add collect job label to charts (#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyam8 authored Sep 8, 2022
1 parent cd2cff4 commit d248e30
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions agent/module/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ func (j *Job) createChart(chart *Chart) {
if chart.ignore {
return
}
j.addJobNameLabel(chart)

if chart.Priority == 0 {
chart.Priority = j.priority
Expand Down Expand Up @@ -483,6 +484,22 @@ func (j *Job) updateChart(chart *Chart, collected map[string]int64, sinceLastRun
return chart.updated
}

func (j Job) addJobNameLabel(chart *Chart) {
const lblKey = "_collect_job"
var ok bool
for _, lbl := range chart.Labels {
if ok = lbl.Key == lblKey; ok {
break
}
}
if !ok {
chart.Labels = append(chart.Labels, Label{
Key: lblKey,
Value: j.Name(),
})
}
}

func (j Job) penalty() int {
v := j.retries / penaltyStep * penaltyStep * j.updateEvery / 2
if v > maxPenalty {
Expand Down

0 comments on commit d248e30

Please sign in to comment.