Merge pull request #4392 from burdandrei/telemetry-parametrized-jobs

Parametrized/periodic jobs per child tagged metric emmision
This commit is contained in:
Preetha
2018-06-21 17:13:36 -05:00
committed by GitHub
2 changed files with 45 additions and 0 deletions

View File

@@ -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
}

View File

@@ -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"},