Class: Projects::Prometheus::AlertsFinder
- Inherits:
-
Object
- Object
- Projects::Prometheus::AlertsFinder
- Defined in:
- app/finders/projects/prometheus/alerts_finder.rb
Overview
Find Prometheus alerts by project
, environment
, id
, or any combo thereof.
Optionally filter by metric
.
Arguments:
params:
project: Project | integer
environment: Environment | integer
metric: PrometheusMetric | integer
Instance Method Summary collapse
-
#execute ⇒ ActiveRecord::Relation<PrometheusAlert>
Find all matching alerts.
-
#initialize(params = {}) ⇒ AlertsFinder
constructor
A new instance of AlertsFinder.
Constructor Details
#initialize(params = {}) ⇒ AlertsFinder
Returns a new instance of AlertsFinder.
16 17 18 19 20 21 22 23 |
# File 'app/finders/projects/prometheus/alerts_finder.rb', line 16 def initialize(params = {}) unless params[:project] || params[:environment] || params[:id] raise ArgumentError, 'Please provide one or more of the following params: :project, :environment, :id' end @params = params end |
Instance Method Details
#execute ⇒ ActiveRecord::Relation<PrometheusAlert>
Find all matching alerts
28 29 30 31 32 33 34 |
# File 'app/finders/projects/prometheus/alerts_finder.rb', line 28 def execute relation = by_project(PrometheusAlert) relation = by_environment(relation) relation = by_metric(relation) relation = by_id(relation) ordered(relation) end |