Instrument usage ping: Count number of enabled integrations per project as histogram
requested to merge 263532-instrument-usage-ping-count-number-of-enabled-integrations-per-project into master
What does this MR do?
This MR create a usage ping histogram of all active alert management http integrations across projects without exposing individual project ids.
Example: amount of enabled integrations => amount of projects
.
{
"usage_activity_by_stage": {
"monitor": {
"projects_with_enabled_alert_integrations_histogram": {
"1": 17,
"2": 13,
"3": 5,
"7": 2
}
}
}
}
In amount of projects == 0
).
Solves #263532 (closed).
The follow-up #323949 takes care of batching histograms.
database query plan
See https://console.postgres.ai/shared/2a604d4c-d41f-41c9-8553-628b9ba0e2b7
WITH "count_cte" AS (
SELECT
count(*) AS count_grouped
FROM
"alert_management_http_integrations"
WHERE
"alert_management_http_integrations"."active" = TRUE
GROUP BY
"alert_management_http_integrations"."project_id"
)
SELECT
WIDTH_BUCKET("count_cte"."count_grouped", 1, 100, 99) AS buckets,
"count_cte"."count"
FROM
"count_cte"
GROUP BY
buckets
ORDER BY
buckets;
Sort (cost=54.74..55.24 rows=200 width=12) (actual time=12.093..12.095 rows=3 loops=1)
Sort Key: (width_bucket((count_cte.count_grouped)::double precision, '1'::double precision, '100'::double precision, 99))
Sort Method: quicksort Memory: 25kB
Buffers: shared hit=100 read=11 dirtied=3
I/O Timings: read=8.838
CTE count_cte
-> Aggregate (cost=0.28..27.50 rows=553 width=16) (actual time=3.208..11.326 rows=555 loops=1)
Group Key: alert_management_http_integrations.project_id
Buffers: shared hit=97 read=11 dirtied=3
I/O Timings: read=8.838
-> Index Only Scan using index_http_integrations_on_active_and_project_and_endpoint on public.alert_management_http_integrations (cost=0.28..19.18 rows=560 width=8) (actual time=3.199..10.858 rows=562 loops=1)
Heap Fetches: 157
Buffers: shared hit=97 read=11 dirtied=3
I/O Timings: read=8.838
-> HashAggregate (cost=16.59..19.59 rows=200 width=12) (actual time=12.051..12.053 rows=3 loops=1)
Group Key: width_bucket((count_cte.count_grouped)::double precision, '1'::double precision, '100'::double precision, 99)
Buffers: shared hit=97 read=11 dirtied=3
I/O Timings: read=8.838
-> CTE Scan on count_cte (cost=0.00..13.83 rows=553 width=36) (actual time=3.228..11.803 rows=555 loops=1)
Buffers: shared hit=97 read=11 dirtied=3
I/O Timings: read=8.838
Screenshots (strongly suggested)
Admin Area > Metrics and profiling Overall | Admin Area > Metrics and profiling Monthly |
---|---|
Does this MR meet the acceptance criteria?
Conformity
-
📋 Does this MR need a changelog?-
I have included a changelog entry because it's a new usage data metric - [-] I have not included a changelog entry because _____.
-
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides - [-] Separation of EE specific content
Related to #263532 (closed)
Edited by Peter Leitzen