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

slack message_template #46

Open
yuvarajanlga opened this issue Jul 31, 2017 · 3 comments
Open

slack message_template #46

yuvarajanlga opened this issue Jul 31, 2017 · 3 comments

Comments

@yuvarajanlga
Copy link

Hi team,

If some one let me know on how to write message_template for slack to display the message in customised format. i am struggling to display the filters in template, if you can show me some guides to read, it will help me to achive on what i want.

@yuvarajanlga
Copy link
Author

yuvarajanlga commented Aug 1, 2017

i have written the basic ERB template for slack. I hope this will be helpful for some one who is new to writing template.

slack-template.erb

<%"<br>"%>


Output: <%= @event["check"]["output"] %>

Alert-Time: <%= Time.at(@event["check"]["issued"])  %>

slack.json

{
  "handlers": {
    "slack": {
      "type": "pipe",
      "command": "/opt/sensu/embedded/bin/handler-slack.rb",
      "severities": [
        "critical",
        "warning"
      ]
    }
  },
  "slack": {
    "webhook_url": "https://hooks.slack.com/******",
    "bot_name": "*********",
    "template": "/etc/sensu/conf.d/email/slack_template.erb",
    "channel": "#servers"
  }
}

If some one let me know, how to achive writing in filters on ERB template. i dont know how to do it.

@majormoses
Copy link
Member

@yuvarajanlga sorry no one got to you sooner, that template looks like a great template that we should include in the readme. Would you be willing to put together a PR to enhance that? Regarding filtering ERB templates I am not sure I understand what you are trying to fo can you explain what you are looking to accomplish?

@trombik
Copy link

trombik commented May 19, 2020

the above example is in invalid format. replace http://172.16.100.254:3000/ with your sensu web URL.

Output: <%= @event["check"]["output"] %>
Alert-Time: <%= Time.at(@event["check"]["issued"])  %>
URL: http://172.16.100.254:3000/n/<%= @event["check"]["metadata"]["namespace"] %>/events/<%= @event["entity"]["metadata"]["name"] %>/<%= @event["check"]["metadata"]["name"] %>

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

No branches or pull requests

4 participants