takus / fluent-plugin-ec2-metadata

Fluentd output plugin to add Amazon EC2 metadata into messages
Other
44 stars 28 forks source link

Adding colon and dash to capturing group #23

Closed eadasiak closed 7 years ago

eadasiak commented 7 years ago

I also ran into issue #22 when trying to use the following tag sets:

Before this change, with the following configuration, the field for INSTANCE_STACK_NAME would be the literal string ${tagset_aws:cloudformation:stack-name} in the log record:

  <filter journald.**>
    @type ec2_metadata
    @id add_ec2_metadata
    metadata_refresh_seconds "#{ENV['FLUENTD_EC2_METADATA_REFRESH']}"
    <record>
      INSTANCE_ID         ${instance_id}
      INSTANCE_TYPE       ${instance_type}
      INSTANCE_NAME       ${tagset_name}
      INSTANCE_AZ         ${availability_zone}
      INSTANCE_AMI_ID     ${image_id}
      INSTANCE_ROLE       ${tagset_role}
      INSTANCE_PRODUCT    ${tagset_product}
      INSTANCE_STACK_NAME ${tagset_aws:cloudformation:stack-name}
    </record>
  </filter>

This was because the original gsub in PlaceholderExpander wouldn't match on the : or - used in the string for the tagset.

Thanks for considering this PR, and for creating this incredibly useful plugin in the first place!

kgf commented 7 years ago

+1 Looks like tests are failing due to a Code Climate issue ?

kgf commented 7 years ago

I can confirm that this resolves #22

takus commented 7 years ago

Thanks you very much for your PR. I'm going to release v0.0.13.