Class: Clusters::Integrations::PrometheusHealthCheckService
- Inherits:
-
Object
- Object
- Clusters::Integrations::PrometheusHealthCheckService
- Includes:
- Gitlab::Routing, Gitlab::Utils::StrongMemoize
- Defined in:
- app/services/clusters/integrations/prometheus_health_check_service.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(cluster) ⇒ PrometheusHealthCheckService
constructor
A new instance of PrometheusHealthCheckService.
Methods included from Gitlab::Routing
add_helpers, includes_helpers, redirect_legacy_paths, url_helpers
Methods included from Gitlab::Utils::StrongMemoize
#clear_memoization, #strong_memoize, #strong_memoized?
Constructor Details
#initialize(cluster) ⇒ PrometheusHealthCheckService
Returns a new instance of PrometheusHealthCheckService.
9 10 11 12 |
# File 'app/services/clusters/integrations/prometheus_health_check_service.rb', line 9 def initialize(cluster) @cluster = cluster @logger = Gitlab::AppJsonLogger.build end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/services/clusters/integrations/prometheus_health_check_service.rb', line 14 def execute raise 'Invalid cluster type. Only project types are allowed.' unless @cluster.project_type? return unless prometheus_integration.enabled project = @cluster.clusterable @logger.info( message: 'Prometheus health check', cluster_id: @cluster.id, newly_unhealthy: became_unhealthy?, currently_healthy: currently_healthy?, was_healthy: was_healthy? ) send_notification(project) if became_unhealthy? prometheus_integration.update_columns(health_status: current_health_status) if health_changed? end |