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

Inherits:
Prometheus::ApiClient::Client 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 Prometheus::ApiClient::Client

#faraday_headers, #faraday_options, #faraday_proxy, #faraday_verify_ssl, #get, #label, #run_command, #targets, #update_query

Constructor Details

#initialize(options = {}) ⇒ Container

Returns a new instance of Container.



66
67
68
69
70
71
72
73
74
# File 'lib/prometheus/api_client/cadvisor.rb', line 66

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

  @labels = "job=\"kubernetes-cadvisor\",namespace=\"#{namespace}\"," \
    "pod_name=\"#{pod_name}\",container_name=\"#{container_name}\""
  super(options)
end

Instance Method Details

#query(options) ⇒ Object



76
77
78
79
# File 'lib/prometheus/api_client/cadvisor.rb', line 76

def query(options)
  options[:query] = update_query(options[:query], @labels)
  super(options)
end

#query_range(options) ⇒ Object



81
82
83
84
# File 'lib/prometheus/api_client/cadvisor.rb', line 81

def query_range(options)
  options[:query] = update_query(options[:query], @labels)
  super(options)
end