Include joined relations into metrics name suggetions
Background
During research work for new naming convention for database sourced metrics, we've decided to use underlying SQL as source for metric name. In order to help apply new naming convention onto metrics, we've decided that metrics names should be generated automatically.
PoC of metric names generator !54077 (closed)
Goal
Extend name suggestion feature with inclusion of joined relations.
To base format operation_target_having_<adjectives describing>_source
or operation_<adjectives describing>_target
joined relations should be included be using following rules:
- Joined relations included into metric name, should persist structure of joined relations, meaning when to source A joined was relation B, and than to B was joined relation C (eg:
Select a.id FROM a JOIN b ON b.a_id = a.id JOIN c on c.b_id = b.id
) than name should reflect that - When counted is foreign key of other relation eg
b.d_id
we should translate it as itd
relation was joined into the query - Conjunction should be used in consistent manner in order to help express joined relation structure, so use different conjunction for different levels relations eg:
Select count(a.id) FROM a JOIN b ON b.a_id = a.id JOIN c ON c.b_id = b.id JOIN d ON d.a_id = a.id
should usewith
conjunction forb
andd
relations andincluding
forc
. count_a_with_b_including_c_with_d
Example: For metric collected with query:
SELECT COUNT(DISTINCT "deployments"."environment_id") FROM "clusters_applications_ingress" INNER JOIN "clusters" ON "clusters"."id" = "clusters_applications_ingress"."cluster_id" INNER JOIN "deployments" ON "deployments"."cluster_id" = "clusters"."id" WHERE "clusters_applications_ingress"."modsecurity_enabled" IS NULL AND "clusters"."enabled" = TRUE AND "deployments"."status" = 2
resulting suggested name after including joins should look like:
count_distinct_environments_having_<adjectives describing>_deployments_with_<adjectives describing>_clusters_having_<adjectives describing>_clusters_applications_ingress