mirror of https://github.com/prometheus/prometheus
Merge pull request #141 from prometheus/julius-constantize-job-label
Constantize job name label.pull/143/head
commit
6b9de768ee
|
@ -16,6 +16,9 @@ package model
|
||||||
// The label name used to indicate the metric name of a timeseries.
|
// The label name used to indicate the metric name of a timeseries.
|
||||||
const MetricNameLabel = LabelName("name")
|
const MetricNameLabel = LabelName("name")
|
||||||
|
|
||||||
|
// The label name used to indicate the job from which a timeseries was scraped.
|
||||||
|
const JobLabel = LabelName("job")
|
||||||
|
|
||||||
// A LabelName is a key for a LabelSet or Metric. It has a value associated
|
// A LabelName is a key for a LabelSet or Metric. It has a value associated
|
||||||
// therewith.
|
// therewith.
|
||||||
type LabelName string
|
type LabelName string
|
||||||
|
|
|
@ -89,7 +89,7 @@ func (m *targetManager) AddTargetsFromConfig(config *config.Config) {
|
||||||
for _, job := range config.Jobs {
|
for _, job := range config.Jobs {
|
||||||
for _, configTargets := range job.Targets {
|
for _, configTargets := range job.Targets {
|
||||||
baseLabels := model.LabelSet{
|
baseLabels := model.LabelSet{
|
||||||
model.LabelName("job"): model.LabelValue(job.Name),
|
model.JobLabel: model.LabelValue(job.Name),
|
||||||
}
|
}
|
||||||
for label, value := range configTargets.Labels {
|
for label, value := range configTargets.Labels {
|
||||||
baseLabels[label] = value
|
baseLabels[label] = value
|
||||||
|
|
|
@ -167,7 +167,7 @@ func sampleVectorImpl(timestamp time.Time, view *viewAdapter, args []Node) inter
|
||||||
model.Sample{
|
model.Sample{
|
||||||
Metric: model.Metric{
|
Metric: model.Metric{
|
||||||
model.MetricNameLabel: "http_requests",
|
model.MetricNameLabel: "http_requests",
|
||||||
"job": "api-server",
|
model.JobLabel: "api-server",
|
||||||
"instance": "0",
|
"instance": "0",
|
||||||
},
|
},
|
||||||
Value: 10,
|
Value: 10,
|
||||||
|
@ -176,7 +176,7 @@ func sampleVectorImpl(timestamp time.Time, view *viewAdapter, args []Node) inter
|
||||||
model.Sample{
|
model.Sample{
|
||||||
Metric: model.Metric{
|
Metric: model.Metric{
|
||||||
model.MetricNameLabel: "http_requests",
|
model.MetricNameLabel: "http_requests",
|
||||||
"job": "api-server",
|
model.JobLabel: "api-server",
|
||||||
"instance": "1",
|
"instance": "1",
|
||||||
},
|
},
|
||||||
Value: 20,
|
Value: 20,
|
||||||
|
@ -185,7 +185,7 @@ func sampleVectorImpl(timestamp time.Time, view *viewAdapter, args []Node) inter
|
||||||
model.Sample{
|
model.Sample{
|
||||||
Metric: model.Metric{
|
Metric: model.Metric{
|
||||||
model.MetricNameLabel: "http_requests",
|
model.MetricNameLabel: "http_requests",
|
||||||
"job": "api-server",
|
model.JobLabel: "api-server",
|
||||||
"instance": "2",
|
"instance": "2",
|
||||||
},
|
},
|
||||||
Value: 30,
|
Value: 30,
|
||||||
|
@ -194,7 +194,7 @@ func sampleVectorImpl(timestamp time.Time, view *viewAdapter, args []Node) inter
|
||||||
model.Sample{
|
model.Sample{
|
||||||
Metric: model.Metric{
|
Metric: model.Metric{
|
||||||
model.MetricNameLabel: "http_requests",
|
model.MetricNameLabel: "http_requests",
|
||||||
"job": "api-server",
|
model.JobLabel: "api-server",
|
||||||
"instance": "3",
|
"instance": "3",
|
||||||
"group": "canary",
|
"group": "canary",
|
||||||
},
|
},
|
||||||
|
@ -204,7 +204,7 @@ func sampleVectorImpl(timestamp time.Time, view *viewAdapter, args []Node) inter
|
||||||
model.Sample{
|
model.Sample{
|
||||||
Metric: model.Metric{
|
Metric: model.Metric{
|
||||||
model.MetricNameLabel: "http_requests",
|
model.MetricNameLabel: "http_requests",
|
||||||
"job": "api-server",
|
model.JobLabel: "api-server",
|
||||||
"instance": "2",
|
"instance": "2",
|
||||||
"group": "canary",
|
"group": "canary",
|
||||||
},
|
},
|
||||||
|
@ -214,7 +214,7 @@ func sampleVectorImpl(timestamp time.Time, view *viewAdapter, args []Node) inter
|
||||||
model.Sample{
|
model.Sample{
|
||||||
Metric: model.Metric{
|
Metric: model.Metric{
|
||||||
model.MetricNameLabel: "http_requests",
|
model.MetricNameLabel: "http_requests",
|
||||||
"job": "api-server",
|
model.JobLabel: "api-server",
|
||||||
"instance": "3",
|
"instance": "3",
|
||||||
"group": "mytest",
|
"group": "mytest",
|
||||||
},
|
},
|
||||||
|
@ -224,7 +224,7 @@ func sampleVectorImpl(timestamp time.Time, view *viewAdapter, args []Node) inter
|
||||||
model.Sample{
|
model.Sample{
|
||||||
Metric: model.Metric{
|
Metric: model.Metric{
|
||||||
model.MetricNameLabel: "http_requests",
|
model.MetricNameLabel: "http_requests",
|
||||||
"job": "api-server",
|
model.JobLabel: "api-server",
|
||||||
"instance": "3",
|
"instance": "3",
|
||||||
"group": "mytest",
|
"group": "mytest",
|
||||||
},
|
},
|
||||||
|
|
|
@ -71,7 +71,7 @@ var testMatrix = ast.Matrix{
|
||||||
{
|
{
|
||||||
Metric: model.Metric{
|
Metric: model.Metric{
|
||||||
model.MetricNameLabel: "http_requests",
|
model.MetricNameLabel: "http_requests",
|
||||||
"job": "api-server",
|
model.JobLabel: "api-server",
|
||||||
"instance": "0",
|
"instance": "0",
|
||||||
"group": "production",
|
"group": "production",
|
||||||
},
|
},
|
||||||
|
@ -80,7 +80,7 @@ var testMatrix = ast.Matrix{
|
||||||
{
|
{
|
||||||
Metric: model.Metric{
|
Metric: model.Metric{
|
||||||
model.MetricNameLabel: "http_requests",
|
model.MetricNameLabel: "http_requests",
|
||||||
"job": "api-server",
|
model.JobLabel: "api-server",
|
||||||
"instance": "1",
|
"instance": "1",
|
||||||
"group": "production",
|
"group": "production",
|
||||||
},
|
},
|
||||||
|
@ -89,7 +89,7 @@ var testMatrix = ast.Matrix{
|
||||||
{
|
{
|
||||||
Metric: model.Metric{
|
Metric: model.Metric{
|
||||||
model.MetricNameLabel: "http_requests",
|
model.MetricNameLabel: "http_requests",
|
||||||
"job": "api-server",
|
model.JobLabel: "api-server",
|
||||||
"instance": "0",
|
"instance": "0",
|
||||||
"group": "canary",
|
"group": "canary",
|
||||||
},
|
},
|
||||||
|
@ -98,7 +98,7 @@ var testMatrix = ast.Matrix{
|
||||||
{
|
{
|
||||||
Metric: model.Metric{
|
Metric: model.Metric{
|
||||||
model.MetricNameLabel: "http_requests",
|
model.MetricNameLabel: "http_requests",
|
||||||
"job": "api-server",
|
model.JobLabel: "api-server",
|
||||||
"instance": "1",
|
"instance": "1",
|
||||||
"group": "canary",
|
"group": "canary",
|
||||||
},
|
},
|
||||||
|
@ -107,7 +107,7 @@ var testMatrix = ast.Matrix{
|
||||||
{
|
{
|
||||||
Metric: model.Metric{
|
Metric: model.Metric{
|
||||||
model.MetricNameLabel: "http_requests",
|
model.MetricNameLabel: "http_requests",
|
||||||
"job": "app-server",
|
model.JobLabel: "app-server",
|
||||||
"instance": "0",
|
"instance": "0",
|
||||||
"group": "production",
|
"group": "production",
|
||||||
},
|
},
|
||||||
|
@ -116,7 +116,7 @@ var testMatrix = ast.Matrix{
|
||||||
{
|
{
|
||||||
Metric: model.Metric{
|
Metric: model.Metric{
|
||||||
model.MetricNameLabel: "http_requests",
|
model.MetricNameLabel: "http_requests",
|
||||||
"job": "app-server",
|
model.JobLabel: "app-server",
|
||||||
"instance": "1",
|
"instance": "1",
|
||||||
"group": "production",
|
"group": "production",
|
||||||
},
|
},
|
||||||
|
@ -125,7 +125,7 @@ var testMatrix = ast.Matrix{
|
||||||
{
|
{
|
||||||
Metric: model.Metric{
|
Metric: model.Metric{
|
||||||
model.MetricNameLabel: "http_requests",
|
model.MetricNameLabel: "http_requests",
|
||||||
"job": "app-server",
|
model.JobLabel: "app-server",
|
||||||
"instance": "0",
|
"instance": "0",
|
||||||
"group": "canary",
|
"group": "canary",
|
||||||
},
|
},
|
||||||
|
@ -134,7 +134,7 @@ var testMatrix = ast.Matrix{
|
||||||
{
|
{
|
||||||
Metric: model.Metric{
|
Metric: model.Metric{
|
||||||
model.MetricNameLabel: "http_requests",
|
model.MetricNameLabel: "http_requests",
|
||||||
"job": "app-server",
|
model.JobLabel: "app-server",
|
||||||
"instance": "1",
|
"instance": "1",
|
||||||
"group": "canary",
|
"group": "canary",
|
||||||
},
|
},
|
||||||
|
|
|
@ -34,7 +34,7 @@ func (serv MetricsService) SetTargets(targetGroups []TargetGroup, jobName string
|
||||||
for _, targetGroup := range targetGroups {
|
for _, targetGroup := range targetGroups {
|
||||||
// Do mandatory map type conversion due to Go shortcomings.
|
// Do mandatory map type conversion due to Go shortcomings.
|
||||||
baseLabels := model.LabelSet{
|
baseLabels := model.LabelSet{
|
||||||
model.LabelName("job"): model.LabelValue(job.Name),
|
model.JobLabel: model.LabelValue(job.Name),
|
||||||
}
|
}
|
||||||
for label, value := range targetGroup.BaseLabels {
|
for label, value := range targetGroup.BaseLabels {
|
||||||
baseLabels[model.LabelName(label)] = model.LabelValue(value)
|
baseLabels[model.LabelName(label)] = model.LabelValue(value)
|
||||||
|
|
Loading…
Reference in New Issue