Skip to content

Commit

Permalink
[Cluster Agent] Add info metric cluster_checks_configs_info (#11518)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-mez authored Apr 4, 2022
1 parent 6c03a0f commit cb9f293
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/clusteragent/clusterchecks/dispatcher_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ func (d *dispatcher) addConfig(config integration.Config, targetNodeName string)
digest := config.Digest()
d.store.digestToConfig[digest] = config
for _, instance := range config.Instances {
d.store.idToDigest[check.BuildID(config.Name, instance, config.InitConfig)] = digest
checkID := check.BuildID(config.Name, instance, config.InitConfig)
d.store.idToDigest[checkID] = digest
if targetNodeName != "" {
configsInfo.Set(1.0, targetNodeName, string(checkID), le.JoinLeaderValue)
}
}

// No target node specified: store in danglingConfigs
Expand Down Expand Up @@ -91,6 +95,7 @@ func (d *dispatcher) removeConfig(digest string) {

for k, v := range d.store.idToDigest {
if v == digest {
configsInfo.Delete(node.name, string(k), le.JoinLeaderValue)
delete(d.store.idToDigest, k)
}
}
Expand Down
9 changes: 9 additions & 0 deletions pkg/clusteragent/clusterchecks/dispatcher_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ func (d *dispatcher) expireNodes() {
log.Debugf("Adding %s:%s as a dangling Cluster Check config", config.Name, digest)
d.store.danglingConfigs[digest] = config
danglingConfigs.Inc(le.JoinLeaderValue)

// TODO: Use partial label matching when it becomes available:
// Replace the loop by a single function call (delete by node name).
// Requires https://github.com/prometheus/client_golang/pull/1013
for k, v := range d.store.idToDigest {
if v == digest {
configsInfo.Delete(name, string(k), le.JoinLeaderValue)
}
}
}
delete(d.store.nodes, name)

Expand Down
4 changes: 4 additions & 0 deletions pkg/clusteragent/clusterchecks/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ var (
busyness = telemetry.NewGaugeWithOpts("cluster_checks", "busyness",
[]string{"node", le.JoinLeaderLabel}, "Busyness of a node per the number of metrics submitted and average duration of all checks run",
telemetry.Options{NoDoubleUnderscoreSep: true})
configsInfo = telemetry.NewGaugeWithOpts("cluster_checks", "configs_info",
[]string{"node", "check_id", le.JoinLeaderLabel}, "Information about the dispatched checks (node, check ID)",
telemetry.Options{NoDoubleUnderscoreSep: true},
)
)
5 changes: 5 additions & 0 deletions releasenotes/notes/clc-info-metric-26bcbaa314cb8e10.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
enhancements:
- |
The Cluster Agent now exposes a new metric ``cluster_checks_configs_info``.
It exposes the node and the check ID as tags.

0 comments on commit cb9f293

Please sign in to comment.