Still learning how to use Grafana. JSON import?

Hi,

I have been learning the basics about using Grafana and importing data for charts.
I have been using SQlite as JSON for importing data into Grafana.

Someone mentioned to me that as I am already using JavaScript why not use that ?
How would I import a JSON document into Grafana, is there a data source I should use or install ?

This is a part of the output I use from Node-RED ( home automation software ) to store data into my Sqlite JSON database.

let payload =                                                                               // Enter any new items to add to database, in this section.

    { IP92 :                                                                                // Why can't i use  let device = "IP92" ?
      
          [
            { 
              timestamp:    timestamp,
              iso:          iso,
              temperature:  temperature,
              humidity:     humidity,
              location:     device_location                                                 // Could not use "location" as function node, gave a warning of redefinition, why do others work ?
            }                                                                               
          ]
    };

payload =JSON.stringify(payload);

Any thoughts or ideas as to the best way to go ?
I will be storing 200 items of data every day for 3 to 4 years !

Thanks Gaz

So you are no longer using this?

As far as terminology:

“I have been using SQlite as JSON for importing data into Grafana”
When you say importing data into grafana, people will confuse it with importing json dashboards.

What do you mean by importing json into Grafana?

Instead of sqlite how about pushing your data to influxdb or mongodb or mysql or postgres?

if you want to stay with sqlite then maybe create your own node/express rest api to fetch data from sqlite and then feed that to grafana?

Hi yosiasz

I will continue using Sqlite with my data saved in it as ‘JSON objects’, as this is working well for me at the moment :grinning:

But I am just looking to see what is the easiest to use and maintain as my datasets increase.

I asked a different question on another site and someone suggest i should use JSON instead of my ‘SQLite with JSON objects’ .

Although I do not know exactly how I would do this ?

How do I import my data into Grafana,
I use the SQLite add on in Grafana and use queries to make the graph.

At the moment my SQLite database is on a Raspberry PI and Grafana is on my main PC.
I the have to copy the data from the RPI to my main PC for graphing.

I would like to be able to access this without copying the SQLite database every day ?
Not sure how I would do this.

Thanks Gaz

You would have to ask them what they meant :no_mouth:
There are tons of ways of saving your data to a json format.

I would avoid using the term import as you are not really importing anything into grafana. You are using a data source in your case sqlite, to create visualizations. Nothing is “imported”

I just imported your sample data into a sqlite and voila.

As you can see above I am using infinity to fetch data from my sqliteapi (GitHub - yosiasz/sqliteapi)

http://localhost:3000/temps

Hi yosiasz,

Thanks for correcting me on my terminology, I am still learning the correct words :grinning:

From the other site …
SQLite is a great tool, but (in my opinion), not for working with JSON. Check out various pure JavaScript JSON database modules (search on NPM). Always, use the right tool for the job.

Not sure how I would do this ?

Also on a different subject how would I use your API ?

As you can see above I am using infinity to fetch data from my sqliteapi (GitHub - yosiasz/sqliteapi)

Would it mean that I could access my SQLite from any PC in my house ?
As i mentioned I have to copy and paste my database file at the moment

Thanks for your patience and help … Gaz

yeah that is one opinion and they are absolutely right about right tool for right job. think of it though: grafana out of the box uses sqlite, your mobile phones uses it. json is a data type now available in sqlite so not sure what they mean. Cant speak for them and in what context they said that.

That api. depends how you want to use it. notice this

image

notice temps.db above, I just happen to copy the temps.db to the root of this project.
if you do not have experience using node application, well, good news: time to learn.

How are you copying the sqlite over to your pc? Manually?

depends if your home network is all interconnected. not part of this conversation. you would have to figure that out yourself.

1 Like

To copy across, I am using FreeFileSync and click on my link I made, every few hours
https://freefilesync.org/

are you doing this click manually?

yes I am , but would like it to be automatic

It does have realtimesync, but with learning everything else over the last few days decided for simplicity and click the link :grinning:

1 Like

:fearful: few options

1.look into telegraf
2. look into windows administrator tools to automate copying .db file using powershell, python, etc
3. look into cron, to do the same and copy it out to your PC or wherever grafana is installed
4. look into running that sqliteapi rest api using node js on the RPi if it allows nodejs on it
then from grafana hit the ip.address.of.rpi:/3000/temps to read the data, not copying required.
5. Look into moving your grafana to docker or some other virtualization.

Thanks yosiasz, for that will look at it in the morning, bed time here ! :zzz:

1 Like