From 7c23293c8960081bd70f21d3ef0345649125bfe7 Mon Sep 17 00:00:00 2001 From: Phillip Wirth Date: Mon, 11 Nov 2024 16:42:40 +0100 Subject: [PATCH] group size distribution test --- .../templates/values.yml.j2 | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/ansible/roles/mongodb_query_exporter/templates/values.yml.j2 b/ansible/roles/mongodb_query_exporter/templates/values.yml.j2 index 573160413..f791963f7 100644 --- a/ansible/roles/mongodb_query_exporter/templates/values.yml.j2 +++ b/ansible/roles/mongodb_query_exporter/templates/values.yml.j2 @@ -1184,3 +1184,46 @@ aggregations: } } ] + + + - database: {{ mongodb_query_exporter_mongodb_sc_db_name }} + collection: groups + metrics: + - name: sc_groups_size_distribution_by_type + type: gauge + help: 'Group user size distribution by type' + value: count + overrideEmpty: true + emptyValue: 0 + labels: + - type + - group_size + constLabels: + longterm: 'true' + mode: pull + pipeline: | + [ + { + "$project": { + "type": 1, + "group_size": { "$size": "$users" } + } + }, + { + "$group": { + "_id": { "type": "$type", "group_size": "$group_size" }, + "count": { "$sum": 1 } + } + }, + { + "$project": { + "_id": 0, + "type": "$_id.type", + "group_size": { "$toString": "$_id.group_size" }, + "count": { "$toDouble": "$count" } + } + }, + { + "$sort": { "type": 1, "group_size": 1 } + } + ] \ No newline at end of file