Monitoring Grafana
Grafana is an open-source platform for data analysis and monitoring. It enables you to query, visualize, and comprehend metrics from various systems, such as databases, servers, cloud services, and many others.
Prometheus Install
1 - Download latest software version
2 - Unzip
3 - Copying contents from the prometheus directory to the appropriate directory
4 - Remove downloaded files
5 - Creating service to run prometheus
5.1 - Create Prometheus Service File
Create a file:
Put the following content inside it:
5.2 - Reload daemons
6 - Execute the prometheus
7 - Checking if prometheus is really running
Something like this will appear:
8 - Enabling service in boot
Node exporter install
1 - Download latest software version
2 - Unzip
3 - Copying contents from the node_exporter directory to the appropriate directory
4 - Remove downloaded files
5 - Creating service to run node_exporter
5.1 - Create Node exporter Service File
Create a file:
Put the following content inside it:
5.2 - Reload daemons
6 - Execute the node_exporter
7 - Checking if node_exporter is really running
Something like this will appear:
8 - Enabling service in boot
Grafana Install
1 - Download latest software version and install
2 - Remove downloaded package
3 - Start grafana-server service
4 - Checking if grafana-server is really running
Something like this will appear:
5 - Enabling service in boot
6 - Access Grafana
Open Grafana at the following URL: http://host_ip:3000
Note: Open port 3000 in your firewall
Grafana's default credentials are:
username: admin password: admin
Note: a good security practice is to change the admin user password after the first login.
7 - Define Data Source
Select Data source option in Configuration section in left panel.
Select Prometheus datasource type.
Define Prometheus name and URL.
Click in Save and test button.
8 - Import Dashboard
Upload file and click in load button.
Define name of Dashboard, select folder and click in import button.
If everything happens normally, your dashboard will appear on the screen.
Grafana Alerts
1 - Access the Alert menu and then click Admin
2 - Click the "Add Alertmanager" button
3 - Set the URL where your external alertmanager instance is installed and click on the "Add alertmanagers" button
4 - Access the panel inside the Dashboard that you want to add the alert, right-click on the panel and then click "Edit"
5 - Click the "Alert" tab and click the "Create alert rule from this panel" button to create an alert with a direct link to this panel.
6 - Define the name of the alert, the folder, the function, select the query and the limit that will be used for the alert.
7 - Set the field "evaluate every" and "for", if necessary add a custom label and then click "Save and exit"
Nginx Install and enable HTTPS connections with Let's Encrypt
Enable Nginx in boot:
Certbot snap version install:
Configure /etc/nginx/sites-enabled/default :
Configure /etc/grafana/grafana.ini :
Restart nginx and grafana-server services :
Configuring names in hosts file
1 - Edit /etc/hosts file
Define the names that will be used for each host, and put them in the file /etc/hosts, follow exemple:
2 - Test configuration with ping command
Something like this will appear:
if the IP address that returns after the command matches the name you put in the /etc/hosts file, the configuration is correct
Now in the configuration of prometheus you can configure the host name instead of the IP
GitHub OAuth2 Authentication
1 - Register your application with GitHub
To enable the GitHub OAuth2 you must register your application with GitHub. GitHub will generate a client ID and secret key for you to use. When you create the application you will need to specify a callback URL. Specify this as callback:
Access your organization
Access Settings of your organization
Access Developer section and select OAuth App
Click in "New OAuth App"
Define OAuth app info
Get Client ID and generate new client secret
Store your Client ID and Client secret for alertmanager configuration
2 - Set root_url in grafana.ini file
3 - Enable GitHub in Grafana in grafana.ini file
4 - Restart grafana-server service
5 - After logout we have a login option with github
Last updated