All Projects → simPod → Grafanajsondatasource

simPod / Grafanajsondatasource

Licence: mit
Grafana datasource to load JSON data over your arbitrary HTTP backend

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Grafanajsondatasource

Networking
⚡️ Elegantly connect to a REST JSON Api. URLSession + Combine + Decodable + Generics = <3
Stars: ✭ 499 (+241.78%)
Mutual labels:  api, rest-api, rest, json
Http Fake Backend
Build a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 253 (+73.29%)
Mutual labels:  api, rest-api, rest, json
Json Serverless
Transform a JSON file into a serverless REST API in AWS cloud
Stars: ✭ 108 (-26.03%)
Mutual labels:  api, rest-api, rest, json
Httpie
As easy as /aitch-tee-tee-pie/ 🥧 Modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more. https://twitter.com/httpie
Stars: ✭ 53,052 (+36236.99%)
Mutual labels:  api, rest-api, rest, json
Spyke
Interact with REST services in an ActiveRecord-like manner
Stars: ✭ 591 (+304.79%)
Mutual labels:  api, rest-api, rest, json
Generator Http Fake Backend
Yeoman generator for building a fake backend by providing the content of JSON files or JavaScript objects through configurable routes.
Stars: ✭ 49 (-66.44%)
Mutual labels:  api, rest-api, rest, json
Json Api Dart
JSON:API client for Dart/Flutter
Stars: ✭ 53 (-63.7%)
Mutual labels:  api, rest-api, rest, json
Aping
angular module to get and display data by adding html-attributes
Stars: ✭ 135 (-7.53%)
Mutual labels:  api, rest, json
Apy
Apy is a simple client-side library for making rest api ajax calls.
Stars: ✭ 68 (-53.42%)
Mutual labels:  api, rest-api, rest
Poloniex Api Node
Poloniex API client for REST and WebSocket API
Stars: ✭ 138 (-5.48%)
Mutual labels:  api, rest-api, rest
Tiledesk Server
Tiledesk server. Tiledesk is an Open Source Live Chat platform written in NodeJs and MongoDB
Stars: ✭ 94 (-35.62%)
Mutual labels:  api, rest-api, rest
Open Rest
Standard rest server, Base on restify and sequelize
Stars: ✭ 136 (-6.85%)
Mutual labels:  api, rest-api, rest
Acf To Rest Api
Exposes Advanced Custom Fields Endpoints in the WordPress REST API
Stars: ✭ 1,152 (+689.04%)
Mutual labels:  api, rest-api, rest
Jokeapi
A REST API that serves uniformly and well formatted jokes in JSON, XML, YAML or plain text format that also offers a great variety of filtering methods
Stars: ✭ 71 (-51.37%)
Mutual labels:  api, rest-api, json
Cookiecutter Django Rest
Build best practiced apis fast with Python3
Stars: ✭ 1,108 (+658.9%)
Mutual labels:  api, rest-api, rest
Behat Api Extension
API extension for Behat, used to ease testing of JSON-based APIs
Stars: ✭ 92 (-36.99%)
Mutual labels:  api, rest, json
Rest Hapi
🚀 A RESTful API generator for Node.js
Stars: ✭ 1,102 (+654.79%)
Mutual labels:  api, rest-api, rest
Api Client Generator
Angular REST API client generator from Swagger YAML or JSON file with camel case settigs
Stars: ✭ 92 (-36.99%)
Mutual labels:  api, rest, json
Http restful api
整理HTTP后台端的RESTful API方面的知识
Stars: ✭ 94 (-35.62%)
Mutual labels:  api, rest-api, rest
Invoice As A Service
💰 Simple invoicing service (REST API): from JSON to PDF
Stars: ✭ 106 (-27.4%)
Mutual labels:  api, rest, json

JSON API Grafana Datasource

Build Marketplace Downloads

The JSON Datasource executes requests against arbitrary backends and parses JSON response into Grafana dataframes.

Contents

Installation

To install this plugin using the grafana-cli tool:

 grafana-cli plugins install simpod-json-datasource

See here for more information.

Setup

When adding datasource add your API endpoint to the URL field. That's where datasource will make requests to.

Datasource setup

API

An OpenAPI definition is defined at openapi.yaml.

To work with this datasource the backend needs to implement 4 endpoints:

  • GET / with 200 status code response. Used for "Test connection" on the datasource config page.
  • POST /search returning available metrics when invoked.
  • POST /query returning metrics based on input.
  • POST /annotations returning annotations.

Those two urls are optional:

  • POST /tag-keys returning tag keys for ad hoc filters.
  • POST /tag-values returning tag values for ad hoc filters.

/search

POST /search

