Switch to new "__name__" metric name label.
This also fixes the compaction test, which before worked only because the input sample sorting was accidentally equal to the resulting on-disk sample sorting. Change-Id: I2a21c4b46ba562424b27058fc02eba84fa6a6006
This commit is contained in:
parent
c3b282bd14
commit
cc04238a85
|
@ -16,6 +16,7 @@ package metric
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -34,7 +35,7 @@ func generateTestSamples(endTime clientmodel.Timestamp, numTs int, samplesPerTs
|
||||||
startTime := endTime.Add(-interval * time.Duration(samplesPerTs-1))
|
startTime := endTime.Add(-interval * time.Duration(samplesPerTs-1))
|
||||||
for ts := 0; ts < numTs; ts++ {
|
for ts := 0; ts < numTs; ts++ {
|
||||||
metric := clientmodel.Metric{}
|
metric := clientmodel.Metric{}
|
||||||
metric["name"] = clientmodel.LabelValue(fmt.Sprintf("metric_%d", ts))
|
metric[clientmodel.MetricNameLabel] = clientmodel.LabelValue(fmt.Sprintf("metric_%d", ts))
|
||||||
for i := 0; i < samplesPerTs; i++ {
|
for i := 0; i < samplesPerTs; i++ {
|
||||||
sample := &clientmodel.Sample{
|
sample := &clientmodel.Sample{
|
||||||
Metric: metric,
|
Metric: metric,
|
||||||
|
@ -44,6 +45,7 @@ func generateTestSamples(endTime clientmodel.Timestamp, numTs int, samplesPerTs
|
||||||
samples = append(samples, sample)
|
samples = append(samples, sample)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sort.Sort(samples)
|
||||||
return samples
|
return samples
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +94,7 @@ func checkStorageSaneAndEquivalent(t *testing.T, name string, ts *TieredStorage,
|
||||||
}
|
}
|
||||||
entire, err := ts.DiskStorage.MetricSamples.ForEach(&MetricSamplesDecoder{}, &AcceptAllFilter{}, cc)
|
entire, err := ts.DiskStorage.MetricSamples.ForEach(&MetricSamplesDecoder{}, &AcceptAllFilter{}, cc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("%s: Error dumping samples: %s", name, err)
|
t.Fatalf("%s: Error checking samples: %s", name, err)
|
||||||
}
|
}
|
||||||
if !entire {
|
if !entire {
|
||||||
t.Fatalf("%s: Didn't scan entire corpus", name)
|
t.Fatalf("%s: Didn't scan entire corpus", name)
|
||||||
|
|
|
@ -341,7 +341,7 @@ Prometheus.Graph.prototype.updateRefresh = function() {
|
||||||
Prometheus.Graph.prototype.renderLabels = function(labels) {
|
Prometheus.Graph.prototype.renderLabels = function(labels) {
|
||||||
var labelStrings = [];
|
var labelStrings = [];
|
||||||
for (label in labels) {
|
for (label in labels) {
|
||||||
if (label != "name") {
|
if (label != "__name__") {
|
||||||
labelStrings.push("<strong>" + label + "</strong>: " + labels[label]);
|
labelStrings.push("<strong>" + label + "</strong>: " + labels[label]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,10 +349,10 @@ Prometheus.Graph.prototype.renderLabels = function(labels) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Prometheus.Graph.prototype.metricToTsName = function(labels) {
|
Prometheus.Graph.prototype.metricToTsName = function(labels) {
|
||||||
var tsName = labels["name"] + "{";
|
var tsName = labels["__name__"] + "{";
|
||||||
var labelStrings = [];
|
var labelStrings = [];
|
||||||
for (label in labels) {
|
for (label in labels) {
|
||||||
if (label != "name") {
|
if (label != "__name__") {
|
||||||
labelStrings.push(label + "=\"" + labels[label] + "\"");
|
labelStrings.push(label + "=\"" + labels[label] + "\"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -437,7 +437,7 @@ Prometheus.Graph.prototype.updateGraph = function(reloadGraph) {
|
||||||
graph: self.rickshawGraph,
|
graph: self.rickshawGraph,
|
||||||
formatter: function(series, x, y) {
|
formatter: function(series, x, y) {
|
||||||
var swatch = '<span class="detail_swatch" style="background-color: ' + series.color + '"></span>';
|
var swatch = '<span class="detail_swatch" style="background-color: ' + series.color + '"></span>';
|
||||||
var content = swatch + series.labels["name"] + ": <strong>" + y + '</strong><br>';
|
var content = swatch + series.labels["__name__"] + ": <strong>" + y + '</strong><br>';
|
||||||
return content + self.renderLabels(series.labels);
|
return content + self.renderLabels(series.labels);
|
||||||
},
|
},
|
||||||
onRender: function() {
|
onRender: function() {
|
||||||
|
|
Loading…
Reference in New Issue