Querying a HTTP JSON data source

Hello everyone, thanks for taking the time to read this topic and helping me out in advance.

Issue

The situation is as follows:
I have a JSON file laying on a server that is reachable through HTTP with the URL http://192.168.10.1:666/data.json, in Grafana I installed and configured the JSON file for parsing JSON responses from a backend, the specific JSON plugin is JSON plugin for Grafana | Grafana Labs . The situation is as follows, using this as a data source on a panel, I want to display a number that is correlated to the key “active_users”, the JSON file is as follows (some data is redacted for security reasons):

{
    "id":  18,
    "plan":  "premium",
    "created_at":  "2023-03-03T04:53:04.381+01:00",
    "starts_at":  "2022-02-11",
    "expires_at":  "2025-02-11",
    "historical_max":  449,
    "maximum_user_count":  449,
    "licensee":  {
                     *Redacted*
                 },
    "add_ons":  {

                },
    "expired":  false,
    "overage":  0,
    "user_limit":  449,
    "active_users":  345
} 

Question

How, with the given info, do I set up a panel that will query this data source and display the number of “active_users”?

The JSON plugin is not the right choice for this use case. JSON API or Infinity will work better from my point of view.

Also, we explained in the YouTube tutorial how to extract data from the JSON API and Infinity.

1 Like

Hi, @mikhailvolkov thanks for the reply and attached videos, I’m going to review the material and it out. I will report back with the results. Thanks again!

1 Like

As @mikhailvolkov said using infinity this is one approach

2 Likes

@mikhailvolkov successfully installed the JSON API plugin and set the data source to the server I mentioned in the original question http://192.168.10.1:666/, where I then set the path of the GET request inside the panel query section to /data.json. The query returns an empty JSON object i.e. {} and not the actual data, but when I request just the source without specifying any other path, I get a valid HTML document which allows for directory browsing. Do you maybe know what’s going on?

P.S. I’m adding these images to show you the current settings:

Little update:
Even when using the Postman service to check the HTTP response, it gets a valid JSON file back in this format:

It appears that the problem was in the HTTP request as Grafana could not parse it, I changed the API from which I was getting the response and it works perfectly now! Thanks for all the help.

1 Like