From e313d8a873f92c4095ac633abd61b239cd1dd134 Mon Sep 17 00:00:00 2001 From: Travis Patterson Date: Tue, 24 May 2022 08:35:04 -0600 Subject: [PATCH] Remove __name__ from label calls (#6229) --- integration/loki_micro_services_test.go | 2 +- integration/loki_single_binary_test.go | 2 +- pkg/storage/stores/series/series_index_store.go | 1 - pkg/storage/stores/series/series_store_test.go | 4 ++-- pkg/storage/stores/series/series_store_utils.go | 4 ++++ 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/integration/loki_micro_services_test.go b/integration/loki_micro_services_test.go index 954dd8fce1..de88fe5736 100644 --- a/integration/loki_micro_services_test.go +++ b/integration/loki_micro_services_test.go @@ -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) { diff --git a/integration/loki_single_binary_test.go b/integration/loki_single_binary_test.go index b836685785..a2b58cf4f2 100644 --- a/integration/loki_single_binary_test.go +++ b/integration/loki_single_binary_test.go @@ -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) { diff --git a/pkg/storage/stores/series/series_index_store.go b/pkg/storage/stores/series/series_index_store.go index 8790165d3c..5160145dbc 100644 --- a/pkg/storage/stores/series/series_index_store.go +++ b/pkg/storage/stores/series/series_index_store.go @@ -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) diff --git a/pkg/storage/stores/series/series_store_test.go b/pkg/storage/stores/series/series_store_test.go index 212026a1cf..9160ef34c4 100644 --- a/pkg/storage/stores/series/series_store_test.go +++ b/pkg/storage/stores/series/series_store_test.go @@ -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 { diff --git a/pkg/storage/stores/series/series_store_utils.go b/pkg/storage/stores/series/series_store_utils.go index 317e0547bd..0e9b44e1cc 100644 --- a/pkg/storage/stores/series/series_store_utils.go +++ b/pkg/storage/stores/series/series_store_utils.go @@ -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) } }