This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Orion SDK: Group Filter Operators

I'm trying to use the Orion.Container.CreateContainer verb in the SDK to create a group with a dynamic query that allows me to utilize more than use the = (is) operator. In the documentation and the example, all of the filters utilize only the = operator. In the UI, we have more operators, as seen in the image below:

pastedImage_0.png

Is it possible to utilize the other operators and if so, does anyone have a list of the expected operators in the filter? Here's a sample of what I'm doing in PowerShell:

$members = @(

    @{ Name = "Subnet 192.168.10.0/24"; Definition = "filter:/Orion.Nodes[IP_Address LIKE '192.168.10.%']" },

    @{ Name = "subnet 192.168.11.0/24"; Definition = "filter:/Orion.Nodes[IP_Address LIKE '192.168.11.%']" }

)

$groupId = (Invoke-SwisVerb $swis "Orion.Container" "CreateContainer" @(

    # group name

    "Children - Site A",

    # owner, must be 'Core'

    "Core",

    # refresh frequency

    120,

    # Status rollup mode:

    # 0 = Mixed status shows warning

    # 1 = Show worst status

    # 2 = Show best status

    1,

    # group description

    "Nodes that are dependent on group Parent - Site A.",

    # polling enabled/disabled = true/false (in lowercase)

    "true",

    # group members

    ([xml]@(

       "<ArrayOfMemberDefinitionInfo xmlns='http://schemas.solarwinds.com/2008/Orion'>",

       [string]($members |% {

         "<MemberDefinitionInfo><Name>$($_.Name)</Name><Definition>$($_.Definition)</Definition></MemberDefinitionInfo>"

         }

       ),

       "</ArrayOfMemberDefinitionInfo>"

    )).DocumentElement

  )).InnerText

The group shows up in red status and when I try to edit the dynamic query, I get the following:

pastedImage_1.png

I was expecting to see something similar to the first screenshot. Your help is appreciated!

  • At a glance try removing your special characters from the name, otherwise the syntax looks about right.

    To make my scripts I have always just gone in and made one example of the logic I wanted by hand and then copied that filter into my script to modify as needed.  The definitions are EXTREMELY fussy about having the exact case and white spaces they expect otherwise you end up with problems.

  • Thanks mesverrum​ - you gave me the clue I needed. I built the expected statement in the UI and then when you select to 'Edit Dynamic Query'

    pastedImage_0.png

    In the URL, you can see the HTML encoded version of the filter. Here's the full list of all operators in examples:

    IP_Address is 192.168.10.10

    filter%3a%2fOrion.Nodes%5bIP_Address%3d%27192.168.10.10%27%5d

    filter:\Orion.Nodes[IP_Address='192.168.10.10')]

    IP_Address is not 192.168.10.10

    filter%3a%2fOrion.Nodes%5bIP_Address!%3d%27192.168.10.10%27%5d

    filter:\Orion.Nodes[IP_Address!='192.168.10.10']

    IP_Address starts with 192.168.10.

    filter%3a%2fOrion.Nodes%5bStartsWith(IP_Address%2c%27192.168.10.%27)%5d

    filter:/Orion.Nodes[StartsWith(IP_Address,'192.168.10.')]

    IP_Address ends with .10.%

    filter%3a%2fOrion.Nodes%5bEndsWith(IP_Address%2c%2710.%25%27)%5d

    filter:\Orion.Nodes[EndsWith(IP_Address,'10.%')]

    IP_Address contains .10.

    filter%3a%2fOrion.Nodes%5bContains(IP_Address%2c%27.10.%27)%5d

    filter:\Orion.Nodes[Contains(IP_Address,'.10.')]

    IP_Address matches 192.168.*

    filter%3a%2fOrion.Nodes%5bPattern(IP_Address%2c%27192.168.%25%27)%5d

    filter:\Orion.Nodes[Pattern(IP_Address,'192.168.%')]

    Thanks again!

  • Created a pull request in GitHub to update the groups.ps1 example file with a comments section that shows how to use the different operators:

    Filter Operator Samples by RepinStyle · Pull Request #213 · solarwinds/OrionSDK · GitHub