2020-04-22 19:07:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Prometheus
|
|
|
|
module Queries
|
|
|
|
class ValidateQuery < BaseQuery
|
|
|
|
def query(query)
|
|
|
|
client_query(query)
|
|
|
|
{ valid: true }
|
2021-12-11 22:18:48 +05:30
|
|
|
rescue Gitlab::PrometheusClient::QueryError, Gitlab::PrometheusClient::ConnectionError => ex
|
2020-04-22 19:07:51 +05:30
|
|
|
{ valid: false, error: ex.message }
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.transform_reactive_result(result)
|
|
|
|
result[:query] = result.delete :data
|
|
|
|
result
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|