Tuesday, April 20, 2021

Grafana with MySQL


Grafana is a web base tool that can be used for dispalying your metric data in for of graph and chart. It also help in doing alerting concept for your monitorig application. Grafana has many plugin and support large number of tool such as prometheus, elastic DB, My SQL db etc to have its monitoring and alerting done using beautiful graph and chart.

Lets first install Grafana. As we are using Windows download the binary from below location.
https://grafana.com/grafana/download

Once you install it by default it will start as a service. To check if it is working hit below url on browser and you will be asked for login credential.
By default it is admin/admin. You can change it as per your wish else click skip.

After login you will be able to see the default page of Grafana.

Lets check how we can build our first dashboard with Grafana using MySQL data.

As we know grafana need time-series data. To get this data we will download this dummy data from online.

For having dummy data i had downloaded the cvs from below location
https://www.stats.govt.nz/large-datasets/csv-files-for-download/

https://www.stats.govt.nz/assets/Uploads/Business-employment-data/Business-employment-data-December-2020-quarter/Download-data/business-employment-data-december-2020-quarter-csv.zip

Now lets add this cvs data in side our MySQL

Lets creat a new schema

CREATE SCHEMA siddhu ;

Now create table

CREATE TABLE siddhu.grafana_table (
idGRAFANA_TABLE INT NOT NULL,
Series_reference VARCHAR(45) NULL,
Period VARCHAR(45) NULL,
Data_value VARCHAR(45) NULL,
Industries VARCHAR(45) NULL,
Date DATE NULL,
PRIMARY KEY (idGRAFANA_TABLE));

Now lets insert the data from our csv files as shown below.

Now lets configure our MySQL datasource to our Grafana. Follow below image sequence wise

First create a data source.

Now lets create a dashboard

No comments: