Add metrics dashboard annotations finder
What does this MR do?
In order to be able to expose annotations to user we need to add finder class, which will be responsible for selecting them
This MR is a part a of implementation #211330 (closed)
Database
query:
SELECT "metrics_dashboard_annotations".* FROM "metrics_dashboard_annotations" WHERE "metrics_dashboard_annotations"."environment_id" = 1 AND "metrics_dashboard_annotations"."starting_at" >= '2020-04-10 11:57:24.262228' AND "metrics_dashboard_annotations"."starting_at" <= '2020-04-10 12:06:24.262243' AND "metrics_dashboard_annotations"."dashboard_path" = 'config/prometheus/common_metrics.yml';
local development seeded with 1_000_000 rows:
gitlabhq_development=# select count(*) from metrics_dashboard_annotations;
count
---------
1000002
(1 row)
EXPLAIN (ANALYZE, BUFFERS) SELECT "metrics_dashboard_annotations".* FROM "metrics_dashboard_annotations" WHERE "metrics_dashboard_annotations"."environment_id" = 2 AND "metrics_dashboard_annotations"."starting_at" >= '2020-04-10 11:57:24.262228' AND "metrics_dashboard_annotations"."starting_at" <= '2020-04-13 12:06:24.262243' AND "metrics_dashboard_annotations"."dashboard_path" = 'dashboard_100';
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Index Scan using index_metrics_dashboard_annotations_on_environment_id_and_3_col on metrics_dashboard_annotations (cost=0.42..64.92 rows=62 width=617) (actual time=0.040..0.270 rows=60 loops=1)
Index Cond: ((environment_id = 2) AND ((dashboard_path)::text = 'dashboard_100'::text) AND (starting_at >= '2020-04-10 11:57:24.262228+02'::timestamp with time zone) AND (starting_at <= '2020-04-13 12:06:24.262243+02'::timestamp with time zone))
Buffers: shared hit=64
Planning time: 0.139 ms
Execution time: 0.307 ms
gitlabhq_development=# EXPLAIN (ANALYZE, BUFFERS) SELECT "metrics_dashboard_annotations".* FROM "metrics_dashboard_annotations" WHERE "metrics_dashboard_annotations"."environment_id" = 5 AND "metrics_dashboard_annotations"."starting_at" >= '2020-04-10 11:57:24.262228' AND "metrics_dashboard_annotations"."starting_at" <= '2020-04-13 12:06:24.262243' AND "metrics_dashboard_annotations"."dashboard_path" = 'dashboard_200';
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Index Scan using index_metrics_dashboard_annotations_on_environment_id_and_3_col on metrics_dashboard_annotations (cost=0.42..66.97 rows=64 width=617) (actual time=0.038..0.293 rows=66 loops=1)
Index Cond: ((environment_id = 5) AND ((dashboard_path)::text = 'dashboard_200'::text) AND (starting_at >= '2020-04-10 11:57:24.262228+02'::timestamp with time zone) AND (starting_at <= '2020-04-13 12:06:24.262243+02'::timestamp with time zone))
Buffers: shared hit=70
Planning time: 0.123 ms
Execution time: 0.320 ms
(5 rows)
From stg:
Index Scan using index_metrics_dashboard_annotations_on_environment_id_and_3_col on metrics_dashboard_annotations (cost=0.12..3.15 rows=1 width=1104) (actual time=0.019..0.019 rows=0 loops=1)
Index Cond: ((environment_id = 1) AND ((dashboard_path)::text = 'config/prometheus/common_metrics.yml'::text) AND (starting_at >= '2020-04-10 11:57:24.262228+00'::timestamp with time zone) AND (starting_at <= '2020-04-10 12:06:24.262243+00'::timestamp with time zone))
Buffers: shared hit=4
Planning time: 4.412 ms
Execution time: 0.067 ms
(5 rows)
production:
Index Scan using index_metrics_dashboard_annotations_on_environment_id_and_3_col on metrics_dashboard_annotations (cost=0.12..3.15 rows=1 width=1104) (actual time=0.026..0.026 rows=0 loops=1)
Index Cond: ((environment_id = 1) AND ((dashboard_path)::text = 'config/prometheus/common_metrics.yml'::text) AND (starting_at >= '2020-04-10 11:57:24.262228+00'::timestamp with time zone) AND (starting_at <= '2020-04-10 12:06:24.262243+00'::timestamp with time zone))
Buffers: shared hit=4
Planning time: 2.981 ms
Execution time: 0.069 ms
query:
SELECT "metrics_dashboard_annotations".* FROM "metrics_dashboard_annotations" WHERE "metrics_dashboard_annotations"."environment_id" = 1 AND "metrics_dashboard_annotations"."dashboard_path" = 'config/prometheus/common_metrics.yml';
staging:
Index Scan using index_metrics_dashboard_annotations_on_environment_id_and_3_col on metrics_dashboard_annotations (cost=0.12..3.14 rows=1 width=1104) (actual time=0.007..0.007 rows=0 loops=1)
Index Cond: ((environment_id = 1) AND ((dashboard_path)::text = 'config/prometheus/common_metrics.yml'::text))
Buffers: shared hit=1
Planning time: 0.171 ms
Execution time: 0.041 ms
(5 rows)
prod:
Index Scan using index_metrics_dashboard_annotations_on_environment_id_and_3_col on metrics_dashboard_annotations (cost=0.12..3.15 rows=1 width=1104) (actual time=0.019..0.019 rows=0 loops=1)
Index Cond: ((environment_id = 1) AND ((dashboard_path)::text = 'config/prometheus/common_metrics.yml'::text) AND (starting_at >= '2020-04-10 11:57:24.262228+00'::timestamp with time zone) AND (starting_at <= '2020-04-10 12:06:24.262243+00'::timestamp with time zone))
Buffers: shared hit=4
Planning time: 0.687 ms
Execution time: 0.059 ms
Does this MR meet the acceptance criteria?
Conformity
- [ ] Changelog entry //only developer facing change
- [-] 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