Class: Fluent::Plugin::PrometheusPullInput
- Inherits:
-
Input
- Object
- Input
- Fluent::Plugin::PrometheusPullInput
- Defined in:
- lib/fluent/plugin/in_prometheus_pull.rb
Overview
input / source pull prometheus http endpoint
Instance Method Summary collapse
Instance Method Details
#configure(conf) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/fluent/plugin/in_prometheus_pull.rb', line 66 def configure(conf) compat_parameters_convert(conf, :parser) parser_config = conf.elements('parse').first # raise Fluent::ConfigError, '<parse> section is required.' unless parser_config parser_config ||= Fluent::Config::Element.new('parse', '', [], { '@type' => 'prometheus_text' }) super @parser = parser_create(conf: parser_config) end |
#pull ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/fluent/plugin/in_prometheus_pull.rb', line 84 def pull urls.each do |url| pull_time = Fluent::EventTime.now raw_metrics = fetch(url) parser.parse(raw_metrics) do |time, record| begin time ||= pull_time router.emit(tag, time, record) rescue StandardError => e error("error #{e}, while emitting #{record}") end end end end |
#start ⇒ Object
78 79 80 81 82 |
# File 'lib/fluent/plugin/in_prometheus_pull.rb', line 78 def start super timer_execute(:in_prometheus_pull, @interval, &method(:pull)) end |