Difference between revisions of "Grafana"

From The TinkerNet Wiki
Jump to navigation Jump to search
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
Originally written by Grant Reed
 
Originally written by Grant Reed
 +
 +
(you will need '''gnupg''')
  
 
==How To Install Grafana on Linux Mint 20==
 
==How To Install Grafana on Linux Mint 20==
Line 8: Line 10:
 
There are 2 versions that could be installed -OSS and Enterprise. It is suggested by Grafana to install the Enterprise version for stability. We will be installing the latest version in this setup. Run the following in a teminal window that is local or SSH'd into your system that will host it...
 
There are 2 versions that could be installed -OSS and Enterprise. It is suggested by Grafana to install the Enterprise version for stability. We will be installing the latest version in this setup. Run the following in a teminal window that is local or SSH'd into your system that will host it...
  
* <code>sudo apt-get install -y apt-transport-https</code>
+
*<code>sudo apt-get install -y apt-transport-https</code>
* <code>sudo apt-get install -y software-properties-common wget</code>
+
*<code>sudo apt-get install -y software-properties-common wget</code>
* <code>wget -q -O - <nowiki>https://packages.grafana.com/gpg.key</nowiki> | sudo apt-key add -</code>
+
*<code>wget -q -O - <nowiki>https://packages.grafana.com/gpg.key</nowiki> | sudo apt-key add -</code>
  
 
===Add the repository to the list and install===
 
===Add the repository to the list and install===
* <code>echo "deb <nowiki>https://packages.grafana.com/enterprise/deb</nowiki> stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list</code>
+
 
* <code>sudo apt-get update</code>
+
*<code>echo "deb <nowiki>https://packages.grafana.com/enterprise/deb</nowiki> stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list</code>
* <code>sudo apt-get install grafana-enterprise</code>
+
*<code>sudo apt-get update</code>
 +
*<code>sudo apt-get install grafana-enterprise</code>
  
 
===Start the Server===
 
===Start the Server===
* <code>sudo systemctl daemon-reload</code>
+
 
* <code>sudo systemctl start grafana-server</code>
+
*<code>sudo systemctl daemon-reload</code>
 +
*<code>sudo systemctl start grafana-server</code>
  
 
===Verify that its running properly===
 
===Verify that its running properly===
* <code>sudo systemctl status grafana-server</code>
+
 
 +
*<code>sudo systemctl status grafana-server</code>
  
 
===Now configure it to start at boot===
 
===Now configure it to start at boot===
* <code>sudo systemctl enable grafana-server.service</code>
+
 
 +
*<code>sudo systemctl enable grafana-server.service</code>
  
 
===Package details===
 
===Package details===
Line 47: Line 53:
 
Default user is admin/admin and it will make you change the password
 
Default user is admin/admin and it will make you change the password
  
The test install login is admin/Fiddlehead
+
==Using this with Node Red==
 +
[[Node-RED - with Grafana|Watch this space...]]
  
 
==Connecting with InfluxDB==
 
==Connecting with InfluxDB==
Line 80: Line 87:
 
You are connected to the proper database and all is well.
 
You are connected to the proper database and all is well.
  
== Adding in a data stream from Node Red ==
+
==Oddities & Issues==
Presumably, you went through all this trouble so you could graph and map the giant amount of data you are creating in your IoT gear around your home. Open Node Red and go to '''Manage Pallete.''' Chances are you installed the v2.0 of Influx DB so you will need the ''''NodeRed - Contrib - Stackhero- InfluxDB - v2'''<nowiki/>' pallette.  
+
If you keep the UI web page open for a while, sometimes it'll log you out without giving ANY indication that it's done so.  If you happen to have a dashboard open that you're working on & try to save it, Grafana will say "NO!".  At this point, attempting to log in will throw away your edits.  
 +
 
 +
There IS a solution!
 +
 
 +
*Duplicate the tab
 +
*Login on the duplicate tab
 +
*Return to the one you were working in
 +
*& pretend it never happened.
 +
 
 +
