In Part 1, We covered how to setup Grafana Loki and Grafana Agent to view Kubernetes pod logs

In Part 2, We will explore how to configure Grafana Agent on VM and export application logs to Grafana Loki.

Requirement:

  • Grafana Loki
  • Grafana agent
  • Windows VM with one application
  • Grafana Dashboard

Step 6: Install Grafana Agent in Windows VM,

Download latest Windows Grafana agent from this location,

Windows: https://github.com/grafana/agent/releases/download/v0.40.2/grafana-agent-installer.exe.zip

For other operating system refer here,

Next double click the downloaded exe and install it, by default in windows the installer path is,

C:\Program Files\Grafana Agent


Once installation is completed, We need to update the configuration based on our needs like which application logs we need to send to Grafana loki.

In our case, we installed Grafana Dashboard in the windows VM and configured the Grafana dashboard logs in Grafana agent.

Similarly, we can add multiple application with different Job names.

Copy the grafana agent config file from below repo and update the required changes according on your needs.

https://github.com/DevOpsArts/grafana_loki_agent/blob/main/agent-config.yaml

Next start the grafana agent service from services.msc

We can start manually by below command in command prompt as well.

In command Prompt go to, C:\Program Files\Grafana Agent

Execute below command,

grafana-agent-windows-amd64.exe --config.file=agent-config.yaml

This will help to find any issue with the configuration.

Note : Here the Grafana loki distributed service endpoint(which is configured in the agent-config.yaml) should be accessible from the windows VM


Step 7 : Access VM application logs in Grafana Loki,

Go to Grafana Dashboard > Home > Explore > Select Loki Datasource

In the filter section, select "Job" and value as the job name which is given in the agent-config.yaml. In our case the job name is "devopsart-vm"


Now We are able to view the Grafana Dashboard logs in Grafana Loki. You can create the Dashboard from here based on your preference.

In Part 2, We covered how to export Windows VM application logs to Grafana Loki and how to view them from the Grafana Dashboard.

In Part 3, We will cover how to export Azure PAAS services logs to Grafana Loki


Post a Comment

Previous Post Next Post