百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

GrafanaJsonDatasource

> 编程语言
开源

Grafana 数据源,用于通过任意 HTTP 后端加载 JSON 数据

383 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Grafana 数据源,用于通过任意 HTTP 后端加载 JSON 数据

JSON API Grafana Datasource

[!WARNING] This project has been abandoned since January 1, 2026 and is no longer maintained. The JSON Datasource executes requests against arbitrary backends and parses JSON response into Grafana dataframes.

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.

If you want to add custom headers, keep Access set to Server.

API

An OpenAPI definition is at openapi.yaml. You can explore it using Swagger Editor.

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 /metrics to return available metrics.
  • POST /metric-payload-options to return a list of metric payload options.
  • POST /query to return panel data or annotations.

Those 3 endpoints are optional:

  • POST /variable to return data for Variable of type Query.
  • POST /tag-keys returning tag keys for ad hoc filters.
  • POST /tag-values returning tag values for ad hoc filters.

/metrics

POST /metrics

In Panel > Queries page. When configuring a query request using Builder mode, it will send the request to obtain the available metrics. The request body will carry the current metric and payload. In the Builder mode, if the reloadMetric value in the load configuration is true, the api will also be triggered when the value is modified / switched.

Example request:

{}

Or.

{
  "metric": "DescribeMetricList",
  "payload":{
    "cloud": "cf6591c5dad211eaa22100163e120f6e",
    "namespace": "MySQL"
  }
}

Example response:

…

The display is as follows:

/metric-payload-options

POST /metric-payload-options

When the payload type is select or multi-select and the payload options configuration is empty, expanding the drop-down menu will trigger this API. The request body will carry the current metric and payload.

Example Request:

{
  "metric":"DescribeMetricList", // Current metric.
  "payload": { // Current payload.
    "namespace":"acs_ecs"
  },
  "name":"cms_metric" // The payload name of the option list needs to be obtained.
}

Example Response:

[{ 
  "label": "CPUUtilization",
  "value": "CPUUtilization"
},{
  "label": "DiskReadIOPS",
  "value": "DiskReadIOPS"
},{
  "label": "memory_freeutilization",
  "value": "memory_freeutilization"
}]

The display is as follows:

/query

POST /query

Example 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", "payload": { "additional": "optional json" } },
     { "target": "Errors", "refId": "B" }
  ],
  "filters": [{
    "key": "City",
    "operator": "=",
    "value": "Berlin"
  }]
}

Response body can contain anything that is or can be converted to a Grafana DataFrame using this function. Returned data will be mapped to a DataFrame through that.

Example response (metric value as a float , unix timestamp 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]
    ]
  }
]
[
  {
    "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"
  }
]

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

Payload

Sending additional data for each metric is supported via the Payload input field that allows you to enter any JSON string.

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

{ "target": "upper_50", "refId": "A", "payload": { "additional": "optional json" } }

You can also enter variables:

/variable

POST /variable

Example request body:

{
  "payload":{"target":"systems"},
  "range":{
    "from":"2022-02-14T08:09:32.164Z",
    "to":"2022-02-21T08:09:32.164Z",
    "raw":{"from":"now-7d","to":"now"}
  }
}

"payload" is value from your input in Variable edit form.

Example response

[
  {"__text":"Label 1", "__value":"Value1"},
  {"__text":"Label 2", "__value":"Value2"},
  {"__text":"Label 3", "__value":"Value3"}
]

DataFrame is also supported.

/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!"}
]

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptapidatasourcegrafanagrafana-plugin

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言