Setup and Configure Observability tool – Grafana
1.???? Connect to your AWS EC2 (Ubuntu Linux) instance
?2.???? Use the following command to become the root user on your Ubuntu EC2 instance.
$ sudo su
?3.???? On the Linux console, use the following commands to install the MySQL database service.
$ apt-get update
$ apt-get install mysql-server
?4.???? Type below command to access the MySQL command line. If prompted for password (for first time users), enter new password of your choice!
$ mysql -u root -p
?5.???? Use the following SQL command to create a database named grafana.
CREATE DATABASE grafana CHARACTER SET UTF8 COLLATE UTF8_BIN;
?6.???? Use the following SQL command to create a database user named grafana with password as Chaos123 (or any other password of your choice).
CREATE USER 'grafana'@'%' IDENTIFIED BY 'Chaos123';
?7.???? Give the SQL user named grafana permission over the database named grafana.
GRANT ALL PRIVILEGES ON grafana.* TO 'grafana'@'%';
quit;
?8.???? On the Linux console, use the following commands to configure the Grafana APT repository.
$ mkdir /downloads/grafana -p
$ cd /downloads/grafana
$ wget https://packages.grafana.com/gpg.key
$ apt-key add gpg.key
$ add-apt-repository 'deb [arch=amd64,i386] https://packages.grafana.com/oss/deb stable main'
$ apt-get update
?9.???? Use the following command to install Grafana.
$ apt-get install grafana
?10.? Edit the Grafana configuration file grafana.ini.
$ vi /etc/grafana/grafana.ini
?11.? Make the following configuration changes under the [Database] and [Session] sections. Please note that you need to change the MySQL username and password to reflect your environment.
[database]
type = mysql
host = 127.0.0.1:3306
name = grafana
user = grafana
password = Chaos123
[session]
provider = mysql
provider_config = grafana:Chaos123@tcp(127.0.0.1:3306)/grafana
?12.? Use the following command to start the Grafana service.
$ ?service grafana-server start
?13.? The Grafana service will start listening on TCP port 3000. Use the following command to see Grafana logs and verify if everything is working.
$ cat /var/log/grafana/grafana.log
t=2022-06-23T01:50:56+0000 lvl=info msg="Initializing ServerLockService" logger=server
t=2022-06-23T01:50:56+0000 lvl=info msg="Initializing UsageStatsService" logger=server
t=2022-06-23T01:50:56+0000 lvl=info msg="Initializing UserAuthTokenService" logger=server
t=2022-06-23T01:50:56+0000 lvl=info msg="Initializing CleanUpService" logger=server
t=2022-06-23T01:50:56+0000 lvl=info msg="Initializing NotificationService" logger=server
t=2022-06-23T01:50:56+0000 lvl=info msg="Initializing ProvisioningService" logger=server
t=2022-06-23T01:50:56+0000 lvl=info msg="Initializing TracingService" logger=server
t=2022-06-23T01:50:56+0000 lvl=info msg="Initializing Stream Manager"
t=2022-06-23T01:50:56+0000 lvl=info msg="HTTP Server Listen" logger=http.server address=0.0.0.0:3000 protocol=http subUrl= socket=
t=2022-06-23T01:50:57+0000 lvl=info msg="cleanup of expired auth tokens done" logger=auth count=0
?14.???? Open your browser and enter the Public IP address of your server plus :3000. In my case, the following URL was entered in the browser: https://15.206.250.8:3000/
The Grafana web interface should be launched!
15.???? On the prompt screen, enter the Grafana Default Password login information.
? Username: admin
? Password: admin
The system will ask you to change the Grafana default password.
?16.???? After a successful login using the new password, the Grafana dashboard will be launched.