Class: Prometheus::ApiClient::Cadvisor::Container

Inherits:
CadvisorClient show all
Defined in:
lib/prometheus/api_client/cadvisor.rb

Overview

A client with special labels for container cadvisor metrics

Constant Summary

Constants inherited from Prometheus::ApiClient::Client

Prometheus::ApiClient::Client::DEFAULT_ARGS

Instance Method Summary collapse

Methods inherited from CadvisorClient

#get, #update_query

Methods inherited from Prometheus::ApiClient::Client

#faraday_headers, #faraday_options, #faraday_proxy, #faraday_request, #faraday_ssl, #get, #label, #query, #query_range, #run_command, #targets

Constructor Details

#initialize(options = {}) ⇒ Container

Returns a new instance of Container.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/prometheus/api_client/cadvisor.rb', line 71

def initialize(options = {})
  container_name = options[:container_name]
  pod_name = options[:pod_name]
  namespace = options[:namespace] || 'default'

  # if no container_name is given, assume we want data on all containers
  @labels = if container_name
              'job="kubernetes-cadvisor",' \
              "namespace=\"#{namespace}\",pod_name=\"#{pod_name}\"," \
              "container_name=\"#{container_name}\""
            else
              'job="kubernetes-cadvisor",container_name!="POD"'
            end

  super(options)
end