summaryrefslogtreecommitdiff
path: root/lib/gitlab/prometheus/query_variables.rb
blob: dca09aef47df1ec2a53ebe3a5192e6cf5649c70b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

module Gitlab
  module Prometheus
    module QueryVariables
      def self.call(environment)
        deployment_platform = environment.deployment_platform
        namespace = deployment_platform&.namespace_for(environment.project) ||
          deployment_platform&.actual_namespace || ''

        {
          ci_environment_slug: environment.slug,
          kube_namespace: namespace,
          environment_filter: %{container_name!="POD",environment="#{environment.slug}"}
        }
      end
    end
  end
end