This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to Parse a string in a rule condition

I have the need to take a string that is used as a Display Name for a database instance in Foglight for SQL Server and parse it.  For instance, the Display name might be something like C-Tier1-DatabaseInstance.   I am building a rule where I have the need to split the string in separate variables to build conditional statements.  What is the syntax to do something like this?

Parents
  • Hi,

    The scope variable is available.
    I think that all other variables defined inside the condition of the rule are not available elsewhere.

    You can try building your variables as Rules Variables (the last tab)
    For example : create a Rule Variable with name DBSS_HostName as expression :
    return scope.dbss_host.get("name");
    Then you can use @DBSS_HostName in your code or email header or body.



    Sometimes i even build the rule alarm message as a rule variable (ex : ruleAlarmMessage ) using other rule variables from the same script.

    Then i use the following as the Alarm Message
    @ruleAlarmMessage

    Occasionally i have seen some weird behavior with rules variables not being evaluated when used in alert email message.
    As a workaround i used the Severity Level Variables, but if you have multiseverity conditions you have to set them multiple times.

    Try first with as Rule Variable.


    Regards
Reply
  • Hi,

    The scope variable is available.
    I think that all other variables defined inside the condition of the rule are not available elsewhere.

    You can try building your variables as Rules Variables (the last tab)
    For example : create a Rule Variable with name DBSS_HostName as expression :
    return scope.dbss_host.get("name");
    Then you can use @DBSS_HostName in your code or email header or body.



    Sometimes i even build the rule alarm message as a rule variable (ex : ruleAlarmMessage ) using other rule variables from the same script.

    Then i use the following as the Alarm Message
    @ruleAlarmMessage

    Occasionally i have seen some weird behavior with rules variables not being evaluated when used in alert email message.
    As a workaround i used the Severity Level Variables, but if you have multiseverity conditions you have to set them multiple times.

    Try first with as Rule Variable.


    Regards
Children
No Data