From f13aa5ba9bbbaa2a3ba8ad539358bbfe3daba40c Mon Sep 17 00:00:00 2001
From: Pierre Souchay
Date: Wed, 18 Apr 2018 16:51:22 +0200
Subject: [PATCH] Added labels to improve new metric
---
agent/local/state.go | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/agent/local/state.go b/agent/local/state.go
index cacbd6607b..0e9b513e6c 100644
--- a/agent/local/state.go
+++ b/agent/local/state.go
@@ -843,7 +843,7 @@ func (l *State) deleteService(id string) error {
// todo(fs): some backoff strategy might be a better solution
l.services[id].InSync = true
l.logger.Printf("[WARN] agent: Service %q deregistration blocked by ACLs", id)
- metrics.IncrCounter([]string{"consul", "acl", "blocked", "service", "deregistration"}, 1)
+ metrics.IncrCounterWithLabels([]string{"consul", "acl", "blocked", "service", "deregistration"}, 1, []metrics.Label{{Name: "id", Value: id}})
return nil
default:
@@ -881,7 +881,7 @@ func (l *State) deleteCheck(id types.CheckID) error {
// todo(fs): some backoff strategy might be a better solution
l.checks[id].InSync = true
l.logger.Printf("[WARN] agent: Check %q deregistration blocked by ACLs", id)
- metrics.IncrCounter([]string{"consul", "acl", "blocked", "check", "deregistration"}, 1)
+ metrics.IncrCounterWithLabels([]string{"consul", "acl", "blocked", "check", "deregistration"}, 1, []metrics.Label{{Name: "id", Value: string(id)}})
return nil
default:
@@ -952,7 +952,7 @@ func (l *State) syncService(id string) error {
l.checks[check.CheckID].InSync = true
}
l.logger.Printf("[WARN] agent: Service %q registration blocked by ACLs", id)
- metrics.IncrCounter([]string{"consul", "acl", "blocked", "service", "registration"}, 1)
+ metrics.IncrCounterWithLabels([]string{"consul", "acl", "blocked", "service", "registration"}, 1, []metrics.Label{{Name: "id", Value: id}})
return nil
default:
@@ -998,7 +998,7 @@ func (l *State) syncCheck(id types.CheckID) error {
// todo(fs): some backoff strategy might be a better solution
l.checks[id].InSync = true
l.logger.Printf("[WARN] agent: Check %q registration blocked by ACLs", id)
- metrics.IncrCounter([]string{"consul", "acl", "blocked", "service", "registration"}, 1)
+ metrics.IncrCounterWithLabels([]string{"consul", "acl", "blocked", "check", "registration"}, 1, []metrics.Label{{Name: "check", Value: string(id)}})
return nil
default:
@@ -1030,7 +1030,7 @@ func (l *State) syncNodeInfo() error {
// todo(fs): some backoff strategy might be a better solution
l.nodeInfoInSync = true
l.logger.Printf("[WARN] agent: Node info update blocked by ACLs")
- metrics.IncrCounter([]string{"consul", "acl", "blocked", "node", "registration"}, 1)
+ metrics.IncrCounterWithLabels([]string{"consul", "acl", "blocked", "node", "registration"}, 1, []metrics.Label{{Name: "id", Value: string(l.config.NodeID)}, {Name: "name", Value: l.config.NodeName}})
return nil
default: