Skip to content

Commit

Permalink
Merge pull request #4392 from burdandrei/telemetry-parametrized-jobs
Browse files Browse the repository at this point in the history
Parametrized/periodic jobs per child tagged metric emmision
  • Loading branch information
preetapan committed Jun 21, 2018
2 parents e2e6079 + 4e352f3 commit 7325cf6
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
20 changes: 20 additions & 0 deletions client/allocrunner/taskrunner/task_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,26 @@ func NewTaskRunner(logger *log.Logger, config *config.Config,
},
}

if tc.alloc.Job.ParentID != "" {
tc.baseLabels = append(tc.baseLabels, metrics.Label{
Name: "parent_id",
Value: tc.alloc.Job.ParentID,
})
if strings.Contains(tc.alloc.Job.Name, "/dispatch-") {
tc.baseLabels = append(tc.baseLabels, metrics.Label{
Name: "dispatch_id",
Value: strings.Split(tc.alloc.Job.Name, "/dispatch-")[1],
})
}
if strings.Contains(tc.alloc.Job.Name, "/periodic-") {
tc.baseLabels = append(tc.baseLabels, metrics.Label{
Name: "periodic_id",
Value: strings.Split(tc.alloc.Job.Name, "/periodic-")[1],
})
}
return tc
}

return tc
}

Expand Down
25 changes: 25 additions & 0 deletions nomad/leader.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (

"golang.org/x/time/rate"

"strings"

"github.com/armon/go-metrics"
memdb "github.com/hashicorp/go-memdb"
"github.com/hashicorp/go-version"
Expand Down Expand Up @@ -625,6 +627,29 @@ func (s *Server) publishJobSummaryMetrics(stopCh chan struct{}) {
Value: name,
},
}

if strings.Contains(summary.JobID, "/dispatch-") {
jobInfo := strings.Split(summary.JobID, "/dispatch-")
labels = append(labels, metrics.Label{
Name: "parent_id",
Value: jobInfo[0],
}, metrics.Label{
Name: "dispatch_id",
Value: jobInfo[1],
})
}

if strings.Contains(summary.JobID, "/periodic-") {
jobInfo := strings.Split(summary.JobID, "/periodic-")
labels = append(labels, metrics.Label{
Name: "parent_id",
Value: jobInfo[0],
}, metrics.Label{
Name: "periodic_id",
Value: jobInfo[1],
})
}

metrics.SetGaugeWithLabels([]string{"nomad", "job_summary", "queued"},
float32(tgSummary.Queued), labels)
metrics.SetGaugeWithLabels([]string{"nomad", "job_summary", "complete"},
Expand Down

0 comments on commit 7325cf6

Please sign in to comment.