Class: Gitlab::Prometheus::Queries::BaseQuery

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ BaseQuery

Returns a new instance of BaseQuery.


18
19
20
# File 'lib/gitlab/prometheus/queries/base_query.rb', line 18

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client


7
8
9
# File 'lib/gitlab/prometheus/queries/base_query.rb', line 7

def client
  @client
end

Class Method Details

.transform_reactive_result(result) ⇒ Object


26
27
28
# File 'lib/gitlab/prometheus/queries/base_query.rb', line 26

def self.transform_reactive_result(result)
  result
end

Instance Method Details

#query(*args) ⇒ Object

Raises:

  • (NotImplementedError)

22
23
24
# File 'lib/gitlab/prometheus/queries/base_query.rb', line 22

def query(*args)
  raise NotImplementedError
end

#raw_cpu_usage_query(environment_slug) ⇒ Object


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

def raw_cpu_usage_query(environment_slug)
  %{avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="#{environment_slug}"}[2m])) * 100}
end

#raw_memory_usage_query(environment_slug) ⇒ Object


10
11
12
# File 'lib/gitlab/prometheus/queries/base_query.rb', line 10

def raw_memory_usage_query(environment_slug)
  %{avg(container_memory_usage_bytes{container_name!="POD",environment="#{environment_slug}"}) / 2^20}
end