1
votes

My requirement is to monitor a Linode Virtual machine that contains Apache using Prometheus and Grafana. (PS - Prometheus and Grafana are running in a seperate Linode VM)

I used the following document to install Apache exporter : https://www.techbeginner.in/2021/01/install-and-configure-apache-node.html. The service file is like this :

[Unit]
Description=Prometheus
Documentation=https://github.com/Lusitaniae/apache_exporter
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=prometheus
Group=prometheus
ExecReload=/bin/kill -HUP $MAINPID
ExecStart=/usr/local/bin/apache_exporter \
  --insecure \
  --scrape_uri=http://localhost/server-status/?auto \
  --telemetry.address=0.0.0.0:9117 \
  --telemetry.endpoint=/metrics

SyslogIdentifier=apache_exporter
Restart=always

[Install]
WantedBy=multi-user.target

I've changed the --scrape_uri to http://usr_name:password@localhost/server-status/?auto \ and --telemetry.address to 127.0.0.1:9117 though I'm sure it wouldn't make any difference. Prometheus is able to scrape the data. But when I import a grafana dashboard (ID - 3894) to visualize the data, I don't get any data. Among 7 panels in the entire dashboard (Current total kbytes sent, Current total apache accesses, Apache scoreboard statuses Apache worker statuses, Apache CPU load, Uptime and Apache Up/Down), I can see the grapf for Apache Up/Down. The other 6 say no data available.

This is the prometheus.yml config:

#Apache Servers
  - job_name: apache-web-server
    static_configs:
      - targets: ['x.x.x.x:9117']
        labels:
          alias: server-apache

PS - Both the Linode instances contain Debian GNU/Linux 9.8 (stretch) as their OS.

What am I missing here? How can I get the graphs for the rest of the panels? Any and all help is appreciated. Thanks a lot in advance.

1
My problems with missing data in Grafana were usually one of two types: 1) Missing data because the counter metric has not been generated yet (happens e.g. with low load on the monitored instance; you will not get an error counter because no errors happened yet) 2) Incompatible dashboards (open the panel in the edit mode, see what the source is and if the metric to provide the data is present in the first place). Learning grafana does not take much time and is actually fun. :)Marek Puchalski
@MarekPuchalski The source is Prometheus, as it should be. The metrics which the panels are using are apache_sent_kilobytes_total, apache_accesses_total, apache_scoreboard, apache_workers and apache_cpuload. I can see none of these in my prometheus. So I have incompatible dashboards? What should I do in order to get the data for these metrics? And everything is fun and games until the boss starts to breathe down my neck XDGautam
Which version of Apache are you using?droidbot

1 Answers

0
votes

From what you have mentioned, it looks like you have not set the ExtendedStatus on.

Check it out here: https://httpd.apache.org/docs/2.4/mod/mod_status.html.

The details given are:

The number of workers serving requests
The number of idle workers
The status of each worker, the number of requests that worker has     performed and the total number of bytes served by the worker (*)
A total number of accesses and byte count served (*)
The time the server was started/restarted and the time it has been running for
Averages giving the number of requests per second, the number of bytes served per second and the average number of bytes per request (*)
The current percentage CPU used by each worker and in total by all workers combined (*)
The current hosts and requests being processed (*)

The lines marked "(*)" are only available if ExtendedStatus is On. 

An example configuration that worked for me covering all the metrics:

ExtendedStatus On

<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from localhost
</Location>

That said, ExtendedStatus is On by default from 2.3.6. I guess you are using an Apache version lower than that.


Side note: I've written an article that covers most aspects of monitoring Apache including granular traffic metrics: https://www.giffgaff.io/tech/monitoring-apache-with-prometheus

It also covers the Apache configuration that uses ExtendedStatus.