This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.

⚠️ We've moved!

Hi there!

To reduce project dependency on 3rd party paid services the StackStorm TSC has decided to move the Q/A from this forum to Github Discussions. This will make user experience better integrated with the native Github flow, as well as the questions closer to the community where they can provide answers.

Use 🔗 Github Discussions to ask your questions.

Rule doesn't match sensor output

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 ===

Answered: https://stackstorm-community.slack.com/archives/C066APT88/p1549007726529200

Your data is not valid JSON. That is why the rule is not matching.

Look at your trigger instance, specifically the type: parameter - it is 'type': 'CheckResult'

But in your rule, you’re doing this:

   trigger.type:
     type: "matchregex"
     pattern : "*exit_status*"

exit_status is the name of a key within your trigger - it is not a value. Are you trying to check if that key exists, or are you trying to check that the exit_status key exists, and is a particular value?

1 Like

Thanks @blag, @lhill: That solved the Issue.