"event was filtered" message is showing "null" instead of the name of the matching filter.

As per #1467, on v0.27 the filtered events should show the name of the matching filter.
Currently, I’m getting ‘null’. I wonder if I’m doing something wrong? Here are my filters:

{
“filters”: {
“filter_1”: {
“negate”: false,
“attributes”: {
“check”: {
“name”: “checkname1”
},
“occurrences”: “eval: value != 1 && value % 5 != 0”
}
},
“filter_2”: {
“negate”: false,
“attributes”: {
“check”: {
“name”: “checkname2”
},
“occurrences”: “eval: value != 3 && value % 6 != 0”
}
}
}
}

And the relevant log output:
{“timestamp”:“2017-02-01T09:22:00.375020+0100”,“level”:“info”,“message”:“event was filtered”,“handler”:{“type”:“pipe”,“command”:"/etc/sensu/handlers/myhandler.rb",“filters”:[“filter_1”,“filter_2”],“severities”:[“critical”,“unknown”,“ok”],“name”:“myhandler”},“event”:{“client”:{…},“check”:{“handlers”:[“webapi”],“command”:“sudo /etc/sensu/plugins/checkscript1.rb”,“interval”:60,“occurrences”:5,“alias”:“checkname1”,“subscribers”:[“all”],“name”:“checkname1”,“issued”:1485937320,“executed”:1485937320,“duration”:0.102,“output”:"",“status”:2,“type”:“standard”,“history”:[“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“0”,“2”],“total_state_change”:11},“occurrences”:1,“occurrences_watermark”:1,“action”:“create”,“timestamp”:1485937320,“id”:“74d1367d-5b63-401f-a0d3-46f6e6be8da9”,“last_ok”:1485937320,“last_state_change”:1485937320,“silenced”:false,“silenced_by”:},“filter”:null}

Shouldn’t the “filter” value show the name of the matching filter?

Hi fhd,

Thanks for reporting this issue. I’ve reproduced this in my testing and it does seem that the feature isn’t working as intended. I’ve opened Filter name is logged as null when event is filtered · Issue #1546 · sensu/sensu · GitHub to track this.

···

On Wednesday, February 1, 2017 at 1:41:51 AM UTC-7, fhd wrote:

As per #1467, on v0.27 the filtered events should show the name of the matching filter.
Currently, I’m getting ‘null’. I wonder if I’m doing something wrong? Here are my filters:

{
“filters”: {
“filter_1”: {
“negate”: false,
“attributes”: {
“check”: {
“name”: “checkname1”
},
“occurrences”: “eval: value != 1 && value % 5 != 0”
}
},
“filter_2”: {
“negate”: false,
“attributes”: {
“check”: {
“name”: “checkname2”
},
“occurrences”: “eval: value != 3 && value % 6 != 0”
}
}
}
}

And the relevant log output:
{“timestamp”:“2017-02-01T09:22:00.375020+0100”,“level”:“info”,“message”:“event was filtered”,“handler”:{“type”:“pipe”,“command”:“/etc/sensu/handlers/myhandler.rb”,“filters”:[“filter_1”,“filter_2”],“severities”:[“critical”,“unknown”,“ok”],“name”:“myhandler”},“event”:{“client”:{…},“check”:{“handlers”:[“webapi”],“command”:“sudo /etc/sensu/plugins/checkscript1.rb”,“interval”:60,“occurrences”:5,“alias”:“checkname1”,“subscribers”:[“all”],“name”:“checkname1”,“issued”:1485937320,“executed”:1485937320,“duration”:0.102,“output”:“”,“status”:2,“type”:“standard”,“history”:[“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“2”,“0”,“2”],“total_state_change”:11},“occurrences”:1,“occurrences_watermark”:1,“action”:“create”,“timestamp”:1485937320,“id”:“74d1367d-5b63-401f-a0d3-46f6e6be8da9”,“last_ok”:1485937320,“last_state_change”:1485937320,“silenced”:false,“silenced_by”:},“filter”:null}

Shouldn’t the “filter” value show the name of the matching filter?

@Cameron Johnston

Great, thanks!