lib/prometheus/api_client/cadvisor.rb in prometheus-api-client-0.2.10 vs lib/prometheus/api_client/cadvisor.rb in prometheus-api-client-0.3.1
- old
+ new
@@ -9,25 +9,23 @@
# With special labels for the cadvisor job.
module Cadvisor
# Create a Prometheus API client:
#
# @param [Hash] options
- # @option options [Hash] :url String base URL.
+ # @option options [String] :url Server base URL.
# @option options [Hash] :params URI query unencoded key/value pairs.
# @option options [Hash] :headers Unencoded HTTP header key/value pairs.
# @option options [Hash] :request Request options.
# @option options [Hash] :ssl SSL options.
# @option options [Hash] :proxy Proxy options.
#
# A default client is created if options is omitted.
class Node < Client
- def initialize(instance:, **options)
- region = options[:region] || 'infra'
- zone = options[:zone] || 'default'
+ def initialize(options = {})
+ instance = options[:instance]
- @labels = "job=\"kubernetes-cadvisor\",region=\"#{region}\"," \
- "zone=\"#{zone}\",instance=\"#{instance}\""
+ @labels = "job=\"kubernetes-cadvisor\",instance=\"#{instance}\""
super(options)
end
def query(options)
options[:query] = update_query(options[:query], @labels)
@@ -40,17 +38,15 @@
end
end
# A client with special labels for pod cadvisor metrics
class Pod < Client
- def initialize(pod_name:, **options)
+ def initialize(options = {})
+ pod_name = options[:pod_name]
namespace = options[:namespace] || 'default'
- region = options[:region] || 'infra'
- zone = options[:zone] || 'default'
- @labels = "job=\"kubernetes-cadvisor\",region=\"#{region}\"," \
- "zone=\"#{zone}\",namespace=\"#{namespace}\"," \
+ @labels = "job=\"kubernetes-cadvisor\",namespace=\"#{namespace}\"," \
"pod_name=\"#{pod_name}\",container_name=\"POD\""
super(options)
end
def query(options)
@@ -64,16 +60,15 @@
end
end
# A client with special labels for container cadvisor metrics
class Container < Client
- def initialize(container_name:, pod_name:, **options)
+ def initialize(options = {})
+ container_name = args[:container_name]
+ pod_name = args[:pod_name]
namespace = args[:namespace] || 'default'
- region = options[:region] || 'infra'
- zone = options[:zone] || 'default'
- @labels = "job=\"kubernetes-cadvisor\",region=\"#{region}\"," \
- "zone=\"#{zone}\",namespace=\"#{namespace}\"," \
+ @labels = "job=\"kubernetes-cadvisor\",namespace=\"#{namespace}\"," \
"pod_name=\"#{pod_name}\",container_name=\"#{container_name}\""
super(options)
end
def query(options)