bbartling
bbartling

Reputation: 3514

grafana display a text/string value from an API

How do you display a text/string value in Grafana with the data fetched from the JSON API plugin?

My datasource the url is https://bensapi.pythonanywhere.com/ that returns:

{"message":"Hello from Flask!","status":"success"}

Setting up the data source for this URL and EXPLORE option it works, the string on the bottom is what I am looking to display:

enter image description here

In grafana selecting this type of chart:

enter image description here

And trying to recreate my steps from the EXPLORE process of the data source I cant seem to plot the Hello from Flask string on a dashboard. Any tips appreciated.

enter image description here

Upvotes: 4

Views: 13542

Answers (3)

bbartling
bbartling

Reputation: 3514

So what I ended up using with the JSON API is the TABLE panel to display text values from a JSON API PAYLOAD. Looks like this below, the API JSON PATH to represent the data into columns:

enter image description here

Upvotes: 0

dnnshssm
dnnshssm

Reputation: 1305

While Jan's answer is correct for the graph and time series panel, you stated that you are using the stat panel.

There you can set what type of values are shown: In the panel settings go to Value options -> Fields. There the default is Numeric Fields. So when you haven't changed that, it is the reason 'No data' is shown for your string. Set it to All Fields to make the panel show strings.

Upvotes: 5

Jan Garaj
Jan Garaj

Reputation: 28714

See the doc of JSON API plugin:

https://marcus.se.net/grafana-json-datasource/troubleshooting#why-do-i-get-unable-to-graph-data-when-i-try-to-graph-the-query-results

The Graph and Time series panels can only display time series. To create a query that returns time series, make sure that it contains at least two fields:

A Time field that contains the timestamps for the X-axis A Number field that contains the values for the Y-axis

So your API response (simple string) can't be graphed.

Upvotes: 1

Related Questions