Welcome to mirror list, hosted at ThFree Co, Russian Federation.

environment_query.rb « queries « prometheus « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 01d756d7284e8cfe53cca429b79ce5d9e8c5cdcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Gitlab::Prometheus::Queries
  class EnvironmentQuery < BaseQuery
    def query(environment_id)
      environment = Environment.find_by(id: environment_id)
      environment_slug = environment.slug
      timeframe_start = 8.hours.ago.to_f
      timeframe_end = Time.now.to_f

      memory_query = raw_memory_usage_query(environment_slug)
      cpu_query = raw_cpu_usage_query(environment_slug)

      {
        memory_values: client_query_range(memory_query, start: timeframe_start, stop: timeframe_end),
        memory_current: client_query(memory_query, time: timeframe_end),
        cpu_values: client_query_range(cpu_query, start: timeframe_start, stop: timeframe_end),
        cpu_current: client_query(cpu_query, time: timeframe_end)
      }
    end
  end
end