Grafana wants information to be helpful. Jack Wallen walks you thru the method of utilizing a MySQL database as a supply for information visualization in Grafana.
Grafana is without doubt one of the most widely-used interactive information visualization instruments in the marketplace. It’s open-source, highly effective, extremely configurable and free to make use of. I’ve walked you thru the method of installing Grafana on Ubuntu Server 20.04, and this time round I’ll assist you to join that newly put in platform to a MySQL database, so you’ll be able to visualize that information.
Large information: Extra must-read protection
Grafana means that you can connect with quite a few information sources (Google Sheets, Amazon Timestream, Elasticsearch and lots of databases). As a result of MySQL is such a preferred database, I believed that might be a fantastic information supply to make use of as an illustration. This can even refresh your reminiscence on the right way to set MySQL up for distant connections.
SEE: 40+ open source and Linux terms you need to know (TechRepublic Premium)
What you’ll want
To make this work, you’re going to want a operating occasion of Grafana, a operating occasion of MySQL and a consumer with sudo privileges. I’m going to imagine your occasion of MySQL is on a distant Linux server.
Easy methods to configure MySQL for distant connection
The very first thing we should do is configure the MySQL server to permit distant connections. On high of that, we’re going to create a particular consumer that has particular permissions for the database we’ll view on Grafana.
First, log into your MySQL server and open the MySQL configuration file with:
sudo nano /and so on/mysql/mysql.conf.d/mysqld.cnf
In that file, search for the road:
bind-address = 127.0.0.1
Change that to:
bind-address = 0.0.0.0
Save and shut the file. Restart the MySQL service with:
sudo systemctl restart mysql
Subsequent, we have to create a brand new consumer and provides it the proper permissions. Log in to the MySQL console with:
sudo mysql -u root -p
Be sure you know which database you’re going to be utilizing. You’ll be able to checklist them out with:
Create the brand new consumer with:
CREATE USER ‘grafanareader’ IDENTIFIED BY ‘PWORD’;
The place PWORD is a robust/distinctive password for the brand new consumer.
Now, we are able to grant that new consumer the SELECT permission for the database with:
GRANT SELECT ON DB.* TO ‘grafanareader’;
The place DB is the identify of the database to be learn by Grafana.
Flush the privileges and exit from the MySQL console with:
Your database server is now prepared.
Easy methods to join Grafana to MySQL
Log into your Grafana occasion and click on the gear icon within the left sidebar. From the ensuing popup, click on Knowledge Sources. Within the subsequent window, scroll down and choose MySQL from the itemizing. You’ll then be offered with the required configuration choices for a MySQL information connection (Determine A).
The MySQL Grafana configuration editor.
Right here’s what you need to fill out:
Host—the IP tackle or area identify of the MySQL internet hosting server together with the port used for the database server (default is 3306).
Database—the database for use as a supply.
Password—PWORD used to create grafanareader within the MySQL console.
You may additionally must allow Skip TLS Confirm.
Configure these choices and click on Save & Check. It’s best to finally see Database Connection OK (Determine B).
Our MySQL connection is nice to go.
Congratulations, you now have Grafana linked to a distant MySQL server. In our subsequent piece within the sequence, we’ll create a brand new dashboard to view among the information from the supply.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the most recent tech recommendation for enterprise execs from Jack Wallen.