Skip to content
This repository was archived by the owner on Aug 4, 2025. It is now read-only.

Commit ac90974

Browse files
committed
modify routes in readme file
1 parent eb31262 commit ac90974

File tree

1 file changed

+119
-4
lines changed

1 file changed

+119
-4
lines changed

README.md

Lines changed: 119 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,83 @@ for example, if you are using Grafana with containers, add:
3636

3737
You REST API application should return data in the following format:
3838

39-
### Fetch Graph
39+
> Note: You API application should handle CORS policy. Otherwise you will face CORS-Policy error in Grafana.
4040
41-
This route returns the graph which is intended to visualize.
41+
### Fetch Graph Fields
4242

43-
endpoint: `/api/fetchgraph`
43+
This route returns the nodes and edges fields defined in the [parameter tables](https://grafana.com/docs/grafana/latest/visualizations/node-graph/#data-api).
44+
This would help the plugin to create desired parameters for the graph.
45+
For nodes, `id` and for edges, `id`, `source` and `target` fields are required and the other fields are optional.
46+
47+
endpoint: `/api/graph/fields`
48+
49+
method: `GET`
50+
51+
content type: `application/json`
52+
53+
content format example:
54+
55+
```json
56+
{
57+
"edges_fields": [
58+
{
59+
"field_name": "id",
60+
"type": "string"
61+
},
62+
{
63+
"field_name": "source",
64+
"type": "string"
65+
},
66+
{
67+
"field_name": "target",
68+
"type": "string"
69+
},
70+
{
71+
"field_name": "mainStat",
72+
"type": "number"
73+
}
74+
],
75+
"nodes_fields": [
76+
{
77+
"field_name": "id",
78+
"type": "string"
79+
},
80+
{
81+
"field_name": "title",
82+
"type": "string"
83+
},
84+
{
85+
"field_name": "mainStat",
86+
"type": "string"
87+
},
88+
{
89+
"field_name": "secondaryStat",
90+
"type": "number"
91+
},
92+
{
93+
"color": "red",
94+
"field_name": "arc__failed",
95+
"type": "number"
96+
},
97+
{
98+
"color": "green",
99+
"field_name": "arc__passed",
100+
"type": "number"
101+
},
102+
{
103+
"displayName": "Role",
104+
"field_name": "detail__role",
105+
"type": "string"
106+
}
107+
]
108+
}
109+
```
110+
111+
### Fetch Graph Data
112+
113+
This route returns the graph data which is intended to visualize.
114+
115+
endpoint: `/api/graph/data`
44116

45117
method: `GET`
46118

@@ -49,7 +121,34 @@ content type: `application/json`
49121
Data Format example:
50122

51123
```json
52-
{"edges":[{"id":"1","mainStat":"53/s","source":"1","target":"2"}],"nodes":[{"arc__failed":0.7,"arc__passed":0.3,"detail__zone":"load","id":"1","subTitle":"instance:#2","title":"Service1"},{"arc__failed":0.5,"arc__passed":0.5,"detail__zone":"transform","id":"2","subTitle":"instance:#3","title":"Service2"}]}
124+
{
125+
"edges": [
126+
{
127+
"id": "1",
128+
"mainStat": "53/s",
129+
"source": "1",
130+
"target": "2"
131+
}
132+
],
133+
"nodes": [
134+
{
135+
"arc__failed": 0.7,
136+
"arc__passed": 0.3,
137+
"detail__zone": "load",
138+
"id": "1",
139+
"subTitle": "instance:#2",
140+
"title": "Service1"
141+
},
142+
{
143+
"arc__failed": 0.5,
144+
"arc__passed": 0.5,
145+
"detail__zone": "transform",
146+
"id": "2",
147+
"subTitle": "instance:#3",
148+
"title": "Service2"
149+
}
150+
]
151+
}
53152
```
54153

55154
For more detail of the variables please visit [here](https://grafana.com/docs/grafana/latest/visualizations/node-graph/#data-api).
@@ -65,6 +164,22 @@ method: `GET`
65164

66165
success status code: `200`
67166

167+
## API Example
168+
169+
In `example` folder you can find a simple API application in Python Flask.
170+
171+
### Requirements:
172+
173+
- flask
174+
- flask-cors
175+
176+
### Run
177+
178+
```bash
179+
python run.py
180+
```
181+
The application will be started on `http://localhost:5000`
182+
68183
## Compiling the data source by yourself
69184

70185
1. Install dependencies

0 commit comments

Comments
 (0)