Is there a way to trigger an handler for an event created with the agent API /events?

I generated an event thourgh the agent API on a Windows server.

$Uri = 'http://127.0.0.1:3031/events'
$Form= '
{ 
  "check": {
    "metadata": {
      "name": "mysql-backup-job"
    },
    "status": 0,
    "output": "mysql backup ran successfully!"}
}
'
Invoke-WebRequest -Uri $Uri -Method Post -Form $Form

As expected, I see this event in the backend but don’t know if there is a way to trigger an handler (my email handler for example) based on this event ?
I tried to add the handler in the event itself (example below) but it doesn’t seem to be taken into account.

$Form= '
{ 
  "check": {
    "metadata": {
      "name": "mysql-backup-job"
    },
	"spec": {
	  "handlers": ["email"]
	},
    "status": 0,
    "output": "mysql backup ran successfully!"}
}
'

Thanks by advance for your help.

You’re almost there. For an event, the ‘handlers’ definition does not go under ‘spec’. This should work:

{ 
  "check": {
    "metadata": {
      "name": "mysql-backup-job"
    },
    "handlers": ["email"],
    "status": 0,
    "output": "mysql backup ran successfully!"}
}
1 Like

You’re right, it’s working as expected.
Thx a lot