Class: Gitlab::Prometheus::Queries::ValidateQuery

Inherits:
BaseQuery
  • Object
show all
Defined in:
lib/gitlab/prometheus/queries/validate_query.rb

Instance Attribute Summary

Attributes inherited from BaseQuery

#client

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseQuery

#initialize, #raw_cpu_usage_query, #raw_memory_usage_query

Constructor Details

This class inherits a constructor from Gitlab::Prometheus::Queries::BaseQuery

Class Method Details

.transform_reactive_result(result) ⇒ Object


14
15
16
17
# File 'lib/gitlab/prometheus/queries/validate_query.rb', line 14

def self.transform_reactive_result(result)
  result[:query] = result.delete :data
  result
end

Instance Method Details

#query(query) ⇒ Object


7
8
9
10
11
12
# File 'lib/gitlab/prometheus/queries/validate_query.rb', line 7

def query(query)
  client_query(query)
  { valid: true }
rescue Gitlab::PrometheusClient::QueryError, Gitlab::PrometheusClient::ConnectionError => ex
  { valid: false, error: ex.message }
end