Skip to content

Datasource: JSON

Rello edited this page Jan 5, 2023 · 8 revisions

With the JSON datasource, you can extract data from an external JSON service

Usecase

  • grab Nextcloud statistics from its own monitoring API (see below)

Prerequisite

  • URL needs to be accessible by Nextcloud

Usage

  1. Realtime data source in the report settings
  2. Store data in the data set automation

Input Parameter

  • URL of json
  • Authentication
  • Object path for non-array values: multiple values extracted at once. They need to be separated by ",". See Example 1
  • Object path for array values: a whole dataset can be selected by choosing the columns within {dimension1,dimension2,value}. See Example 3, 4
  • HTTP method to choose GET/POST
  • Request body - in case the request requires data to be sent
  • Content-Type (default application/json)
  • Timestamp - if the data should be stored with the timestamp of the data loading; to keep a historic snapshot; not for array values

Examples

Example 1:

Monitor the Nextcloud instance via its internal API

  • monitoring app needs to be enabled
  • access token needs to be created
  • URL: http://server/nextcloud/ocs/v2.php/apps/serverinfo/api/v1/info?format=json
  • Auth: user:token (from settings->security)
  • Object path: ocs/data/nextcloud/storage,ocs/data/nextcloud/shares
  • Timestamp true

Screenshot

Example 2:

Monitor ethermine API

  • URL: https://api.ethermine.org/miner/0x70CEC2d62EcDeebd19CE87EBAf01c6d9546BF407/currentStats
  • Object path: data/currentHashrate,data/averageHashrate
  • Method: GET
  • Timestamp true

Example 3:

Get history of BTC/EUR values

  • URL: https://cex.io/api/price_stats/BTC/EUR
  • Object path: {BTC,tmsp,price}
  • Method: POST
  • Request body: {"lastHours": 24,"maxRespArrSize": 100}
  • Timestamp false

Screenshot

Example 4:

Read an array of values from a sub-path of the json.
Absolute and array paths can be combined

  • Object path: data/data{forecast,from,intensity/forecast}