Back to Geneos FAQ

How to parse JSON output from a website using the REST Extractor plugin?

The REST Extractor plugin has been available in Netprobe version GA4.11 and above. Dataviews are configured through the use of jq queries. Users are expected to have technical knowledge and experience in jq syntax in order to use this plugin. Users should check if their Geneos license is entitled to use this plugin. It will likely need to apply an additional license token to the Licence Daemon.

This article uses the same website as an example in a separate article: How to parse JSON output from a website using the Extractor plugin?.

In this example, we will be monitoring and extracting information from the following website:https://www.treasurydirect.gov/webapis/webapisecurities.htm From the API, we have picked the Announced Endpoint to obtain 30 days data with JSON format output. The complete URL would be https://www.treasurydirect.gov/TA_WS/securities/announced?format=json&days=30

  1. Configure the URL to monitor** The REST Extractor plugin can access web sites and parse JSON format output in one go. There is an URL field (highlighted in screen capture) which can be directly inputted to monitor the web site.

Rest Extractor URL field

  1. Enter jq Query** Then at the Query field, user can simply enter the jq syntax to parse the JSON output. We have used the following query in our example:
[.[] | {cusip: (.cusip + " - "+ .securityTerm), issueDate, maturityDate, securityType, announcementDate, auctionDate, interestRate, offeringAmount, securityTermDayMonth, securityTermWeekYear}]
Code Explanation
.[] Treats the input as an array and returns the elements
cusip: (.cusip + " - "+ .securityTerm) Creates a new element by concatenating cusip, -, and securityTerm
issueDate, maturityDate, ..., securityTermWeekYear Captures the existing elements
  1. Reorder the columns

We have chosen to use cusip as the first column. This can be achieved with the Columns button on the right of the URL field.

Rest Extractor dataview

The sampler’s XML is also attached in this article. For more information, see REST Extractor documentation. The documentation for jq can be found in Github.

["Geneos"] ["Geneos > Netprobe"] ["FAQ"]

Was this topic helpful?