Class: Gitlab::Database::HealthStatus::Indicators::PrometheusAlertIndicator
- Inherits:
-
Object
- Object
- Gitlab::Database::HealthStatus::Indicators::PrometheusAlertIndicator
- Includes:
- Utils::StrongMemoize
- Defined in:
- lib/gitlab/database/health_status/indicators/prometheus_alert_indicator.rb
Direct Known Subclasses
Constant Summary collapse
- ALERT_CONDITIONS =
{ above: :above, below: :below }.freeze
Instance Method Summary collapse
- #evaluate ⇒ Object
-
#initialize(context) ⇒ PrometheusAlertIndicator
constructor
A new instance of PrometheusAlertIndicator.
Constructor Details
#initialize(context) ⇒ PrometheusAlertIndicator
Returns a new instance of PrometheusAlertIndicator.
15 16 17 |
# File 'lib/gitlab/database/health_status/indicators/prometheus_alert_indicator.rb', line 15 def initialize(context) @gitlab_schema = context.gitlab_schema.to_sym end |
Instance Method Details
#evaluate ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gitlab/database/health_status/indicators/prometheus_alert_indicator.rb', line 19 def evaluate return Signals::NotAvailable.new(self.class, reason: 'indicator disabled') unless enabled? = return unknown_signal() if .present? sli = fetch_sli(sli_query) return unknown_signal("#{indicator_name} can not be calculated") unless sli.present? if alert_condition == ALERT_CONDITIONS[:above] ? sli.to_f > slo.to_f : sli.to_f < slo.to_f Signals::Normal.new(self.class, reason: "#{indicator_name} SLI condition met") else Signals::Stop.new(self.class, reason: "#{indicator_name} SLI condition not met") end end |