Grafana issues this request on

  1. Variables > New/Edit page. Query field value is passed in a body as
{ "target": "query field value" }
  1. Panel > Queries page. Format As and Metric values are passed in a body as
{ "type": "timeseries", "target": "upper_50" }

The way you handle those values is up to you.

The response body can either contain an array or a map.

Example array response:

["upper_25","upper_50","upper_75","upper_90","upper_95"]

Example map response:

[ { "text": "upper_25", "value": 1}, { "text": "upper_75", "value": 2} ]

/query

POST /query

Example timeseries request:

{
  "panelId": 1,
  "range": {
    "from": "2016-10-31T06:33:44.866Z",
    "to": "2016-10-31T12:33:44.866Z",
    "raw": {
      "from": "now-6h",
      "to": "now"
    }
  },
  "rangeRaw": {
    "from": "now-6h",
    "to": "now"
  },
  "interval": "30s",
  "intervalMs": 30000,
  "maxDataPoints": 550,
  "targets": [
     { "target": "Packets", "refId": "A", "type": "timeseries", "data": { "additional": "optional json" } },
     { "target": "Errors", "refId": "B", "type": "timeseries" }
  ],
  "adhocFilters": [{
    "key": "City",
    "operator": "=",
    "value": "Berlin"
  }]
}

Example timeseries response (metric value as a float , unixtimestamp in milliseconds):

[
  {
    "target":"pps in",
    "datapoints":[
      [622,1450754160000],
      [365,1450754220000]
    ]
  },
  {
    "target":"pps out",
    "datapoints":[
      [861,1450754160000],
      [767,1450754220000]
    ]
  },
  {
    "target":"errors out",
    "datapoints":[
      [861,1450754160000],
      [767,1450754220000]
    ]
  },
  {
    "target":"errors in",
    "datapoints":[
      [861,1450754160000],
      [767,1450754220000]
    ]
  }
]

The relation between target in request and response is 1:n. You can return multiple targets in response for one requested target.

Example table response to be returned if the metric selected is "type": "table":

[
  {
    "columns":[
      {"text":"Time","type":"time"},
      {"text":"Country","type":"string"},
      {"text":"Number","type":"number"}
    ],
    "rows":[
      [1234567,"SE",123],
      [1234567,"DE",231],
      [1234567,"US",321]
    ],
    "type":"table"
  }
]

Additional data

Additional data input

Sending additional data for each metric is supported via the Additional JSON Data input field that allows you to enter JSON.

For example when { "additional": "optional json" } is entered into Additional JSON Data input, it is attached to the target data under "data" key:

{ "target": "upper_50", "refId": "A", "type": "timeseries", "data": { "additional": "optional json" } }

You can also enter variables:

Additional data varible input

/annotations

POST /annotations

The JSON request body looks like this:

{
  "range": {
    "from": "2016-04-15T13:44:39.070Z",
    "to": "2016-04-15T14:44:39.070Z"
  },
  "rangeRaw": {
    "from": "now-1h",
    "to": "now"
  },
  "annotation": {
    "name": "deploy",
    "datasource": "JSON Datasource",
    "iconColor": "rgba(255, 96, 96, 1)",
    "enable": true,
    "query": "#deploy"
  },
   "variables": []
}

Grafana expects a response containing an array of annotation objects.

Field explanation:

  • text - Text for the annotation. (required)
  • title - The title for the annotation tooltip. (optional)
  • isRegion - Whether is region. (optional) (http://docs.grafana.org/reference/annotations/#adding-regions-events)
  • time - Time since UNIX Epoch in milliseconds. (required)
  • timeEnd - Time since UNIX Epoch in milliseconds (required if isRegion is true )
  • tags - Tags for the annotation. (optional)
[
  {
    "text": "text shown in body",
    "title": "Annotation Title",
    "isRegion": true,
    "time": "timestamp",
    "timeEnd": "timestamp",
    "tags": ["tag1"]
  }
]

Note: If the datasource is configured to connect directly to the backend, you also need to implement OPTIONS /annotations that responds with the correct CORS headers:

Access-Control-Allow-Headers:accept, content-type
Access-Control-Allow-Methods:POST
Access-Control-Allow-Origin:*

/tag-keys

POST /tag-keys

Example request body

{ }

The tag keys api returns:

[
    {"type":"string","text":"City"},
    {"type":"string","text":"Country"}
]

/tag-values

POST /tag-values

Example request body

{"key": "City"}

The tag values api returns:

[
    {"text": "Eins!"},
    {"text": "Zwei"},
    {"text": "Drei!"}
]

Development Setup

This plugin requires node 6.10.0. Use of Yarn is encouraged to build.

yarn install
yarn run build
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].