You can Watch all our Tutorials and Training Videos for Free on ourYouTube Channel

How to Observe NGINX Controller with Loki?

How to Observe NGINX Controller with Loki, nginx controller with loki, setup nginx controller with loki, nginx controller loki example
How to Observe NGINX Controller with Loki

In today's world, observability is one of the most important factors to consider when it comes to managing and troubleshooting a web server. NGINX Controller is a popular tool for managing NGINX instances, and Loki is a powerful log aggregation and analysis tool that integrates well with NGINX Controller. In this article, we'll explore how to observe NGINX Controller with Loki.

Setting Up Loki

Before we can start observing NGINX Controller with Loki, we need to set up Loki. Here are the steps to follow:

  1. Install the Loki server by following the instructions on the official Loki website.

  2. Once Loki is installed, create a new configuration file for NGINX by running the following command:

touch /etc/loki/loki-nginx-config.yaml
  1. Edit the configuration file and add the following content:
- job_name: nginx
- targets: ['localhost']
job: nginx
host: my-nginx
__path__: /var/log/nginx/access.log
  1. Restart the Loki service:
systemctl restart loki

Observing NGINX Controller with Loki

With Loki set up, we can now start observing NGINX Controller. Here are the steps to follow:

  1. Log in to NGINX Controller and navigate to the "Logs" tab.

  2. Click on the "Settings" button in the top-right corner of the screen.

  3. In the "Log Streaming" section, click on the "Add" button.

  4. Select "Loki" from the "Type" dropdown menu.

  5. Enter the URL of your Loki server and the name of the configuration file you created earlier.

  6. Click on the "Test" button to verify that NGINX Controller can connect to Loki.

  7. Click on the "Save" button to save the configuration.

  8. Once the configuration is saved, NGINX Controller will start streaming logs to Loki. You can view the logs by running queries in the Loki UI.


Here are some examples of queries you can run in the Loki UI to observe NGINX Controller:

  1. To view all NGINX access logs:
  1. To view NGINX access logs with a specific status code:
{job="nginx"} |~ "status=404"
  1. To view NGINX access logs with a specific IP address:
{job="nginx"} |~ "ip="

Observing NGINX Controller with Loki is a powerful way to gain insights into your web server's performance and troubleshoot issues. By following the steps outlined in this article, you can easily set up Loki and start streaming logs from NGINX Controller. We hope this article has been helpful in getting you started with observing NGINX Controller with Loki.

Related Searches and Questions asked:

  • How to Collect Kubernetes Events?
  • How to Collect Logs with Fluentd?
  • Kubernetes Liveness and Readiness Probes
  • How to Configure Fluent Bit to Collect Logs for Your K8s Cluster?
  • That's it for this post. Keep practicing and have fun. Leave your comments if any.

    Cookie Consent
    We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
    It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
    AdBlock Detected!
    We have detected that you are using adblocking plugin in your browser.
    The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
    Site is Blocked
    Sorry! This site is not available in your country.
    whatsapp logo