Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-7639

ansible-rulebook : support event path for collecting elements in array in array

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Done
    • Icon: Major Major
    • None
    • None
    • Ansible Integration
    • None
    • NEW
    • NEW
    • ---
    • ---

      Assume we have an event like:

      {
        "incident":{
          "id":"aaa",
          "active":false,
          "alerts":[
            {
              "id":"bbb",
              "tags":[
                {
                  "name":"alertname",
                  "value":"MariadbDown"
                },
                {
                  "name":"severity",
                  "value":"critical"
                }
              ],
              "status":"Ok"
            },
            {
              "id":"ccc",
              "tags":[
                {
                  "name":"severity",
                  "value":"critical"
                },
                {
                  "name":"alertname",
                  "value":"DiskUsage"
                }
              ],
              "status":"Ok"
            }
          ]
        }
      }
      

      Rule condition:

      event.incident.alerts.tags is selectattr('value', '==', 'DiskUsage')  
      

      When "alerts" and "tags" are both arrays, we want to evaluate all tags elements under all alerts elements.

      Currently the condition doesn't match because alerts has to be suffixed with index accessor (e.g. alerts[1]).

      We want to achieve that with

      event.incident.alerts.tags is selectattr('value', '==', 'DiskUsage')  
      

      Note: we don't even support [*].

      event.incident.alerts[*].tags is selectattr('value', '==', 'DiskUsage')  
      

      FYI)
      https://support.smartbear.com/alertsite/docs/monitors/api/endpoint/jsonpath.html
      JSONPath supports [*]

              rhn-support-tkobayas Toshiya Kobayashi
              rhn-support-tkobayas Toshiya Kobayashi
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: