{"id":13588796,"url":"https://github.com/simPod/GrafanaJsonDatasource","last_synced_at":"2025-04-08T06:32:43.443Z","repository":{"id":37048440,"uuid":"138867419","full_name":"simPod/GrafanaJsonDatasource","owner":"simPod","description":"Grafana datasource to load JSON data over your arbitrary HTTP backend","archived":false,"fork":false,"pushed_at":"2024-10-29T16:16:50.000Z","size":20620,"stargazers_count":353,"open_issues_count":8,"forks_count":72,"subscribers_count":15,"default_branch":"0.7.x","last_synced_at":"2024-10-29T16:58:41.038Z","etag":null,"topics":["api","datasource","grafana","grafana-plugin","hacktoberfest","http","json","json-api","rest","rest-api"],"latest_commit_sha":null,"homepage":"https://grafana.com/grafana/plugins/simpod-json-datasource/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simPod.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["simPod"]}},"created_at":"2018-06-27T10:36:49.000Z","updated_at":"2024-10-18T18:40:20.000Z","dependencies_parsed_at":"2023-10-28T17:29:52.269Z","dependency_job_id":"18c7a498-c397-4d85-afb4-63fca720e689","html_url":"https://github.com/simPod/GrafanaJsonDatasource","commit_stats":null,"previous_names":["simpod/grafana-json-datasource"],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simPod%2FGrafanaJsonDatasource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simPod%2FGrafanaJsonDatasource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simPod%2FGrafanaJsonDatasource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simPod%2FGrafanaJsonDatasource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simPod","download_url":"https://codeload.github.com/simPod/GrafanaJsonDatasource/tar.gz/refs/heads/0.7.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247589822,"owners_count":20963025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","datasource","grafana","grafana-plugin","hacktoberfest","http","json","json-api","rest","rest-api"],"created_at":"2024-08-01T15:06:56.253Z","updated_at":"2025-04-08T06:32:43.392Z","avatar_url":"https://github.com/simPod.png","language":"TypeScript","funding_links":["https://github.com/sponsors/simPod"],"categories":["TypeScript"],"sub_categories":[],"readme":"# JSON API Grafana Datasource\n\n[![Build](https://github.com/simPod/GrafanaJsonDatasource/workflows/CI/badge.svg)](https://github.com/simPod/GrafanaJsonDatasource/actions?query=workflow%3A%22CI%22)\n[![Marketplace](https://img.shields.io/badge/dynamic/json?logo=grafana\u0026color=F47A20\u0026label=marketplace\u0026prefix=v\u0026query=%24.items%5B%3F%28%40.slug%20%3D%3D%20%22simpod-json-datasource%22%29%5D.version\u0026url=https%3A%2F%2Fgrafana.com%2Fapi%2Fplugins)](https://grafana.com/grafana/plugins/simpod-json-datasource)\n[![Downloads](https://img.shields.io/badge/dynamic/json?logo=grafana\u0026color=F47A20\u0026label=downloads\u0026query=%24.items%5B%3F%28%40.slug%20%3D%3D%20%22simpod-json-datasource%22%29%5D.downloads\u0026url=https%3A%2F%2Fgrafana.com%2Fapi%2Fplugins)](https://grafana.com/grafana/plugins/simpod-json-datasource)\n\nThe JSON Datasource executes requests against arbitrary backends and parses JSON response into Grafana dataframes.\n\n## Installation\n\nTo install this plugin using the `grafana-cli` tool:\n\n```sh\n grafana-cli plugins install simpod-json-datasource\n ```\n\nSee [here](https://grafana.com/grafana/plugins/simpod-json-datasource/) for more information.\n\n## Setup\n\nWhen adding datasource add your API endpoint to the `URL` field. That's where datasource will make requests to.\n\n![Datasource setup](https://raw.githubusercontent.com/simPod/grafana-json-datasource/0.6.x/docs/images/datasource-setup.png)\n\nIf you want to add custom headers, keep Access set to `Server`.\n\n## API\n\nAn OpenAPI definition is at [openapi.yaml](https://github.com/simPod/GrafanaJsonDatasource/blob/0.6.x/openapi.yaml). \n_You can explore it using [Swagger Editor](https://editor-next.swagger.io/)_.\n\nTo work with this datasource the backend needs to implement 4 endpoints:\n\n- `GET /` with 200 status code response. Used for \"Test connection\" on the datasource config page.\n- `POST /metrics` to return available metrics.\n- `POST /metric-payload-options` to return a list of metric payload options.\n- `POST /query` to return panel data or annotations.\n\nThose 3 endpoints are optional:\n\n- `POST /variable` to return data for Variable of type `Query`.\n- `POST /tag-keys` returning tag keys for ad hoc filters.\n- `POST /tag-values` returning tag values for ad hoc filters.\n\n### /metrics\n\n`POST /metrics`\n\nIn `Panel \u003e 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.\n\nExample request:\n```json\n{}\n```\nOr. \n```json\n{\n  \"metric\": \"DescribeMetricList\",\n  \"payload\":{\n    \"cloud\": \"cf6591c5dad211eaa22100163e120f6e\",\n    \"namespace\": \"MySQL\"\n  }\n}\n```\nExample response:\n```json5\n[{\n  \"label\": \"Describe metric list\", // Optional. If the value is empty, use the value as the label\n  \"value\": \"DescribeMetricList\", // The value of the option.\n  \"payloads\": [{ // Configuration parameters of the payload.\n    \"label\": \"Namespace\", // The label of the payload. If the value is empty, use the name as the label.\n    \"name\": \"namespace\", // The name of the payload.\n    \"type\": \"select\", // If the value is select, the UI of the payload is a radio box. If the value is multi-select, the UI of the payload is a multi selection box; if the value is input, the UI of the payload is an input box; if the value is textarea, the UI of the payload is a multiline input box. The default is input.\n    \"placeholder\": \"Please select namespace\", // Input box / selection box prompt information.\n    \"reloadMetric\": true, // Whether to overload the metrics API after modifying the value of the payload.\n    \"width\": 10, // Set the input / selection box width to a multiple of 8px. \n    \"options\": [{ // If the payload type is select / multi-select, the list is the configuration of the option list.\n      \"label\": \"acs_mongodb\", // The label of the payload select option.\n      \"value\": \"acs_mongodb\", // The label of the payload value.\n    },{\n      \"label\": \"acs_rds\",\n      \"value\": \"acs_rds\",\n    }]\n  },{\n    \"name\": \"metric\",\n    \"type\": \"select\"\n  },{\n    \"name\": \"instanceId\",\n    \"type\": \"select\"\n  }]\n},{\n  \"value\": \"DescribeMetricLast\",\n  \"payloads\": [{\n    \"name\": \"namespace\",\n    \"type\": \"select\"\n  },{\n    \"name\": \"metric\",\n    \"type\": \"select\"\n  },{\n    \"name\": \"instanceId\",\n    \"type\": \"multi-select\"\n  }]\n}]\n```\nThe display is as follows:\n![Metrics in builder Mode](https://raw.githubusercontent.com/simPod/grafana-json-datasource/0.6.x/docs/images/builder-metrics.png)\n\n### /metric-payload-options\n\n`POST /metric-payload-options`\n\nWhen 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. \n\nExample Request:\n```json5\n{\n  \"metric\":\"DescribeMetricList\", // Current metric.\n  \"payload\": { // Current payload.\n    \"namespace\":\"acs_ecs\"\n  },\n  \"name\":\"cms_metric\" // The payload name of the option list needs to be obtained.\n}\n```\n\nExample Response:\n```json\n[{ \n  \"label\": \"CPUUtilization\",\n  \"value\": \"CPUUtilization\"\n},{\n  \"label\": \"DiskReadIOPS\",\n  \"value\": \"DiskReadIOPS\"\n},{\n  \"label\": \"memory_freeutilization\",\n  \"value\": \"memory_freeutilization\"\n}]\n```\nThe display is as follows:\n![Metric options in builder Mode](https://raw.githubusercontent.com/simPod/grafana-json-datasource/0.6.x/docs/images/builder-metric-options.png)\n\n### /query\n\n`POST /query`\n\nExample request:\n\n```json\n{\n  \"panelId\": 1,\n  \"range\": {\n    \"from\": \"2016-10-31T06:33:44.866Z\",\n    \"to\": \"2016-10-31T12:33:44.866Z\",\n    \"raw\": {\n      \"from\": \"now-6h\",\n      \"to\": \"now\"\n    }\n  },\n  \"rangeRaw\": {\n    \"from\": \"now-6h\",\n    \"to\": \"now\"\n  },\n  \"interval\": \"30s\",\n  \"intervalMs\": 30000,\n  \"maxDataPoints\": 550,\n  \"targets\": [\n     { \"target\": \"Packets\", \"refId\": \"A\", \"payload\": { \"additional\": \"optional json\" } },\n     { \"target\": \"Errors\", \"refId\": \"B\" }\n  ],\n  \"filters\": [{\n    \"key\": \"City\",\n    \"operator\": \"=\",\n    \"value\": \"Berlin\"\n  }]\n}\n```\n\n**Response body can contain anything that is or can be converted to a Grafana DataFrame using [this function](https://github.com/grafana/grafana/blob/1e024f22b8f767da01c9322f489d7b71aeec19c3/packages/grafana-data/src/dataframe/processDataFrame.ts#L284).\nReturned data will be mapped to a DataFrame through that.**\n\nExample response (metric value as a float , unix timestamp in milliseconds):\n\n```json\n[\n  {\n    \"target\":\"pps in\",\n    \"datapoints\":[\n      [622,1450754160000],\n      [365,1450754220000]\n    ]\n  },\n  {\n    \"target\":\"pps out\",\n    \"datapoints\":[\n      [861,1450754160000],\n      [767,1450754220000]\n    ]\n  },\n  {\n    \"target\":\"errors out\",\n    \"datapoints\":[\n      [861,1450754160000],\n      [767,1450754220000]\n    ]\n  },\n  {\n    \"target\":\"errors in\",\n    \"datapoints\":[\n      [861,1450754160000],\n      [767,1450754220000]\n    ]\n  }\n]\n```\n\n```json\n[\n  {\n    \"columns\":[\n      {\"text\":\"Time\",\"type\":\"time\"},\n      {\"text\":\"Country\",\"type\":\"string\"},\n      {\"text\":\"Number\",\"type\":\"number\"}\n    ],\n    \"rows\":[\n      [1234567,\"SE\",123],\n      [1234567,\"DE\",231],\n      [1234567,\"US\",321]\n    ],\n    \"type\":\"table\"\n  }\n]\n```\n\n_The relation between `target` in request and response is 1:n. You can return multiple targets in response for one requested `target`._\n\n#### Payload\n\nSending additional data for each metric is supported via the `Payload` input field that allows you to enter any JSON string.\n\nFor example, when `{ \"additional\": \"optional json\" }` is entered into `Payload` input, it is attached to the target data under `\"payload\"` key:\n\n```json\n{ \"target\": \"upper_50\", \"refId\": \"A\", \"payload\": { \"additional\": \"optional json\" } }\n```\n\nYou can also enter variables:\n\n![Additional data variable input](https://raw.githubusercontent.com/simPod/grafana-json-datasource/0.6.x/docs/images/additional-data-variable-input.png)\n\n### /variable\n\n`POST /variable`\n\nExample request body:\n\n```json\n{\n  \"payload\":{\"target\":\"systems\"},\n  \"range\":{\n    \"from\":\"2022-02-14T08:09:32.164Z\",\n    \"to\":\"2022-02-21T08:09:32.164Z\",\n    \"raw\":{\"from\":\"now-7d\",\"to\":\"now\"}\n  }\n}\n```\n\n`\"payload\"` is value from your input in Variable edit form.\n\nExample response\n\n```json\n[\n  {\"__text\":\"Label 1\", \"__value\":\"Value1\"},\n  {\"__text\":\"Label 2\", \"__value\":\"Value2\"},\n  {\"__text\":\"Label 3\", \"__value\":\"Value3\"}\n]\n```\n\nDataFrame is also supported.\n\n### /tag-keys\n\n`POST /tag-keys`\n\nExample request body\n\n```json\n{ }\n```\n\nThe tag keys api returns:\n\n```json\n[\n    {\"type\":\"string\",\"text\":\"City\"},\n    {\"type\":\"string\",\"text\":\"Country\"}\n]\n```\n\n### /tag-values\n\n`POST /tag-values`\n\nExample request body\n\n```json\n{\"key\": \"City\"}\n```\n\nThe tag values api returns:\n\n```json\n[\n    {\"text\": \"Eins!\"},\n    {\"text\": \"Zwei\"},\n    {\"text\": \"Drei!\"}\n]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FsimPod%2FGrafanaJsonDatasource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FsimPod%2FGrafanaJsonDatasource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FsimPod%2FGrafanaJsonDatasource/lists"}