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

add collect job label to charts #814

Merged
merged 1 commit into from
Sep 8, 2022
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
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