From 486324753e40dafb8cc808c554cc1bdd2516aad7 Mon Sep 17 00:00:00 2001 From: Sergiusz Urbaniak Date: Fri, 17 May 2019 15:01:35 +0200 Subject: [PATCH] pkg/naming/BuildExternal: respect namespace Currently, the namespace is ignored for external labels. This fixes it. --- pkg/naming/metrics_query.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/naming/metrics_query.go b/pkg/naming/metrics_query.go index a38e6785..30411863 100644 --- a/pkg/naming/metrics_query.go +++ b/pkg/naming/metrics_query.go @@ -142,6 +142,19 @@ func (q *metricsQuery) BuildExternal(seriesName string, namespace string, groupB // Build up the query parts from the selector. queryParts = append(queryParts, q.createQueryPartsFromSelector(metricSelector)...) + if namespace != "" { + namespaceLbl, err := q.resConverter.LabelForResource(NsGroupResource) + if err != nil { + return "", err + } + + queryParts = append(queryParts, queryPart{ + labelName: string(namespaceLbl), + values: []string{namespace}, + operator: selection.Equals, + }) + } + // Convert our query parts into the types we need for our template. exprs, valuesByName, err := q.processQueryParts(queryParts)