How to extract JSON with Extractor and Rest-Extractor
The Rest-Extractor plugin can be used to get JSON format into Geneos. Some users prefer to read JSON from a file, rather than accessing the JSON through http or https. The following examples use both plugins, so that you can compare and and get a feel of the different. The JSON file is in /var/www/html and the httpd is in the Linux server.
[
{"MON":{"Host":"hkserver101.net","AlertID":"HK0101","Cmp":"instrument","Lvl":"I","Data":{"Usd":8088,"Max":85000,"Pct":12.231213,"Lmt":50.0},"Timestamp":"20201113.110008.333880"}},
{"MON":{"Host":"hkserver201.net","AlertID":"HK2020","Cmp":"price_1","Lvl":"I","Data":{"Usd":123,"Max":30000,"Pct":59.2123,"Lmt":50.0},"Timestamp":"20201113.120008.323072"}}
]
Both plugins result to identical outputs:
Extractor plugin:
Rest-Extractor plugin:
Using Extractor, you need to know how to use xpath. Geneos convert JSON to xml in extractor plugin, if you want to know about the path, you can do this:
And you will get this:
Rest-Extractor provides a simpler approach, by using JQ query:
For reference, the xml for Extractor.txt and Rest_Extractor.txt can be downloaded and tested.