Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: for multiple "AND" conditions to detect an event #12

Open
hz2102 opened this issue Aug 21, 2018 · 5 comments
Open

Feature Request: for multiple "AND" conditions to detect an event #12

hz2102 opened this issue Aug 21, 2018 · 5 comments

Comments

@hz2102
Copy link

hz2102 commented Aug 21, 2018

Hi,

I am new to stackstorm and ghost2logger. And nice work David to provide this package.

Just wondering if there is any way to define 2 or more patterns with and condition.
Seems like in this current version there is only one trigger.pattern can be defined.

In some cases, we need to check multiple parameters, like interfaceX with recent state up or down.
I have tried with Regex and these type of events can be detected with ghost2logger.
But attaching this event to an action, we need to extract the interface name from the syslog message. And forward this info to another module like execute ansible playbook, to change that interface configuration.

I am not sure if any other way to do this, but if it is possible using ghost2logger it would be really nice.

Regards,
hz2102

@blag
Copy link
Contributor

blag commented Aug 21, 2018

If I understand your question correctly, yes, this is entirely possible. The provided example rule even illustrates how to do this:

name: rule_1
pack: ghost2logger
ref: ghost2logger.rule_1
criteria:
    trigger.host:
        pattern: 192.168.16.1
        type: eq
    # implicit AND operator
    trigger.pattern:
        pattern: thing [0-9]$
        type: eq
...

All you have to do is provide more than one key/object pair in the criteria.

You can also create this in the StackStorm web UI in the "Rules" tab and using the "Add Criteria" button:

screen shot 2018-08-20 at 9 34 18 pm

Note the "and" between the criteria - that indicates that both criteria must match to pass the rule and create a trigger instance. Furthermore, please note that the example rule and the screenshot I posted are not for the same rule.

@hz2102
Copy link
Author

hz2102 commented Aug 21, 2018

Thanks for the detailed explanation.
I think I cannot able to explain the problem correctly.

I am aware that there can be multiple criteria defined.
image

But I need to define multiple trigger.pattern, so when I add another trigger.pattern like following, the previous one seems to be re-written.
image

  • you can see here the previous one is back to default value.

Regards,
hz2102

@hz2102
Copy link
Author

hz2102 commented Aug 21, 2018

To add an example, in my environment I can now detect the following syslog. Using two AND criteria, host IP and syslog message information.
image
<189>166: Aug 21 11:37:39.394 JST: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet3, changed state to down

What I need is, parse the affected interface and the fault information from this message, so what I thought, if I can define the criteria like,
trigger.pattern1 == GigabitEthernet.* (<- interface name only)
trigger.pattern2 == "changed state to down"
trigger.host == x.y.z.w
In this way, I can pass the trigger.pattern1 value to some other modules, like ansible to execute some commands, like "show interface GigabitEthernet1".

If the scenario is not clear enough please let me know.

Regards,
hz2102

@DavidJohnGee
Copy link
Contributor

DavidJohnGee commented Aug 21, 2018 via email

@hz2102
Copy link
Author

hz2102 commented Aug 21, 2018

Thanks, David. Hope you had a nice relaxing time^^

I may understand you wrong so please point me out if I am.
What I need, or I think if its available could make this package better is to have options something like following,

name: rule_1
pack: ghost2logger
ref: ghost2logger.rule_1
criteria:
    trigger.host:
        pattern: 192.168.16.1
        type: eq
    trigger.pattern1:
        pattern: link.*down$
        type: eq
    trigger.pattern2:
        pattern: ge-0/0/[0-9]*
        type: regex
enabled: true
tags: []

If its possible we can get two variables, {{trigger.pattern1}} and {{trigger.pattern2}}.
pattern1 is to know that something, eventually pattern2, is in a down state now.
By getting these two variables we can pass related info to our action module, say use ansible to get that interface info.

What I am facing is, I cannot define trigger.pattern more than 1 time. It may be a GUI problem, or it is the only way to define only one trigger.pattern per rule.

I will try to troubleshoot this problem and report back to St2 team if needed :)

Regards,
hz2102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants