News and blog
NXLog main page
  • Products
    NXLog Platform
    Log collection
    Log management and analytics
    Log storage
    NXLog Community Edition
    Integrations
    Professional Services
  • Solutions
    Use cases
    Specific OS support
    SCADA/ICS
    Windows event log
    DNS logging
    MacOS logging
    Open Telemetry
    Solutions by industry
    Financial Services
    Government & Education
    Entertainment & Gambling
    Telecommunications
    Medical & Healthcare
    Military & Defense
    Law Firms & Legal Counsel
    Industrial & Manufacturing
  • Pricing
    Licensing
    Plans
  • Partners
    Find a Reseller
    Partner Program
    Partner Portal
  • Resources
    Documentation
    Blog
    White papers
    Videos
    Webinars
    Case Studies
    Community Program
    Community Forum
  • About
    Company
    Careers
  • Support
    Support portals
    Contact us

NXLog Platform
Log collection
Log management and analytics
Log storage
NXLog Community Edition
Integrations
Professional Services

Use Cases
Specific OS support
SCADA/ICS
Windows event log
DNS logging
MacOS logging
Open Telemetry
Solutions by industry
Financial Services
Government & Education
Entertainment & Gambling
Telecommunications
Medical & Healthcare
Military & Defense
Law Firms & Legal Counsel
Industrial & Manufacturing

Licensing
Plans

Find a Reseller
Partner Program
Partner Portal

Documentation
Blog
White papers
Videos
Webinars
Case Studies
Community Program
Community Forum

Company
Careers

Support portals
Contact us
Let's Talk
  • Start free
  • Interactive demo
Let's Talk
  • Start free
  • Interactive demo
NXLog search
  • Loading...
Let's Talk
  • Start free
  • Interactive demo
October 20, 2025 security

From web server logs to metrics: Visualizing NGINX logs with Prometheus and Grafana

By Arielle Bonnici

Share
ALL ANNOUNCEMENT COMPARISON COMPLIANCE DEPLOYMENT SECURITY SIEM STRATEGY RSS

When users start reporting slow responses or intermittent errors from your web applications, your first go-to is your web server logs. But did you know those same logs can provide more than just troubleshooting clues? When analyzed with the right tools, they give system administrators and DevOps teams real-time visibility into your web environment, enabling them to monitor web servers proactively, rather than reactively.

In this post, we’re going to show you how you can uncover web server performance issues and potential attacks early on by collecting NGINX access logs with NXLog Agent, transforming them into Prometheus metrics, and visualizing them with Grafana.

This article continues our series on log visualization. In our previous posts, we explored Visualizing OpenVPN logs and Windows security monitoring with Elasticsearch and Kibana. Now, we’ll shift focus to web infrastructure monitoring and how transforming log data into actionable observability helps your team drive better performance and security awareness.

Why monitor web access logs?

Web access logs are more than a record of HTTP requests. They capture valuable details about client requests, server responses, and overall traffic patterns. Monitoring these logs provides insight into three key areas:

Performance monitoring

Metrics such as response time, request rate, and error frequency help you identify problematic endpoints, resource shortages, and performance issues before they impact users. Instead of reacting to complaints, track service health in real time and optimize your web applications proactively.

Operational visibility

Web access logs provide you with a clear view of your web environment’s activity. You can monitor traffic peaks, identify your busiest endpoints, and observe which regions the traffic is coming from. This operational awareness helps with capacity planning and troubleshooting unexpected changes in traffic patterns.

Security awareness

Web access logs often contain the first signs of malicious activity, such as failed login attempts, scanning for vulnerabilities, and unusual bursts of traffic. Visualizing this data helps you spot anomalies and respond to potential attacks early on. Regularly monitoring web traffic also helps you establish a baseline for normal activity, making it easier to detect deviations.

Understanding NGINX access logs

NGINX generally writes its access logs to the /var/log/nginx/access.log file on Linux and the C:\nginx\logs\access.log file on Windows. It records every request as a single line of text containing information such as:

  • Client IP address — who made the request.

  • Request timestamp — when the request was made.

  • HTTP request method and URL — the endpoint requested.

  • HTTP status code — the server’s response.

  • Response size — data sent back to the client in bytes.

  • User agent — the application that made the request.

