logstash-output-slack icon indicating copy to clipboard operation
logstash-output-slack copied to clipboard

Add support for all of Slack's Message API

Open seanmuth opened this issue 8 years ago • 2 comments

Not all of the different hashes supported by Slack's Message API are supported by this plugin.

For example the following config:

input {
  stdin {
  }
}

output {
  slack {
    url => "https://hooks.slack.com/services/mywebhookurl"
    channel => "@sean.muth"
    attachments => [
        { fallback      => "This is the FALLBACK Message" },
        { color         => "#ff0000" },
        { title         => "This is the Title" },
        { title_link    => "http://google.com" },
        { author        => "This is the author" },
        { author_link   => "http://google.com"},
        { fields        => [
                { title => "Error Message"},
                { value => "This is the error message."},
                { short => false}
          ]}
        ]
  }
}

Won't include the author at all, won't include the link for the title text, and isn't displaying the message "bar" in red. I'm also not sure how to add more than one field, as they are JSON arrays. (That could just be because I'm not formatting my attempts to add more than one field correctly)

The docs for Slack's Message API are here

seanmuth avatar May 03 '16 01:05 seanmuth

@seanmuth I think your attachments is mal-formed - looks like you're accidentally trying to send a message with seven attachments.

You probably want to try something more like this:

attachments => [{
  text => "This is an example message"
  color => "#ff0000"
}]

hatchetation avatar Jun 14 '16 22:06 hatchetation

@hatchetation you could be onto something there. I know I messed with a ton of different configs trying to get it to allow me to include multiple nodes of an attachment, as per the Slack Docu, but never got anywhere.

Ended up just using the http{} output and constructing my own JSON payload for slack, works like a charm!

I'm also not at the company I did this for, so I haven't looked at it in a while

seanmuth avatar Jun 15 '16 01:06 seanmuth