From eb61436103f55fe31cf9ebbcdc5cd43a31177f6f Mon Sep 17 00:00:00 2001 From: Phillip Wirth Date: Wed, 30 Oct 2024 18:21:11 +0100 Subject: [PATCH] BC-8339 last seven days security check on files --- .../templates/values.yml.j2 | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/ansible/roles/mongodb_query_exporter/templates/values.yml.j2 b/ansible/roles/mongodb_query_exporter/templates/values.yml.j2 index ad8ba98e0..b47c47791 100644 --- a/ansible/roles/mongodb_query_exporter/templates/values.yml.j2 +++ b/ansible/roles/mongodb_query_exporter/templates/values.yml.j2 @@ -926,3 +926,44 @@ aggregations: } } ] + + + - database: {{ mongodb_query_exporter_mongodb_sc_db_name }} + collection: files + metrics: + - name: sc_files_security_check_last_seven_days + type: gauge + help: 'Legacy files scan results in the last 7 days' + value: total + overrideEmpty: true + emptyValue: 0 + labels: [status] + constLabels: {} + mode: pull + pipeline: | + [ + { "$match": { "isDirectory": false, "securityCheck": { "$exists": true } } }, + { + "$match": { + "$expr": { + "$gte": [ + "$createdAt", + { "$subtract": ["$$NOW", 604800000] } + ] + } + } + }, + { + "$group": { + "_id": "$securityCheck.status", + "total": { "$sum": 1 } + } + }, + { + "$project": { + "_id": 0, + "status": "$_id", + "total": "$total" + } + } + ]