Skip to content

Commit

Permalink
feat(floorist): add HMS metrics for tested systems
Browse files Browse the repository at this point in the history
This should collect data in such format:

org_id             | systems
12345678           | [{"system_id": "uuid1", "updated_at": "timestamp1"}, {"system_id": "uuid2", "updated_at": "timestamp2"}]
  • Loading branch information
romanblanco committed Jan 22, 2025
1 parent 0e14851 commit 85f820e
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions deploy/clowdapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 85f820e

Please sign in to comment.