Skip to content

Commit

Permalink
Remove __name__ from label calls (#6229)
Browse files Browse the repository at this point in the history
  • Loading branch information
MasslessParticle authored May 24, 2022
1 parent 67e7285 commit e313d8a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion integration/loki_micro_services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestMicroServicesIngestQuery(t *testing.T) {
t.Run("label-names", func(t *testing.T) {
resp, err := cliQueryFrontend.LabelNames()
require.NoError(t, err)
assert.ElementsMatch(t, []string{"__name__", "job"}, resp)
assert.ElementsMatch(t, []string{"job"}, resp)
})

t.Run("label-values", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion integration/loki_single_binary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func TestSingleBinaryIngestQuery(t *testing.T) {
t.Run("label-names", func(t *testing.T) {
resp, err := cli.LabelNames()
require.NoError(t, err)
assert.ElementsMatch(t, []string{"__name__", "job"}, resp)
assert.ElementsMatch(t, []string{"job"}, resp)
})

t.Run("label-values", func(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion pkg/storage/stores/series/series_index_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ func (c *indexStore) lookupLabelNamesBySeries(ctx context.Context, from, through
level.Debug(log).Log("entries", len(entries))

var result util.UniqueStrings
result.Add(model.MetricNameLabel)
for _, entry := range entries {
lbs := []string{}
err := jsoniter.ConfigFastest.Unmarshal(entry.Value, &lbs)
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/stores/series/series_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,11 @@ func TestChunkStore_LabelNamesForMetricName(t *testing.T) {
}{
{
`foo`,
[]string{labels.MetricName, "bar", "flip", "toms"},
[]string{"bar", "flip", "toms"},
},
{
`bar`,
[]string{labels.MetricName, "bar", "toms"},
[]string{"bar", "toms"},
},
} {
for _, schema := range schemas {
Expand Down
4 changes: 4 additions & 0 deletions pkg/storage/stores/series/series_store_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ func labelNamesFromChunks(chunks []chunk.Chunk) []string {
var result util.UniqueStrings
for _, c := range chunks {
for _, l := range c.Metric {
if l.Name == model.MetricNameLabel {
continue
}

result.Add(l.Name)
}
}
Expand Down

0 comments on commit e313d8a

Please sign in to comment.