Since it’s launch in 1995, the Apache HTTP Server has been the stable, reliable workhorse of the Internet.

As a key component of your production infrastructure, Apache needs to be monitored for health and performance. Read on to see how.

Apache Monitoring With OpsDash

Here’s how a default, out-of-the-box Apache dashboard looks:

OpsDash Monitoring an Apache vhost

In OpsDash, you can easily set alerts like “if number of number of 5xx responses per second exceed 100, notify me on Slack” in just a few clicks.

Here is how the Response Codes graphs looks in detail:

The Reponse Codes Graph

All that is needed for this level of monitoring is to have exactly 4 lines in your OpsDash Smart Agent configuration file – like this:

service "apache-main" {
     type = "apache"
     logs = "/var/log/apache2/access.log"
}

service "apache-myvhost" {
     type = "apache"
     logs = "/var/log/apache2/myvhost-access.log"
}

service "apache-all-vhosts" {
     type = "apache"
     logs = "/var/log/apache2/*vhost*-access.log"
}

The configuration has 3 entries (they show up as 3 separate dashboards in the UI), one for the main Apache server, one for a single virtual host, and another for all the virtual hosts combined.

Read on to see how the OpsDash Smart Agent actually monitors your Apache servers.

The Access Log

For maximum portability and flexibility, the OpsDash Smart Agent relies on access logs, rather than the mod_status module of Apache. Practically, parsing the log files are fast, efficient, unintrusive, and yields nearly as much information as other methods.

The OpsDash Smart Agent reads and parses a given set of access log files each minute, and reports the values to the OpsDash servers. It reads in and parses only as much portion of the access log file as is needed to extract the recent most minute’s worth of metrics, so the parsing process is very light on the server’s resources.

Apache log files live under /var/log/httpd or /var/log/apache2, depending upon your Linux distribution and Apache version. By default, there is typically an access log file and an error log file. The access log file is typically of the “combined log format”.

The Combined Log Format

The combined log format is a defacto standard for HTTP access logs, and is used by default by both Apache and Nginx servers. Although Apache and Nginx allows you to customize the format, there is a lot of tooling that work with combined log format logs that it makes sense to leave the default unchanged.

Apache’s directives for manipulating the log formats, and the description of the combined log format can be found here.

Here is how a single entry in this format looks like:

1.1.1.1 - - [02/May/2017:05:34:14 +0000] "GET /blog/disk-monitoring-linux.html HTTP/1.1" 200 5266 "https://www.google.com/" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/58.0.3029.81 Chrome/58.0.3029.81 Safari/537.36"

The fields, in order are:

  1. The IP address of the incoming connection. If there is a proxy or load balancer in front, this field is usually a comma-separated list of IP addresses.
  2. The second field is supposed to be “remote logname”, it is usually always just a “-“.
  3. The username, if HTTP authentication headers were set in the incoming HTTP request. Supplied by the client, so such a user may or may not be valid or authenticated. Value is a “-“ if no username is involved.
  4. The timestamp when the request was received, enclosed in square brackets.
  5. The HTTP request line, enclosed in double quotes. The request line has three parts – the method, the URI and the protocol.
  6. The response code, like 200 or 404.
  7. The number of bytes that were present in the HTTP response body. If no body was sent, the value is “-“.
  8. The value of the Referrer field in the incoming HTTP request.
  9. The value of the User-Agent field in the incoming HTTP request.

The Metrics

From these fields, the OpsDash Smart Agent computes and reports the following metrics:

  • Response Codes - The number of 2xx, 3xx, 4xx and 5xx response codes per second.
  • Requests Per Second - The number of overall HTTP requests per second.
  • Unique IPs Per Second - The number of unique IP addresses that hit the server each second.
  • Unique User Agents Per Second - The number of unique user agent strings per second.
  • Data Sent Per Second - The size of the HTTP response body data sent each second, in bytes.

With OpsDash, monitoring Apache is fast and easy. You can be up and running in just a few minutes. No need to waste time getting set up, but don’t neglect monitoring this key component of your production infrastructure either. Get started today!

New Here?

OpsDash is a server monitoring, service monitoring, and database monitoring solution for monitoring MySQL, PostgreSQL, MongoDB, memcache, Redis, Apache, Nginx, Elasticsearch and more. It provides intelligent, customizable dashboards and spam-free alerting via email, HipChat, Slack, PagerDuty and Webhooks. Send in your custom metrics with StatsD and Graphite interfaces built into each agent.