sowawa / fluent-plugin-slack

132 stars 52 forks source link

Question: Use mulitple fields #40

Open chhetripradeep opened 6 years ago

chhetripradeep commented 6 years ago

Thank you for the awesome slack plugin. I am trying to post a slack attachment message with multiple fields but i unable to achieve it. I am only able to create single field per msg using the following configuration

<match kube.**>
      @type slack
      webhook_url "#{ENV['SLACK_WEBHOOK_URL']}"
      channel "#{ENV['SLACK_CHANNEL']}"
      username fluentd
      message %s
      message_keys log
      title Pod: %s
      title_keys kube_tag
      icon_emoji :ghost:
      flush_interval 1s
      mrkdwn true
      color danger
</match>

screen shot 2017-12-20 at 6 51 44 pm

I would like to add other fields as well but not able to figure out how can we achieve it.

andrewl commented 6 years ago

Hi,

Not sure if this is still relevant to you, but you add multiple placeholders for your fields in the message section, then in message_keys you put a comma delimited list of keys in order of replacement, eg

message The current temperature is %s and the weight is %s message_keys temp,weight

chhetripradeep commented 6 years ago

@andrewl Thanks. let me try it and get back to you.

chhetripradeep commented 6 years ago

@andrewl do you know if we can make use of slack attachments to make it look pretty ?