sensu-plugins / sensu-plugins-slack

Sensu Slack chat handlers
http://sensu-plugins.io
MIT License
30 stars 54 forks source link

client fields not rendering values. #17

Closed brettswift closed 4 years ago

brettswift commented 8 years ago

I'm trying to pass some metadata from the check into the slack message. Both a custom param "owner" as well as the # of occurrences it's had. In both cases (see the bottom screenshot) the field name appears in the check, but not the value.

I'm not sure the best way to test handlers as I haven't written one yet, but just blasting out the @event variable to system logs seems to just

Maybe this feature is known to not be working, or I'm doing it wrong?

Client check:

[root@devcorepptl918 ~]# cat /etc/sensu/conf.d/checks/chk-proc-puppetdb_process.json
{
  "checks": {
    "chk-proc-puppetdb_process": {
      "command": "check-process.rb --pattern 'puppetdb' --critical-under 5",
      "handlers": [
        "slack"
      ],
      "interval": 10,
      "occurrences": 2,
      "subscribers": [
        "all"
      ],
      "standalone": true,
      "owner": "bswift"
    }
  }
}

Handler config

[root@devcoremonl905 sensu]# cat /etc/sensu/conf.d/handlers/slack.json
{
  "handlers": {
    "slack": {
      "command": "handler-slack.rb",
      "type": "pipe",
      "filters": [

      ],
      "severities": [
        "critical"
      ]
    }
  },
  "slack": {
    "webhook_url": "https://hooks.slack.com/services/--redacted---",
    "fields": [
      "owner",
      "occurrences"
    ]
  }
}

This is the slack message:

image

brettswift commented 8 years ago

I actually wasn't aware the custom fields could exist on the client as well as a check. So lines were blurred here.

There isn't support for check fields here... however I think it should be fairly simple to implement.

https://github.com/sensu-plugins/sensu-plugins-slack/blob/master/bin/handler-slack.rb#L163

Are you achieving this currently by just supplying a template? Would that be enough?

majormoses commented 6 years ago

yes you could supply your own template to very granularly control what is (not) sent.