Parsing plugins
- LineNumber.pm - <line> - Extract whole line
- Regex.pm - <regex> - Regular expression
- XPath.pm - <xpath> - XML XPath
- JSON.pm - <json> - JSON path
LineNumber.pm (<line> directive)
Perhaps the simplest parsing plugin M3 has to offer. This plugin will extract a whole line from the output. Having for instance the output of:
Hello World
Would result in the following parsing:
- <line>1</line> => Hello
- <line>2</line> => World
Regex.pm (<regex> directive)
The first and perhaps most powerful parsing plugins M3 has to offer.
Regular expressions are extremely simple yet very powerful and flexible.
Numerous examples exist in the different sample configuration files.
The regex plugin most commonly used feature is to extract the whole output:
<regex>(.*)</regex>
For instance, extracting the second word in a sentence would be:
The quick brown fox jumps over the lazy dog
- <regex>\w+\s+(\w+)</regex> => quick
If you are unfamiliar with regular expressions and would still like to use them, I suggest further reading.
XPath.pm (<xpath> directive)
XPath would retrieve a XML path from XML formatted output.
An example XPath would look like:
- <xpath>{agent}->{"Sample XML extraction"}->{monitor}->{"XML extraction"}->{exectemplate}[0]</xpath>
Generally speaking you could have a look JSON.pm (<json> directive)
Very similar to the XPath.pm, this plugin will extract a JSON path. An example for a JSON path would look like: <json>{'forecast'}[0]->{'low_temperature'}</json>