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
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/fluent/plugin/in_prometheus_pull.rb', line 69 def configure(conf) compat_parameters_convert(conf, :parser) parser_config = conf.elements('parse').first # raise Fluent::ConfigError, '<parse> section is required.' unless parser_config unless parser_config parser_config ||= Fluent::Config::Element.new('parse', '', { '@type' => 'prometheus_text' }, []) conf.elements.append(parser_config) end super @parser = parser_create(conf: parser_config) end |
#pull ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/fluent/plugin/in_prometheus_pull.rb', line 90 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 record[event_url_key] = url if event_url_key router.emit(tag, time, record) rescue StandardError => e error("error #{e}, while emitting #{record}") end end end end |
#start ⇒ Object
84 85 86 87 88 |
# File 'lib/fluent/plugin/in_prometheus_pull.rb', line 84 def start super timer_execute(:in_prometheus_pull_timer, @interval, &method(:pull)) end |