Skip to content

Commit 9b63e46

Browse files
authored
Introduce a new foundationdb.processes_per_role gauge tagged by role/process class (#19706)
1 parent 0214a39 commit 9b63e46

File tree

5 files changed

+42
-0
lines changed

5 files changed

+42
-0
lines changed

foundationdb/changelog.d/19706.added

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Introduce a `foundationdb.processes_per_role` gauge tagged by process role/class

foundationdb/datadog_checks/foundationdb/check.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,20 +233,47 @@ def check_metrics(self, status):
233233
)
234234

235235
role_counts = {}
236+
process_counts_by_tag_set = {}
236237

237238
for process_key in processes:
238239
process = processes[process_key]
239240

240241
self.report_process(process)
242+
243+
process_tags = tags.copy()
244+
245+
if "class_type" in process:
246+
process_tags.append("fdb_process_class:" + process["class_type"])
247+
241248
if "roles" in process:
242249
for role in process["roles"]:
243250
if "role" in role:
244251
rolename = role["role"]
252+
process_tags.append("fdb_role:" + rolename)
245253
if rolename in role_counts:
246254
role_counts[rolename] += 1
247255
else:
248256
role_counts[rolename] = 1
249257

258+
process_tags.sort()
259+
260+
# Packing and unpacking tags into sorted, comma-separated strings is a little hacky, but allows us to
261+
# keep a map of role sets to counts; lists/sets aren't hashable and won't work as dictionary keys.
262+
tags_string = ",".join(process_tags)
263+
264+
if tags_string in process_counts_by_tag_set:
265+
process_counts_by_tag_set[tags_string] += 1
266+
else:
267+
process_counts_by_tag_set[tags_string] = 1
268+
269+
for tags_string in process_counts_by_tag_set:
270+
process_tags = tags_string.split(",")
271+
self.gauge(
272+
"processes_per_role",
273+
process_counts_by_tag_set[tags_string],
274+
process_tags if process_tags else None,
275+
)
276+
250277
for role in role_counts:
251278
self.gauge("processes_per_role." + role, role_counts[role], tags)
252279

foundationdb/metadata.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ foundationdb.process.role.stored_bytes,gauge,,byte,,,0,foundationdb,stored bytes
9494
foundationdb.process.role.total_queries.counter,count,,query,,,0,foundationdb,total queries,
9595
foundationdb.process.role.total_queries.hz,gauge,,query,,,0,foundationdb,total queries,
9696
foundationdb.processes,gauge,,process,,,0,foundationdb,processes,
97+
foundationdb.processes_per_role,gauge,,process,,,0,foundationdb,processes per role/process class,
9798
foundationdb.processes_per_role.cluster_controller,gauge,,process,,,0,foundationdb,processes per cluster controller,
9899
foundationdb.processes_per_role.coordinator,gauge,,process,,,0,foundationdb,processes per coordinator,
99100
foundationdb.processes_per_role.data_distributor,gauge,,process,,,0,foundationdb,processes per data distributor,

foundationdb/tests/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@
189189
"foundationdb.process.role.read_latency_statistics.p90",
190190
"foundationdb.process.role.read_latency_statistics.p99",
191191
"foundationdb.process.role.queue_length",
192+
"foundationdb.processes_per_role",
192193
"foundationdb.processes_per_role.cluster_controller",
193194
"foundationdb.processes_per_role.coordinator",
194195
"foundationdb.processes_per_role.data_distributor",

foundationdb/tests/test_foundationdb.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ def test_full(aggregator, instance):
6363
aggregator.assert_metrics_using_metadata(get_metadata_metrics())
6464
aggregator.assert_service_check("foundationdb.can_connect", AgentCheck.OK)
6565

66+
aggregator.assert_metric_has_tag("foundationdb.processes_per_role", "fdb_process_class:unset")
67+
68+
aggregator.assert_metric_has_tag("foundationdb.processes_per_role", "fdb_role:master")
69+
aggregator.assert_metric_has_tag("foundationdb.processes_per_role", "fdb_role:cluster_controller")
70+
aggregator.assert_metric_has_tag("foundationdb.processes_per_role", "fdb_role:data_distributor")
71+
aggregator.assert_metric_has_tag("foundationdb.processes_per_role", "fdb_role:ratekeeper")
72+
aggregator.assert_metric_has_tag("foundationdb.processes_per_role", "fdb_role:coordinator")
73+
aggregator.assert_metric_has_tag("foundationdb.processes_per_role", "fdb_role:proxy")
74+
aggregator.assert_metric_has_tag("foundationdb.processes_per_role", "fdb_role:log")
75+
aggregator.assert_metric_has_tag("foundationdb.processes_per_role", "fdb_role:storage")
76+
aggregator.assert_metric_has_tag("foundationdb.processes_per_role", "fdb_role:resolver")
77+
6678

6779
@pytest.mark.skipif(PROTOCOL == 'tls', reason="Non-TLS FoundationDB cluster only.")
6880
@pytest.mark.usefixtures("dd_environment")

0 commit comments

Comments
 (0)