From 56ca8b81b1c5a22041f903509da8d1208313d59e Mon Sep 17 00:00:00 2001 From: Roman Blanco Date: Wed, 22 Jan 2025 11:23:54 +0000 Subject: [PATCH] feat(floorist): add HMS metrics for tested systems This should collect data in such format: org_id | systems 12345678 | [{"system_id": "uuid1", "updated_at": "timestamp1"}, {"system_id": "uuid2", "updated_at": "timestamp2"}] --- deploy/clowdapp.yaml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/deploy/clowdapp.yaml b/deploy/clowdapp.yaml index be4ce7b93..ff1868388 100644 --- a/deploy/clowdapp.yaml +++ b/deploy/clowdapp.yaml @@ -576,6 +576,41 @@ objects: INNER JOIN "canonical_profiles" ON "canonical_profiles"."id" = "tailorings"."profile_id" INNER JOIN "accounts" ON "accounts"."id" = "v2_policies"."account_id"; +- apiVersion: metrics.console.redhat.com/v1alpha1 + kind: FloorPlan + metadata: + name: compliance-hms + spec: + database: + secretName: ${FLOORIST_DB_SECRET_NAME} + objectStore: + secretName: ${FLOORIST_HMS_BUCKET_SECRET_NAME} + logLevel: ${FLOORIST_LOGLEVEL} + suspend: ${{FLOORIST_SUSPEND}} + queries: + - prefix: hms_analytics/compliance/systems + chunksize: 200000 + query: >- + WITH "tested_systems" AS ( + SELECT "policy_systems"."system_id", MAX("v2_test_results"."updated_at") AS "updated_at" + FROM "policy_systems" + JOIN "v2_test_results" ON "v2_test_results"."system_id" = "policy_systems"."system_id" + GROUP BY "policy_systems"."system_id" + ) + SELECT + "policies"."account_id" AS "org_id", + JSON_AGG( + JSON_BUILD_OBJECT( + 'system_id', "policy_systems"."system_id"::text, + 'updated_at', "tested_systems"."updated_at" + ) + ) AS "systems" + FROM "policies" + INNER JOIN "policy_systems" ON "policy_systems"."policy_id" = "policies"."id" + LEFT JOIN "tested_systems" ON "tested_systems"."system_id" = "policy_systems"."system_id" + WHERE "tested_systems"."updated_at" IS NOT NULL + GROUP BY "policies"."account_id"; + - apiVersion: v1 kind: Secret type: Opaque