From 77ee41084fae5a286e8469490863b0bfea6ed7e3 Mon Sep 17 00:00:00 2001 From: Simon Pasquier Date: Fri, 30 Nov 2018 15:24:15 +0100 Subject: [PATCH] web: group targets by job then instance (#4898) Signed-off-by: Simon Pasquier --- web/web.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/web.go b/web/web.go index 1945051a02..8cc63a7f4e 100644 --- a/web/web.go +++ b/web/web.go @@ -55,7 +55,6 @@ import ( "github.com/prometheus/prometheus/config" "github.com/prometheus/prometheus/notifier" - "github.com/prometheus/prometheus/pkg/labels" "github.com/prometheus/prometheus/promql" "github.com/prometheus/prometheus/rules" "github.com/prometheus/prometheus/scrape" @@ -709,7 +708,8 @@ func (h *Handler) targets(w http.ResponseWriter, r *http.Request) { tps := h.scrapeManager.TargetsActive() for _, targets := range tps { sort.Slice(targets, func(i, j int) bool { - return targets[i].Labels().Get(labels.InstanceName) < targets[j].Labels().Get(labels.InstanceName) + return targets[i].Labels().Get(model.JobLabel) < targets[j].Labels().Get(model.JobLabel) || + targets[i].Labels().Get(model.InstanceLabel) < targets[j].Labels().Get(model.InstanceLabel) }) }