For example, a web access event may appear as follows:

151.189.176.84 - - [12/Oct/2025:10:14:23 +0200] "GET /october-2025-newsletter HTTP/2.0" 404 18240 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"

Breaking it down:

  • 151.189.176.84 — the client IP address.

  • 12/Oct/2025:10:14:23 +0200 — the request timestamp.

  • GET — the HTTP request method.

  • /october-2025-newsletter — the URL.

  • 404 — the HTTP status code, in this case, Not Found.

  • 18240 — the response size.

  • Mozilla/5.0 (Windows NT 10.0; Win64; x64) — the user agent.

NGINX also allows you to define custom log formats and include additional fields to expose deeper insights. For simplicity’s sake, we will stick to the default log format in this blog post.

Collecting NGINX access logs and converting them to Prometheus metrics

NXLog Agent is a lightweight, cross-platform log collection agent that can parse raw NGINX access logs and convert them into Prometheus metrics. Here is how we can approach this:

  • Use the File input module to collect the NGINX access log.

  • Parse the log records using a regular expression.

Prometheus is built for time-series data, making it an ideal choice for monitoring web server metrics. NXLog Agent provides a dedicated Prometheus output module, which exposes processed telemetry data as metrics in Prometheus exposition format.

Here is the complete configuration:

<Input nginx_access>
    Module         im_file
    File           '/var/log/nginx/access.log'
    <Exec>
        if $raw_event =~ /(?x)^(\S+)\ \S+\ (\S+)\ \[([^\]]+)\]\ \"(\S+)\ (.+)
                          \ HTTP\/\d\.\d\"\ (\S+)\ (\S+)\ \"([^\"]+)\"
                          \ \"([^\"]+)\"/ {
            $ipAddress = $1;
            if $2 != '-' $AccountName = $2;
            $EventTime = parsedate($3);
            $http_method = $4;
            $http_url = $5;
            $http_status_code = $6;
            if $7 != '-' $file_size = $7;
            if $8 != '-' $http_referer = $8;

            delete($raw_event);
        }

        if ($http_status_code == '200') { (1)
            drop();
        }
    </Exec>
</Input>

<Output prometheus>
    Module         om_prometheus
    ListenAddr     0.0.0.0:9464 (2)
    MappingFile    '/opt/nxlog/etc/prometheus_mappings.json' (3)
</Output>

<Route nginx_to_prometheus>
    Path           nginx_access => prometheus
</Route>
1 Discards records that have a 200 OK response code.
2 Exposes the Prometheus metrics via an HTTP endpoint listening on port 9464.
3 The MappingFile directive specifies the path to the JSON schema file.

This configration requires the following schema file:

prometheus_mappings.json
{
  "metrics": {
    "gauge": [
      {
        "name": "http_status_code",
        "labels": ["http_method", "http_url", "file_size", "ipAddress", "http_referer"]
      }
    ]
  }
}

Configuring an agent is easy with NXLog Platform. Find your agent, paste the configuration into the editor, and save your changes.

NXLog Agent configuration
Figure 1. NXLog Agent configuration in NXLog Platform

You can also create a configuration and assign it to multiple agents.

Once NXLog Agent is up and running, you can verify your configuration by accessing http://localhost:9464/metrics in a browser on the same machine where the agent is running.

NXLog Agent Prometheus endpoint
Figure 2. NXLog Agent Prometheus endpoint

To configure Prometheus to scrape this endpoint, add it to your scrape configuration. For example:

scrape_configs:

  - job_name: "WEBSRV-01"
    static_configs:
      - targets: ["192.168.1.123:9464"] (1)
1 Replace the IP address with the NXLog Agent host’s IP address.

By turning unstructured access logs into Prometheus metrics, you make them queryable and ready to visualize in Grafana. Let’s dive into that next.

Visualizing NGINX metrics in Grafana

Once Prometheus starts collecting metrics from NXLog Agent, you can start exploring them in its expression browser. For example, enter http_status_code in the expression console and click Execute. This returns a list of HTTP status codes with their respective labels.

Query NGINX metrics in Prometheus
Figure 3. Query NGINX metrics in Prometheus

