debian-mirror-gitlab/lib/gitlab/prometheus/query_variables.rb

32 lines
974 B
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
module Gitlab
module Prometheus
module QueryVariables
2020-06-23 00:09:42 +05:30
# start_time and end_time should be Time objects.
def self.call(environment, start_time: nil, end_time: nil)
2019-02-15 15:39:39 +05:30
{
2020-06-23 00:09:42 +05:30
__range: range(start_time, end_time),
2019-02-15 15:39:39 +05:30
ci_environment_slug: environment.slug,
2019-10-12 21:52:04 +05:30
kube_namespace: environment.deployment_namespace || '',
2020-04-08 14:13:33 +05:30
environment_filter: %{container_name!="POD",environment="#{environment.slug}"},
ci_project_name: environment.project.name,
ci_project_namespace: environment.project.namespace.name,
ci_project_path: environment.project.full_path,
ci_environment_name: environment.name
2019-02-15 15:39:39 +05:30
}
end
2020-06-23 00:09:42 +05:30
private
def self.range(start_time, end_time)
if start_time && end_time
range_seconds = (end_time - start_time).to_i
"#{range_seconds}s"
end
end
private_class_method :range
2019-02-15 15:39:39 +05:30
end
end
end