Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing "type" in metric block fails if using Ruby syntax #149

Open
jonmoter opened this issue Apr 16, 2020 · 1 comment
Open

Parsing "type" in metric block fails if using Ruby syntax #149

jonmoter opened this issue Apr 16, 2020 · 1 comment

Comments

@jonmoter
Copy link

I'm using the ruby-style syntax to define fluentd configuration. I have a config block that looks like:

  match('output.**') do
    type :copy

    store {
      type :prometheus

      metric {
        name :fluentd_output_status_num_records_total
        type :counter
        desc 'The total number of outgoing records'
        labels {
          tag '${tag}'
        }
      }
    }
  end

But when I try running the code, I get the error:

config error file=\"config/fluent.conf.rb\" error_class=Fluent::ConfigError error=\"type option must be 'counter', 'gauge', 'summary' or 'histogram'\"

I hunted down the line of code that was generating that error:

raise ConfigError, "type option must be 'counter', 'gauge', 'summary' or 'histogram'"

I tweaked the error message that it output to write the keys of the element hash. I got:

type option must be 'counter', 'gauge', 'summary' or 'histogram', element keys: name,@type,desc

As far as I can tell, the Fluent::Config::Element class has some magic in it that turns type into @type as a hash key.

@jonmoter jonmoter changed the title Parsing metrics fails if using Ruby syntax Parsing "type" in metric block fails if using Ruby syntax Apr 16, 2020
@ganmacs
Copy link
Member

ganmacs commented Apr 17, 2020

Right. type is one of reserved keywords in fluentd. BTW, we can't maintain Ruby DSL configuration and will make it deprecated because we don't have enough resources to maintain it. We recommend that you use the original format of fluentd.

https://github.com/fluent/fluentd/blob/a5badcdf916bebcce25af5aac21ad13ce1c3f9a1/lib/fluent/config/dsl.rb#L100

<match output.**>
  @type copy
  <store>
    @type prometheus
    <metric>
      name fluentd_output_status_num_records_total
      type counter
      desc "The total number of outgoing records"
        <labels>
          tag "${tag}"
      </labels>
    </metric>
  </store>
</match>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants