5 Replies Latest reply on Jan 28, 2019 2:22 PM by Kaushik KM

    Understanding Indexes in MRL ?

    Kaushik KM
      Share This:

      Dear ALL,


      I would like to understand how the index work exactly in MRL. i have understood it partially by going through Indexes in rules - BMC ProactiveNet 9.6 - BMC Documentation  and looking to get clear picture on how to use them.

      Please find the code below :

      what are the lines which are highlighted below doing ?



      index clear_due_to_OK_idx : EVENT hashed [clear_slot] END


      new new_clear_events : EVENT($EV)

      where [ $EV.severity equals OK AND $EV.clear_slot not_equals '' AND $EV.dup_key equals '' AND $EV.status not_equals CLOSED ]

      using ALL


              index clear_due_to_OK_idx [$EV.clear_slot]($OLD)

              where [ $OLD.CLASS equals $EV.CLASS AND $OLD.status not_equals CLOSED ]




              $OLD.status = CLOSED ;

              $EV.status = CLOSED ;

              $EV.mc_tool_suggestion = OK_EVENT_RECEIVED ;

              opadd($OLD, '', "Cleared by OK event " || $EV.mc_ueid) ;

              opadd($EV, '', "Cleared an existing event " || $OLD.mc_ueid) ;

              $OLD.msg_status = 'OK_RECEIVED' ;





      Thank you for your time in advance.


        • 1. Re: Understanding Indexes in MRL ?
          Kaushik KM

          Just bringing it up in the stack 

          • 2. Re: Understanding Indexes in MRL ?
            Brian Morris

            The first bolded line is defining an index on the base EVENT class, creating it as a hashed index (which is tuned to be a perfomance enhancement when we hit a rule that needs to find a match or several matches based on the ECF) and declaring that the slot called "clear_slot" is the one which it will index.


            The new rule is just invoking the index in order to locate relevent events. So it will find all events that are indexed by clear_slot and assign that to $OLD and further qualify those matches by using the where criteria, so the classes have to match and the old event can't be closed.

            • 3. Re: Understanding Indexes in MRL ?
              Kaushik KM

              Hi Brian Morris,

              Thank you for responding & being very active here.

              i have been going through other examples and tried to put this way.. let me know if there is anything wrong.


              defining an index --> to say it in layman's language, and visualize it, does it mean like to say "keep a stack of events of class or subclass of EVENT ready in  table named "clear_due_to_OK_idx" to be evaluated against any rule looking at the only slot "clear_slot" without bothering about the order of evaluation(hashed) ?


              coming to :

              USING ALL {} block,


              looking at the 1st line inside the block:

              >> using the index table which we created above, submit the value of slot clear_slot of the current event being evaluated against ALL the events in the table, having the same value as that of current event and point ALL those previous events with variable "$OLD" and perform the action whatever present in the triggers block ?


              what will happen if we dont use the word "ALL"?

              does it find only one event which is matching the clear_slot value and perform action on only one event ?


              Thank you for your time.

              Kaushik KM

              1 of 1 people found this helpful
              • 4. Re: Understanding Indexes in MRL ?
                Brian Morris

                I think you have a good understanding of it now. Defining the index is correct, the ony thing I would add is that "clear_due_to_OK" is evaluated only against a rule that calls it, not necessarily any or every rule. So if we look at the new rule in your example, its invoking this index by name.


                So yes, in this case, as it is presently written, for each match it finds it will do whatever has been defined in the triggers block.


                If you don't use ALL a few things can occur, but they're logically kind of similar.

                • Nothing matches the ECF or the index, so the rule ends
                • Only one event matches, so only that one event is used
                • More than one match exists, but only the first will be used


                I hope this helps.

                • 5. Re: Understanding Indexes in MRL ?
                  Kaushik KM

                  Thank you Brian Morris  I had confusion for the last point, which is cleared now.


                  • More than one match exists, but only the first will be used and after that rule ends - if the keyword 'ALL' is not used.