"Effortless Log Monitoring with Grafana, Loki, and Promtail: Visualize and Analyze Your Logs for Actionable Insights"

"Effortless Log Monitoring with Grafana, Loki, and Promtail: Visualize and Analyze Your Logs for Actionable Insights"

Table of contents

No heading

No headings in the article.

This Article is focused on monitoring logs and if you want to know more about the installation process, then please check out the article link below:

Link: https://amitblog.hashnode.dev/complete-guide-installing-grafana-loki-and-promtail-for-powerful-log-monitoring-and-visualization

In the last article, we showed how we install grafana, loki and promtail and how we access Loki through port 3100 with the public IP address.

Now, This article is focused on monitoring and visualization, let's get started:

First, Loki webpage which is showing the logs after we access

Now, go to the Grafana home page and select Loki and there add name and URL as http://localhost:3100/ because in the Loki config file, we added the IP address of the local system IP address.

Next, click save & test - As we can see - "Data source successfully connected"

Next, click on "Explore views" on Data source successfully connected

Now, on the label filter, we select - jobs and varlogs, which we will be getting from promtail config by default

Promtail config

After selecting jobs and varlogs, next is to "Run query"

After running query, we will get the logs

Next, we do some edits to promtail config file to see grafana logs.

In the VM (virtual Machine) go to cd /var/log/grafana and if we do ls (list) we can see grafana.log file, and copy the local path by pwd command

Next, open the Promtail config file using an editor like Vim and add a new target for Grafana and add the location path for the Grafana log that we copied earlier

After making changes to the Promtail config file next is to "Restart" the Promtail docker container, so that it can apply the change

Now, go to grafana - Loki, and here we can on logs we have both varlogs and grafanalogs

Now select the job and varlogs and select the option "add to dashboard"

In the option, New dashboard, select Open dashboard

As we can see the logs are added to the dashboard and now to add visualization - select Add - Visualization

As it shows No data to show

As there is no data, we will just install Nginx on our VM to get the logs

Now, on Label filters add job and varlogs and add input as "nginx" and time forecast for last 5 min and select run query

Remember to select the Data sources as Loki - 1 as we name it Loki - 1

Now, select the option - Open visualization suggestions

Now we are able to see the nginx logs

Now to add visualization, On label filters select - + operation - range function - rate and click on the run query

Select the visual effect suitable for you to monitor and add to the dashboard

Here we also added the logs for Docker and added visuals by just getting input Docker in label filters and adding operation to the logs same as nginx logs

That's it for Grafana and how to install and monitor logs with the use of various tools

Thanks for taking the time to read my blogs!!!!!