Skip to content

Latest commit

 

History

History
160 lines (121 loc) · 6.34 KB

MAIN.md

File metadata and controls

160 lines (121 loc) · 6.34 KB

httpd-exporter

Prometheus Metrics exporter for HTTP daemons (Apache, nginx, ...) based on access log file scraping.

Table of Contents

Description

httpd-exporter was written because there were no Prometheus exporters that were able to expose information from arbitrary HTTPD log files and able to handle multiple logfiles within the same instance and able to discover these log files automatically while running.

The emphasis of httpd-exporter is to expose the number of requests that returned with a certain status. Most of current exporters for Apache et al. cannot deliver this kind of metrics.

This is especially required when a Kubernetes cluster or other major Docker installations exist in production. httpd-exporter will provide an insight into the health of single HTTPD instances (aka microservices).

Status

httpd-exporter is in Beta phase. It is running stable in a commercial Kubernetes environment. However, it cannot be regarded as mature because the project was initiated for and tested in that very specific environment only.

Installation

Prerequisites

htppd-exporter is written in Perl. The following prerequisites apply:

Most of these modules shall be already installed with a default Perl installation. Please follow the links above if this is not the case.

Downloading

Install httpd-exporter by cloning the Git repository:

git clone https://github.com/technicalguru/httpd-exporter

Testing

Test your installation by invoking:

<path-to-installation>/exporterd.pl --test

A successful test will produce an output similar to this:

1/12...OK
2/12...OK
3/12...OK
4/12...OK
5/12...OK
6/12...OK
7/12...OK
8/12...OK
9/12...OK
10/12...OK
11/12...OK
12/12...OK
Test Summary: 12 total, 0 failed, 12 passed

Configuration

httpd-exporter requires a configuration file describing the log files to scrape and the metrics to be produced. A default configuration file is part of the installation (exporter.conf) which you should install in directory /etc/httpd-exporter. Edit the file then to reflect your installation.

See the Configuration page for more details.

Running

Invoking the httpd-exporter

The following command invokes the httpd-exporter:

<path-to-installation>/exporterd.pl

The httpd-exporter will try to find your configuration file in the following order:

  1. The path to the file was given as argument to the script (exporterd.pl exporter.conf).
  2. The path to the file is passed by environment variable HTTPD_EXPORTER_CONFIG_FILE.
  3. Default location is assumed: /etc/httpd-exporter/exporter.conf.

httpd-exporter will fail to start when the file was not found or is not readable.

Exposing metrics

Please notice that you will need an additional HTTPD product (Apache, nginx, ...) that needs to serve the metrics file produced by the httpd-exporter at the following URL:

http://<your-host-name>:9386/metrics

Linking Prometheus to metrics

Prometheus requires the following configuration to scrape the metrics:

TBD

Docker image

There is a Docker image available:

https://hub.docker.com/r/technicalguru/httpd-exporter/

The Prometheus Operator YAML for Kubernetes is available here. Install it via:

kubectl apply -f https://github.com/technicalguru/httpd-exporter/master/contrib/kubernetes/exporter.yaml

Metrics Exposed

The httpd-exporter exposes the following metrics:

 # TYPE http_requests_total counter
 # HELP http_requests_total Counts the requests that were logged by HTTP daemon
 http_requests_total{method="GET",status="2xx"} 5432 1512397393000
 http_requests_total{method="GET",status="4xx"} 32 1512397393000
 http_requests_total{method="GET",status="5xx"} 5 1512397393000

 # TYPE http_sent_bytes counter
 # HELP http_sent_bytes Number of bytes transferred as logged by HTTP daemon
 http_sent_bytes{method="GET",status="2xx"} 235432 1512397393000
 http_sent_bytes{method="GET",status="4xx"} 3782 1512397393000
 http_sent_bytes{method="GET",status="5xx"} 4375 1512397393000

Metrics are attributed with appropriate labels as defined by the configuration file. You might require the following Prometheus expressions to query your HTTPD status:

delta(http_requests_total{status!="200"}[5m])  - returns number of requests in the last 5 minutes for each label combination that were not successful
sum(delta(http_requests_total{status!="200"}[5m])) - returns the total count of requests in the last 5 minutes that failed

Contribution

Please contact @technicalguru if you want to contribute. Any improvement is highly welcome.

Further Readings