Constantize job name label.

pull/141/head
Julius Volz 2013-04-15 11:47:54 +02:00
parent f21b5ad12b
commit a0d311c9e6
5 changed files with 20 additions and 17 deletions

View File

@ -16,6 +16,9 @@ package model
// The label name used to indicate the metric name of a timeseries.
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
// therewith.
type LabelName string

View File

@ -89,7 +89,7 @@ func (m *targetManager) AddTargetsFromConfig(config *config.Config) {
for _, job := range config.Jobs {
for _, configTargets := range job.Targets {
baseLabels := model.LabelSet{
model.LabelName("job"): model.LabelValue(job.Name),
model.JobLabel: model.LabelValue(job.Name),
}
for label, value := range configTargets.Labels {
baseLabels[label] = value

View File

@ -167,7 +167,7 @@ func sampleVectorImpl(timestamp time.Time, view *viewAdapter, args []Node) inter
model.Sample{
Metric: model.Metric{
model.MetricNameLabel: "http_requests",
"job": "api-server",
model.JobLabel: "api-server",
"instance": "0",
},
Value: 10,
@ -176,7 +176,7 @@ func sampleVectorImpl(timestamp time.Time, view *viewAdapter, args []Node) inter
model.Sample{
Metric: model.Metric{
model.MetricNameLabel: "http_requests",
"job": "api-server",
model.JobLabel: "api-server",
"instance": "1",
},
Value: 20,
@ -185,7 +185,7 @@ func sampleVectorImpl(timestamp time.Time, view *viewAdapter, args []Node) inter
model.Sample{
Metric: model.Metric{
model.MetricNameLabel: "http_requests",
"job": "api-server",
model.JobLabel: "api-server",
"instance": "2",
},
Value: 30,
@ -194,7 +194,7 @@ func sampleVectorImpl(timestamp time.Time, view *viewAdapter, args []Node) inter
model.Sample{
Metric: model.Metric{
model.MetricNameLabel: "http_requests",
"job": "api-server",
model.JobLabel: "api-server",
"instance": "3",
"group": "canary",
},
@ -204,7 +204,7 @@ func sampleVectorImpl(timestamp time.Time, view *viewAdapter, args []Node) inter
model.Sample{
Metric: model.Metric{
model.MetricNameLabel: "http_requests",
"job": "api-server",
model.JobLabel: "api-server",
"instance": "2",
"group": "canary",
},
@ -214,7 +214,7 @@ func sampleVectorImpl(timestamp time.Time, view *viewAdapter, args []Node) inter
model.Sample{
Metric: model.Metric{
model.MetricNameLabel: "http_requests",
"job": "api-server",
model.JobLabel: "api-server",
"instance": "3",
"group": "mytest",
},
@ -224,7 +224,7 @@ func sampleVectorImpl(timestamp time.Time, view *viewAdapter, args []Node) inter
model.Sample{
Metric: model.Metric{
model.MetricNameLabel: "http_requests",
"job": "api-server",
model.JobLabel: "api-server",
"instance": "3",
"group": "mytest",
},

View File

@ -71,7 +71,7 @@ var testMatrix = ast.Matrix{
{
Metric: model.Metric{
model.MetricNameLabel: "http_requests",
"job": "api-server",
model.JobLabel: "api-server",
"instance": "0",
"group": "production",
},
@ -80,7 +80,7 @@ var testMatrix = ast.Matrix{
{
Metric: model.Metric{
model.MetricNameLabel: "http_requests",
"job": "api-server",
model.JobLabel: "api-server",
"instance": "1",
"group": "production",
},
@ -89,7 +89,7 @@ var testMatrix = ast.Matrix{
{
Metric: model.Metric{
model.MetricNameLabel: "http_requests",
"job": "api-server",
model.JobLabel: "api-server",
"instance": "0",
"group": "canary",
},
@ -98,7 +98,7 @@ var testMatrix = ast.Matrix{
{
Metric: model.Metric{
model.MetricNameLabel: "http_requests",
"job": "api-server",
model.JobLabel: "api-server",
"instance": "1",
"group": "canary",
},
@ -107,7 +107,7 @@ var testMatrix = ast.Matrix{
{
Metric: model.Metric{
model.MetricNameLabel: "http_requests",
"job": "app-server",
model.JobLabel: "app-server",
"instance": "0",
"group": "production",
},
@ -116,7 +116,7 @@ var testMatrix = ast.Matrix{
{
Metric: model.Metric{
model.MetricNameLabel: "http_requests",
"job": "app-server",
model.JobLabel: "app-server",
"instance": "1",
"group": "production",
},
@ -125,7 +125,7 @@ var testMatrix = ast.Matrix{
{
Metric: model.Metric{
model.MetricNameLabel: "http_requests",
"job": "app-server",
model.JobLabel: "app-server",
"instance": "0",
"group": "canary",
},
@ -134,7 +134,7 @@ var testMatrix = ast.Matrix{
{
Metric: model.Metric{
model.MetricNameLabel: "http_requests",
"job": "app-server",
model.JobLabel: "app-server",
"instance": "1",
"group": "canary",
},

View File

@ -34,7 +34,7 @@ func (serv MetricsService) SetTargets(targetGroups []TargetGroup, jobName string
for _, targetGroup := range targetGroups {
// Do mandatory map type conversion due to Go shortcomings.
baseLabels := model.LabelSet{
model.LabelName("job"): model.LabelValue(job.Name),
model.JobLabel: model.LabelValue(job.Name),
}
for label, value := range targetGroup.BaseLabels {
baseLabels[model.LabelName(label)] = model.LabelValue(value)