Hi,
I found out my rule doesn’t match with sensor output but unsure whats wrong. Any insight will be of much help
Sensor output:
2019-02-01 06:21:48,072 INFO [-] Processing event: {u'check_result': {u'check_source': u'xxx',
u'exit_status': 2.0, u'vars_before': {u'state_type': 1.0, u'reachable': True, u'state': 2.0, u'attempt':
1.0}, u'type': u'CheckResult', u'vars_after': {u'state_type': 1.0, u'reachable': True, u'state': 2.0,
u'attempt': 1.0}, u'execution_start': 1549002107.592814, u'schedule_end': 1549002108.066733,
u'performance_data': [u'available_upgrades=3;;;0', u'critical_updates=3;;;0'], u'state': 2.0,
u'command': xxx'], u'execution_end': 1549002108.066672, u'active': True, u'output': u'APT CRITICAL: xxx
', u'schedule_start': 1549002107.592504}, u'timestamp': 1549002108.066818, u'host': u'xxx', u'type':
u'CheckResult', u'service': u'apt'}
Rule:
name: icinga_action
pack: icinga2
description: Post to chat when icinga2 service state changes
enabled: true
trigger:
type: icinga2.event.state_change
#criteria:
# trigger.type:
# pattern: "u'state_type"
# type: "eq"
# trigger.state_type:
# pattern: 0.1
# type: gt
criteria: # optional
trigger.type:
type: "matchregex"
pattern : "*exit_status*"
trigger.state_type:
type: "gt"
pattern : "0.1"
action:
ref: chatops.post_message
parameters:
message: Icinga2 service {{trigger.service}} on host {{trigger.host}} has changed its state to {{ trigger.state|int }}, state type {{ trigger.state_type|int }}
{{trigger.check_result.output}}
channel: 'xxxx'
Rule Doesn’t Match:
2019-02-01 06:28:53,216 INFO [-] Validating rule icinga2.icinga_action for event.state_change.
2019-02-01 06:28:53,232 INFO [-] Validation for rule icinga2.icinga_action failed on criteria -
key: trigger.state_type
pattern: 0.1
type: gt
payload: None
2019-02-01 06:28:53,232 INFO [-] 0 rule(s) found to enforce for event.state_change.
2019-02-01 06:28:53,232 INFO [-] === RULE DOES NOT MATCH ===