Skip to content

Add filter to search incidents with selected alert monitoring tool

What does this MR do and why?

This MR adds new filter to allow users to search incidents with selected alert monitoring tool and updates GraphQL API to support new filter.

In scope of this MR we are also adding new index to improve performance of new query.

Migrations

⋊> env VERBOSE=true bundle exec rake db:migrate:down VERSION=20211021013336

== 20211021013336 AddIndexToAlertManagementAlertsMonitoringTool: reverting ====
-- transaction_open?()
   -> 0.0000s
-- indexes(:alert_management_alerts)
   -> 0.0052s
-- execute("SET statement_timeout TO 0")
   -> 0.0007s
-- remove_index(:alert_management_alerts, {:algorithm=>:concurrently, :name=>"index_alert_management_alerts_on_monitoring_tool"})
   -> 0.0081s
-- execute("RESET statement_timeout")
   -> 0.0009s
== 20211021013336 AddIndexToAlertManagementAlertsMonitoringTool: reverted (0.0226s) 

⋊> env VERBOSE=true bundle exec rake db:migrate:up VERSION=20211021013336

== 20211021013336 AddIndexToAlertManagementAlertsMonitoringTool: migrating ====
-- transaction_open?()
   -> 0.0000s
-- index_exists?(:alert_management_alerts, [:issue_id, :monitoring_tool], {:name=>"index_alert_management_alerts_on_monitoring_tool", :where=>"(monitoring_tool != 'Cilium')", :algorithm=>:concurrently})
   -> 0.0063s
-- execute("SET statement_timeout TO 0")
   -> 0.0012s
-- add_index(:alert_management_alerts, [:issue_id, :monitoring_tool], {:name=>"index_alert_management_alerts_on_monitoring_tool", :where=>"(monitoring_tool != 'Cilium')", :algorithm=>:concurrently})
   -> 0.0101s
-- execute("RESET statement_timeout")
   -> 0.0011s
== 20211021013336 AddIndexToAlertManagementAlertsMonitoringTool: migrated (0.0221s) 

Queries

SELECT "issues".* FROM "issues" 
INNER JOIN "alert_management_alerts" ON "alert_management_alerts"."issue_id" = "issues"."id"
WHERE "issues"."project_id" = 23619647 AND "issues"."issue_type" = 1
AND "alert_management_alerts"."monitoring_tool" != 'Cilium'
LIMIT 100;

Without index

Time: 101.858 ms
  - planning: 0.655 ms
  - execution: 101.203 ms
    - I/O read: 97.773 ms
    - I/O write: 0.000 ms

Shared buffers:
  - hits: 990 (~7.70 MiB) from the buffer pool
  - reads: 377 (~2.90 MiB) from the OS file cache, including disk I/O
  - dirtied: 6 (~48.00 KiB)
  - writes: 0

https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/7207/commands/25529

Index

exec CREATE INDEX index_alert_management_alerts_on_monitoring_tool ON alert_management_alerts USING btree (project_id, monitoring_tool, issue_id) WHERE issue_id IS NOT NULL AND monitoring_tool != 'Cilium';

The query has been executed. Duration: 1.355 s

With new index

Time: 7.588 ms
  - planning: 5.974 ms
  - execution: 1.614 ms
    - I/O read: 0.000 ms
    - I/O write: 0.000 ms

Shared buffers:
  - hits: 1367 (~10.70 MiB) from the buffer pool
  - reads: 0 from the OS file cache, including disk I/O
  - dirtied: 0
  - writes: 0

https://postgres.ai/console/gitlab/gitlab-production-tunnel-pg12/sessions/7207/commands/25531

How to set up and validate locally

  1. Create new project
  2. Using factories (FactoryBot) create new Alerts for with monitoring tool for Prometheus and Cilium.
  3. Create incident issues from these alerts (you can use UI for this).
  4. Go to /-/graphql-explorer to verify if new filter works as expected

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #323276 (closed)

Edited by Alan (Maciej) Paruszewski

Merge request reports

Loading