0

I would like to add custom key/value pairs to the event data in sensu. I added the keys to the event definition, but it's not there by the time it gets to the handlers.

So what i want to achieve is to have the data behind the "custom_values" key at the point the check data is passed to the handler. (see example)

{
  "checks": {
    "check-disk": {
      "command": "/etc/sensu/plugins/check-disk.rb",
      "interval": 60,
      "handlers": [
        "default"
      ],
      "subscribers": [
        "default"
      ],
      "standalone": false

      "custom_values": {
          "custom1": "somevalue"
      }

    }
  }
}

Mutators won't help, AFAIK they can only work with the check data, which is not containing the custom key when the mutator gets the check result.

Thanks

Bszabo
  • 3
  • 1
  • 5

2 Answers2

0

This should work. Can you be sure that this check is not defined in on the client as well? Additionally, did you remember to restart the sensu server to pick up the new definition?

SolarKennedy
  • 138
  • 8
0

Not much to go on as to how you're trying to use it, but there are a couple items you'll want to be sure of.

First off, the checks json provided is malformed, prior to defining your custom_values, you need a comma after "standalone": false

As such:

"standalone": false,

  "custom_values": {
      "custom1": "somevalue"
  }

Second, when you go to use this custom_value data in your handler, make sure you're addressing it as part of the check:

@event['check']['custom_values']['custom1']

and not just trying to use it directly off the event, i.e.

@event['custom_values']['custom1']
thomaswsdyer
  • 346
  • 1
  • 10