Skip to content

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

@jonmoter

Description

@jonmoter

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions