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.


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

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


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

def self.transform_reactive_result(result)
  result
end

Instance Method Details

#query(*args) ⇒ Object

Raises:

  • (NotImplementedError)

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

def query(*args)
  raise NotImplementedError
end

#raw_cpu_usage_query(environment_slug) ⇒ Object


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

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


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

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