Class: Fluent::Plugin::KubernetesMetricsInput

Inherits:
Input
  • Object
show all
Defined in:
lib/fluent/plugin/in_kubernetes_metrics.rb

Instance Method Summary collapse

Instance Method Details

#closeObject



105
106
107
108
109
# File 'lib/fluent/plugin/in_kubernetes_metrics.rb', line 105

def close
  @watchers.each &:finish if @watchers

  super
end

#configure(conf) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/fluent/plugin/in_kubernetes_metrics.rb', line 77

def configure(conf)
  super

  @kubelet_address = "[#{@kubelet_address}]" if @kubelet_address =~ Resolv::IPv6::Regex

  if @use_rest_client
    raise Fluentd::ConfigError, 'node_name is required' if @node_name.nil? || @node_name.empty?
  else
    raise Fluentd::ConfigError, 'node_names is required' if @node_names.nil? || @node_names.empty?
  end

  parse_tag
  initialize_client
end

#startObject



92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/fluent/plugin/in_kubernetes_metrics.rb', line 92

def start
  super

  timer_execute :metric_scraper, @interval, &method(:scrape_metrics)
  timer_execute :cadvisor_metric_scraper, @interval, &method(:scrape_cadvisor_metrics)
  # It is done to optionally fetch from 'stats' for k8s version <1.21
  if is_stats_endpoint_available?
    timer_execute :stats_metric_scraper, @interval, &method(:scrape_stats_metrics)
  else
    log.info "'/stats' endpoint is not available. It has been deprecated since k8s v1.15, disabled since v1.18, and removed in v1.21 and onwards"
  end
end