From 10ae00ab9d6ec2cfe66fcec5bc964dc9dbca50a6 Mon Sep 17 00:00:00 2001 From: Ganesh Vernekar Date: Thu, 31 Jan 2019 15:44:14 +0530 Subject: [PATCH] Fix bug from #4898 (#5161) Signed-off-by: Ganesh Vernekar --- web/web.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/web/web.go b/web/web.go index ecd09e687..60972c63b 100644 --- a/web/web.go +++ b/web/web.go @@ -695,8 +695,12 @@ 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(model.JobLabel) < targets[j].Labels().Get(model.JobLabel) || - targets[i].Labels().Get(model.InstanceLabel) < targets[j].Labels().Get(model.InstanceLabel) + iJobLabel := targets[i].Labels().Get(model.JobLabel) + jJobLabel := targets[j].Labels().Get(model.JobLabel) + if iJobLabel == jJobLabel { + return targets[i].Labels().Get(model.InstanceLabel) < targets[j].Labels().Get(model.InstanceLabel) + } + return iJobLabel < jJobLabel }) }