Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In the XML parser, we have several operators which need to be used at different levels.

...

  • _vars - allows you to define variable which can be used later on in the script. The parser will basically replace the vars throughout the script with the value you set. For example, this:

    _vars:
    root: /response/result

    Means "${root}" will be replaced with "/response/result" throughout the script.

  • _tags - device tags. There is also a _tags section under metric, but more on that below. The "_tags" section at the top level is used to define device tags, such as "os.version" or "model". For example:
    _tags:
    "os.name":
    _constant: "panos"
    "os.version":
    _text: "/response/result/system/sw-version"
    "vendor":
    _constant: "paloaltonetworks"
    "model":
    _text: "/response/result/system/model"
  • _metrics - only allowed in monitoring scripts. Metrics are defined under this section. Each metric is under its own "-" section. It looks like this:
    _metrics:
    -
    _value.double:
    _count: "${root}/entry"
    _tags:
    "im.name":
    _constant: "routes-usage"

    A few things to note:

    • In case no metrics were parsed (due to missing data or incorrect parsing) then the command will fail; that is, unless some dynamic variables were parsed by the command. 
      • By using _optional_metrics instead of _metrics, one could override this behavior and not fail the command when no metrics are parsed.
    • the "_value" operator is used to determine the type of metric (more on this below). 
    • The "_tags" section here is not the same as the one at the root level (described above). Rather, these are tags to attach to the metric.
  • _omit - drop certain lines from the input:

    _omit:
      - _top: 2
      - _bottom: 3
      - _regex: "regex"

    Means omit 2 lines from the top, then three lines from the bottom, the lines matching "regex". The order matters - the omitting will be executed according to the order. Older versions didn't use the "-" at the beginning of each operator line. In that case, it only supported _top and _bottom, no _regex.

     

...