Guides - Capture Apache Metrics with Longview
View real-time system metrics and resource utilization to gain insight into your Linux-based cloud workloads.
In addition to capturing general system metrics, Longview can also be used to capture metrics for Apache. The Apache tab appears in the Cloud Manager when Longview detects that you have Apache installed on your system. It can help you keep track of Apache’s settings, workers and requests, system resource consumption, and other information.
In this Guide:
This guide covers using Longview with Apache and includes the following topics:
- Configuring Longview for Apache.
- Interacting with the Apache data provided by Longview in the Cloud Manager.
- Troubleshooting Longview for Apache.
Configure Longview for Apache
Automatic Configuration
These instructions are compatible only with Debian and Ubuntu and do not work on CentOS.
If Apache is installed and running when you install the Longview agent, Longview should automatically configure itself for Apache. If you install Apache after setting up the Longview agent, you can perform the steps below to configure Longview with any available software integrations (Apache, NGINX, and MySQL). Any existing Longview data is not affected and will remain accessible.
SSH into the Compute Instance you are monitoring with Longview.
Ensure that Apache is running.
sudo systemctl status apache2
Run the automatic Longview configuration command.
dpkg-reconfigure -phigh linode-longview
For most systems, Longview should be able to configure itself automatically. If this is the case, your output should be similar to the following:
Checking Apache configuration... Found Apache status page at http://127.0.0.1/server-status?auto specified in /etc/linode/longview.d/Apache.conf
Once you see this successful message, the Longview should automatically start collecting Apache data. Refresh Longview in the Cloud Manager to start viewing your Apache stats for your Longview Client instance.
If you receive a failure message or the popup shown below, you should visit the Troubleshooting section at the end of this article.
Manual Configuration
These instructions work for all supported distributions, including Debian, Ubuntu, and CentOS.
To enable the Apache Longview integration manually, follow these steps on your system via SSH:
SSH into the Compute Instance you are monitoring with Longview.
Verify that mod_status is enabled for Apache (it should be by default). For more information, see the Apache Module mod_status documentation.
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo a2enmod status</span></span></code></pre></div></div>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo yum install links
httpd -M | grep status
The output should be similar to:
status_module (shared)
Update your Apache configuration file to include the block in the example file below. Depending on your Linux distribution and version, your Apache configuration file may be stored in one of the following locations:
/etc/apache2/httpd.conf
/etc/apache2/apache2.conf
/etc/httpd/httpd.conf
/etc/httpd/conf/httpd.conf
- File: httpd.conf or apache2.conf
1 2 3 4 5 6 7
<IfModule mod_status.c> ExtendedStatus On <Location /server-status> SetHandler server-status Require local </Location> </IfModule>
Edit the Longview configuration file for Apache (
/etc/linode/longview.d/Apache.conf
) so that it includes the following line. If this line is commented out, you can uncomment it.- File: /etc/linode/longview.d/Apache.conf
1
location http://127.0.0.1/server-status?auto
Restart Apache:
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo systemctl restart apache2</span></span></code></pre></div></div>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo systemctl restart httpd</span></span></code></pre></div></div>
Restart Longview:
sudo systemctl restart longview
Refresh the Longview in your Cloud Manager.
You should now be able to see Longview data for Apache. If that’s not the case, proceed to the Troubleshooting section at the end of this article.
View Apache Metrics
Log in to the Cloud Manager and select the Longview link in the sidebar.
Locate the Longview Client you have configured for Apache and click the corresponding View details link.
Select the Apache tab.
You’ll see the current version of Apache listed on the upper left hand side of the page.
Hover over a data point to see the exact numbers for that time. With Longview Pro, you can view older time periods for your data. The next sections cover the Longview Apache App in detail.
Requests
The Requests graph shows the total number of requests Apache handled at the selected time. This is every HTTP and HTTPS request to your system.
Throughput
The Throughput graph shows the amount of data that Apache sent and received via web requests at the time selected.
Workers
The Workers graph shows all of the Apache workers at the selected time. The workers are broken down by state:
- Waiting
- Starting
- Reading
- Sending
- Keepalive
- DNS Lookup
- Closing
- Logging
- Finishing
- Cleanup
CPU
The CPU graph shows the percentage of your system’s CPU being used by Apache at the selected time. If you want to see the total CPU used instead, check the Overview tab.
Memory
The Memory graph shows the amount of RAM being used by Apache at the selected time. If you want to see your system’s total memory use instead, check the Overview tab.
Disk IO
The Disk IO graph shows the amount of input to and output from the disk caused by Apache at the selected time. To see the total IO instead, visit the Disks tab.
Process Count
The Process Count graph shows the total number of processes on your system spawned by Apache at the selected time. If you want to see more details, and how this stacks up against the total number of processes on your system, see the Processes tab.
Troubleshooting
If you don’t see Longview data for Apache, you’ll instead get an error on the page and instructions on how to fix it. As a general tip, you can check the
/var/log/linode/longview.log
file for errors as well. You should also compare your mod_status configuration file to the example shown in Step 2 of the Manual Configuration (All Distributions) section of this article.By default Longview uses port 80 for its automatic configuration. In the event you are experiencing problems you may need to edit the
/etc/apache2/ports.conf
file to use port 8080 or another non-standard port.Autoconfigure mod_status Popup
If you run the automatic Longview configuration tool, and get the popup message shown below:
This indicates that Longview can’t locate the Apache status page. In turn, this could indicate that either:
- The status page is in an unusual and unspecified location.
- mod_status isn’t enabled.
- An Apache virtual host setting is interfering with requests to the status page.
- Apache itself is misconfigured.
If you choose:
<No>: the Longview tool will quit, and you can do a manual configuration. This is the safer option.
<Yes>: the Longview tool will attempt to enable mod_status, set the status page location, and restart Apache. This option is easier, but has the potential to disrupt your current Apache configuration. If you choose yes, and the configuration is successful, you should see output like the following:
[ ok ] Stopping Longview Agent: longview. Checking Apache configuration... Enabling module status. To activate the new configuration, you need to run: service apache2 restart [....] Reloading web server config: . ok Apache mod_status enabled [ ok ] Starting Longview Agent: longview. update-rc.d: using dependency based boot sequencing
Refresh the Longview Apache tab in the Cloud Manager to verify that it’s working now.
If instead you receive a failure message, such as:
[FAIL] Reloading web server config: apache2 failed!
You will need to double-check your Apache installation, and then do a manual configuration.
Unable to Access Local Server Status for Apache
This error will state
Unable to access local server status for Apache at <http://example.com/example?auto>: <error>:
. This error occurs when either:Apache’s mod_status setting is disabled or has been changed from the default location.
An Apache virtual host configuration is interfering with web requests to the mod_status location.
Note This error occurs when Longview attempts to check the status pagelocation
listed in/etc/linode/longview.d/Apache.conf
, or the default page at127.0.0.1/server-status?auto
, but receives a non-200 HTTP response code. Basically, it means that the status page Longview is expecting is not being returned by the server.
To fix this, follow these steps:
Make sure Apache is running:
sudo systemctl restart apache2
Make sure mod_status is enabled. See the Apache website for details. You can also check the output of the following command:
apachectl -M
Check the location for mod_status. The default location on Debian and Ubuntu systems is
http://127.0.0.1/server-status?auto
on localhost. In the Apache configuration file, this is designated with the lines:- File: httpd.conf or apache2.conf
1 2
<Location /server-status> SetHandler server-status
The
SetHandler server-status
line indicates that this is the location block for mod_status. The location line itself sets the location.On cPanel/WHM:
To direct Longview to the cPanel customized status page, edit the
location
line in/etc/linode/longview.d/Apache.conf
to match the following:- File: /etc/linode/longview.d/Apache.conf
1
location http://localhost/whm-server-status?auto
Longview is designed to check the default location automatically. If you use the default location shown above, you should be done. Refresh the Longview in the Cloud Manager to verify that it’s working now.
If you’re not using the default location, you need to create a new file,
/etc/linode/longview.d/Apache.conf
, and set thelocation
variable to match what you set in the Apache configuration file:- File: /etc/linode/longview.d/Apache.conf
1 2
location http://127.0.0.1/custom/location/path ``
Determine if an Apache virtual host configuration is interfering with requests to the mod_status location. Use a tool like
curl
orwget
to request the server status location:curl http://127.0.0.1/server-status?auto
Observe the output. If the output looks like something other than a simple status page, then you’ll have to fix your Apache virtual host configuration.
Restart Longview:
sudo service longview restart
Refresh the Longview in the Cloud Manager to verify that it’s working now.
The Apache Status Page Doesn’t Look Right
This error states
The Apache status page doesn't look right. Check <http://example.com/example?auto> and investigate any redirects for misconfiguration.
This error occurs when Longview is able to reach the mod_status page, but doesn’t receive the expected content.Note This error occurs when Longview attempts to check the status page, and receives a 200 HTTP response code, but can’t scrape the expected status content from the page. That is, the page exists on your system, but it doesn’t have the right content. If, for example, Longview was to check your website’s home page, you would get this error.To resolve this issue, follow these steps:
Visit the URL shown in the error. See if it directs or redirects you to a page that isn’t the Apache status page.
Update your Apache and Longview settings so that they specify the same location:
- The <Location > line in your Apache configuration file
- The location line in
/etc/linode/longview.d/Apache.conf
If neither of these is set, the default location of
http://127.0.0.1/server-status?auto
on localhost will be used.Make sure there aren’t any Apache redirects or other settings that are affecting this page.
Restart Longview:
sudo systemctl restart longview
Refresh the Longview in the Cloud Manager to verify that it’s working now.
Missing Graphs: Enable ExtendedStatus
If some of your Apache graphs are missing, you may see the error
Enable ExtendedStatus in your Apache configuration for throughput and request graphs.
This indicates that you need to add the following line to your Apache configuration file in the
<IfModule mod_status.c>
section:- File: httpd.conf
1
ExtendedStatus On
When you’ve finished modifying the configuration file, restart Apache:
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo systemctl restart apache2</span></span></code></pre></div></div> <div class="absolute right-0 top-0 overflow-x-none mt-4 sm:mt-5 pl-3" style="background-color: inherit;" @click="$copy($refs.code)"> <button type="button" aria-label="copy" class="btn-icon copy-button"><svg class="fill-current mr-4" style="width: 0.875rem; height: 1rem;"><use href="#icon--copy"></use></svg></button> </div> </div>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo systemctl restart httpd</span></span></code></pre></div></div> <div class="absolute right-0 top-0 overflow-x-none mt-4 sm:mt-5 pl-3" style="background-color: inherit;" @click="$copy($refs.code)"> <button type="button" aria-label="copy" class="btn-icon copy-button"><svg class="fill-current mr-4" style="width: 0.875rem; height: 1rem;"><use href="#icon--copy"></use></svg></button> </div> </div>
Apache Tab is Missing
If the Longview Apache tab is missing entirely, this indicates that Apache is either not installed, or has stopped. If you restart Apache, you will be able to see the tab again and view all of your old data.
This page was originally published on