2017 © Pedro Peláez
 

library apache-exporter

A library for exporting Apache status for Prometheus

image

building5/apache-exporter

A library for exporting Apache status for Prometheus

  • Friday, March 2, 2018
  • by leedm777
  • Repository
  • 1 Watchers
  • 0 Stars
  • 201 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 15 % Grown

The README.md

apache-exporter-php

PHP port of apache_exporter. Slightly more convenient for PHP apps, since it does not require running the additional exporter process., (*1)

Installation

$ composer require building5/apache-exporter

Usage

Be sure to have the Apache server-status page enabled and configured., (*2)

Enable the status module using a2enmod status. It probably already has a status.conf configured in /etc/apache2/mods-enabled, but if not, you'll need that, too, (*3)

<IfModule mod_status.c>
    <Location /server-status>
        SetHandler server-status
        Require local
    </Location>
    ExtendedStatus On

    <IfModule mod_proxy.c>
        # Show Proxy LoadBalancer status in mod_status
        ProxyStatus On
    </IfModule>
</IfModule>

You can test the status page by running curl http://localhost/server-status?auto on the web server to see if it's service the status page., (*4)

Simple usage

In your PHP application, or in whatever webroot you choose, create a metrics.php script that calls ApacheExporter\Exporter::simple(). The use of .htaccess to restrict access, add passwords, etc. is left as an exercise., (*5)

<?php
ApacheExporter\Exporter::simple();

Non-simple usage

If you have other stats you'd like to report, you can use the ApacheExporter\Exporter::export() method to export stats to the registry of your own choosing., (*6)

The use of APC or Redis storage is not recommended. The counter fields like accesses, kilobytes and uptime will accumulate wildly if you do., (*7)

See prometheus_client_php#68., (*8)

<?php
use ApacheExporter\Exporter;
use Prometheus\CollectorRegistry;
use Prometheus\RenderTextFormat;
use Prometheus\Storage\InMemory;

$registry = new CollectorRegistry(new InMemory());
$renderer = new RenderTextFormat();

Exporter::export($registry);

// register other stats you want here

header('Content-type: ' . RenderTextFormat::MIME_TYPE);
echo $renderer->render($registry->getMetricFamilySamples());

License

apache-exporter-php is licensed under the MIT license., (*9)

The Versions

02/03 2018

dev-master

9999999-dev https://github.com/building5/apache-exporter-php

A library for exporting Apache status for Prometheus

  Sources   Download

MIT

The Requires

 

The Development Requires

by David M. Lee, II

apache prometheus

02/03 2018

v1.0.0

1.0.0.0 https://github.com/building5/apache-exporter-php

A library for exporting Apache status for Prometheus

  Sources   Download

MIT

The Requires

 

The Development Requires

by David M. Lee, II

apache prometheus