And a way to decrease the annoyance (found [https://community.grafana.com/t/admin-getting-logged-out-frequently/37953/3 here]):
 +
 
 +
*Edit the [https://grafana.com/docs/grafana/latest/setup-grafana/configure-grafana/ configuration]
 +
**<code>sudo vi /etc/grafana/grafana.ini</code>
 +
*Change <code>token_rotation_interval_minutes</code> to something larger than the default of '''10''' minutes.
 +
*There also seems to be mention of changing <code>login_maximum_inactive_lifetime_days</code> but it doesn't seem to exist. (Possibly <code>login_maximum_inactive_lifetime_duration</code>?)
 +
 
 +
The documentation does not seem to mention it, but I suspect you need to restart Grafana after editing the configuration...
  
Utilizing that pallete........ Dunno yet
+
*<code>sudo systemctl start grafana-server</code>

Latest revision as of 20:03, 12 March 2023

Originally written by Grant Reed

(you will need gnupg)

How To Install Grafana on Linux Mint 20

https://grafana.com/docs/grafana/latest/installation/debian/

Installation was tested on a fresh VM of Mint 20 so if i screwed something up, it wasn't going to be my Automation server

There are 2 versions that could be installed -OSS and Enterprise. It is suggested by Grafana to install the Enterprise version for stability. We will be installing the latest version in this setup. Run the following in a teminal window that is local or SSH'd into your system that will host it...

  • sudo apt-get install -y apt-transport-https
  • sudo apt-get install -y software-properties-common wget
  • wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -

Add the repository to the list and install

  • echo "deb https://packages.grafana.com/enterprise/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
  • sudo apt-get update
  • sudo apt-get install grafana-enterprise

Start the Server

  • sudo systemctl daemon-reload
  • sudo systemctl start grafana-server

Verify that its running properly

  • sudo systemctl status grafana-server

Now configure it to start at boot

  • sudo systemctl enable grafana-server.service

Package details

  • Installs binary to /usr/sbin/grafana-server
  • Installs Init.d script to /etc/init.d/grafana-server
  • Creates default file (environment vars) to /etc/default/grafana-server
  • Installs configuration file to /etc/grafana/grafana.ini
  • Installs systemd service (if systemd is available) name grafana-server.service
  • The default configuration sets the log file at /var/log/grafana/grafana.log
  • The default configuration specifies a SQLite3 db at /var/lib/grafana/grafana.db
  • Installs HTML/JS/CSS and other Grafana files at /usr/share/grafana

Getting Started with Grafana

The home for this information is here:

https://grafana.com/docs/grafana/latest/getting-started/getting-started/

Open a browser to your new Grafana install, in my case its 192.168.1.139:3000

Default user is admin/admin and it will make you change the password

Using this with Node Red

Watch this space...

Connecting with InfluxDB

https://grafana.com/docs/grafana/latest/datasources/influxdb/

Open up the Web-GUI for Grafana ('ServerName:3000). Log in and click on the Configuration icon (looks like a gear) on the left tab. One of the options will be Data Sources. Click that and select Add Data Source.

Give the data source a meaningful name. I gave mine 'InfluxDB'. Select InfluxDB under Time series databases.

My databases are not set up for authorization or credentials since this setup will not be allowed to go play in the streets so all auth is turned off.

This will open a screen titled Data Sources / InfluxDB

Give this new data source a Name (or leave it as the default of InfluxDB).

Leave Query Language as the default InfluxQL.

Fill in the URL box with the address of your database server. (On a typical installation, with the database & Grafana on a single machine, this will be http://localhost:8086)

Scroll down to InfluxDB Details.

Put in the name of your new database.

Put in the username and password.

Optional: Select the type of http access you want. The simple version is GET. If you are going to be doing long requests then select 'POST.

Hit Save and Test.

You should get a green bar that says Data source is working.

You are connected to the proper database and all is well.

Oddities & Issues

If you keep the UI web page open for a while, sometimes it'll log you out without giving ANY indication that it's done so. If you happen to have a dashboard open that you're working on & try to save it, Grafana will say "NO!". At this point, attempting to log in will throw away your edits.

There IS a solution!

  • Duplicate the tab
  • Login on the duplicate tab
  • Return to the one you were working in
  • & pretend it never happened.

And a way to decrease the annoyance (found here):

  • Edit the configuration
    • sudo vi /etc/grafana/grafana.ini
  • Change token_rotation_interval_minutes to something larger than the default of 10 minutes.
  • There also seems to be mention of changing login_maximum_inactive_lifetime_days but it doesn't seem to exist. (Possibly login_maximum_inactive_lifetime_duration?)

The documentation does not seem to mention it, but I suspect you need to restart Grafana after editing the configuration...

  • sudo systemctl start grafana-server