This interface is excellent for troubleshooting and validating metrics. However, the real value comes when you connect your metrics to Grafana. Grafana turns raw metrics into interactive charts and dashboards, making it easier to spot trends and anomalies at a glance. For example, you can build an NGINX dashboard with charts such as:

  • Failed requests by URL to help you identify problematic endpoints.

  • Failed requests by source IP address to easily spot potential malicious activity.

Grafana dashboard for NGINX metrics
Figure 4. Grafana dashboard for NGINX metrics

To help you get started, we prepared a Grafana dashboard with these charts. You can import it into Grafana by navigating to Dashboards and clicking New > Import. Then, upload the .json file, fill in the remaining fields, and click Import.

By visualizing NGINX metrics through Grafana, you gain full observability over your web server, enabling you to maintain a more reliable web service.

Conclusion

Web server access logs are one of the most valuable yet underutilized sources of telemetry data. By using NXLog Agent to collect NGINX access logs and transform them into Prometheus metrics, you can gain real-time visibility into your web environment and ensure your web services remain reliable and secure.

At NXLog, we’ve built NXLog Platform to help you get the most out of your telemetry data. If you’re ready to take your telemetry pipeline to the next level, try NXLog Agent to see how it can help you transform logs into actionable observability.

In this post, we’ve only scratched the surface of what you can achieve with an NXLog Platform, Prometheus, and Grafana stack. To learn more or discuss your specific use case, get in touch with us. Our advisors are always happy to help!

Related resources

Watch our video tutorial to explore complementary methods for collecting and forwarding NGINX access and error logs, such as receiving syslog messages over UDP or exporting agent metrics to Prometheus.

NXLog Platform is an on-premises solution for centralized log management with
versatile processing forming the backbone of security monitoring.

With our industry-leading expertise in log collection and agent management, we comprehensively
address your security log-related tasks, including collection, parsing, processing, enrichment, storage, management, and analytics.

Start free Contact us
  • web server logs
  • nginx
  • prometheus
  • grafana
Share

Facebook Twitter LinkedIn Reddit Mail
Related Posts

How to monitor file access in Windows
6 minutes | May 26, 2023
Leveraging Okta logs for improved security monitoring
6 minutes | June 16, 2025
Assertive compliance - using frameworks to extend your coverage
4 minutes | September 30, 2022

Stay connected:

Sign up

Keep up to date with our monthly digest of articles.

By clicking singing up, I agree to the use of my personal data in accordance with NXLog Privacy Policy.

Featured posts

Security dashboards go dark: why visibility isn't optional, even when your defenses keep running
February 26, 2026
Building a practical OpenTelemetry pipeline with NXLog Platform
February 25, 2026
Announcing NXLog Platform 1.11
February 23, 2026
Adopting OpenTelemetry without changing your applications
February 10, 2026
Linux security monitoring with NXLog Platform: Extracting key events for better monitoring
January 9, 2026
2025 and NXLog - a recap
December 18, 2025
Announcing NXLog Platform 1.10
December 11, 2025
Announcing NXLog Platform 1.9
October 22, 2025
Gaining valuable host performance metrics with NXLog Platform
September 30, 2025
Security Event Logs: Importance, best practices, and management
July 22, 2025
Enhancing security with Microsoft's Expanded Cloud Logs
June 10, 2025

Categories

  • ANNOUNCEMENT
  • COMPARISON
  • COMPLIANCE
  • DEPLOYMENT
  • SECURITY
  • SIEM
  • STRATEGY
  • Products
  • NXLog Platform
  • NXLog Community Edition
  • Integration
  • Professional Services
  • Licensing
  • Plans
  • Resources
  • Documentation
  • Blog
  • White Papers
  • Videos
  • Webinars
  • Case Studies
  • Community Program
  • Community Forum
  • Compare NXLog Platform
  • Partners
  • Find a Reseller
  • Partner Program
  • Partner Portal
  • About NXLog
  • Company
  • Careers
  • Support Portals
  • Contact Us

Follow us

LinkedIn Facebook YouTube Reddit
logo

© Copyright NXLog Ltd.

Subscribe to our newsletter

Privacy Policy • General Terms of Business