Count number of projects with active Prometheus Service
What does this MR do?
Implements #263521 (closed)
Adds projects_with_prometheus_service_enabled
usage ping.
To count the number of projects with Prometheus Service activated.
DB Queries
Generated by
::Gitlab::UsageData.count(::PrometheusService.active)
SELECT MIN("services"."id")
FROM "services"
WHERE "services"."type" = 'PrometheusService' AND "services"."active" = TRUE
-
#database-lab
query: https://gitlab.slack.com/archives/CLJMDRD8C/p1604936243258600 - Explain: https://explain.depesz.com/s/hp2CX
SELECT MAX("services"."id")
FROM "services"
WHERE "services"."type" = 'PrometheusService' AND "services"."active" = TRUE
-
#database-lab
query: https://gitlab.slack.com/archives/CLJMDRD8C/p1604936341261000 - Explain: https://explain.depesz.com/s/hTir
SELECT COUNT("services"."id")
FROM "services"
WHERE "services"."type" = 'PrometheusService' AND
"services"."active" = TRUE AND
"services"."project_id" IS NOT NULL AND
"services"."id" >= 12 AND
"services"."id" < 100000
-
#database-lab
query: https://gitlab.slack.com/archives/CLJMDRD8C/p1605007020398500 - Explain https://explain.depesz.com/s/lFae
- Performs better than the query without
"project_id" IS NOT NULL
because it usesindex_services_on_type_id_when_active_and_project_id_not_null
index. For comparison:-
#database-lab
query: https://gitlab.slack.com/archives/CLJMDRD8C/p1604936417263300 - Explain https://explain.depesz.com/s/b8DK
-
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry - [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team
Edited by Vitali Tatarintev