mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 09:25:46 +03:00
Merge pull request #4392 from burdandrei/telemetry-parametrized-jobs
Parametrized/periodic jobs per child tagged metric emmision
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
@@ -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"},
|
||||
|
||||
Reference in New Issue
Block a user