pax_global_header 0000666 0000000 0000000 00000000064 13557577635 0014541 g ustar 00root root 0000000 0000000 52 comment=ca2bb38d121dbff38f62f10f3470b2bb260d2a78
prometheus-apache-exporter-0.7.0+ds/ 0000775 0000000 0000000 00000000000 13557577635 0017427 5 ustar 00root root 0000000 0000000 prometheus-apache-exporter-0.7.0+ds/.circleci/ 0000775 0000000 0000000 00000000000 13557577635 0021262 5 ustar 00root root 0000000 0000000 prometheus-apache-exporter-0.7.0+ds/.circleci/config.yml 0000664 0000000 0000000 00000006512 13557577635 0023256 0 ustar 00root root 0000000 0000000 ---
version: 2.1
jobs:
test:
docker:
- image: circleci/golang:1.10
working_directory: /go/src/github.com/Lusitaniae/apache_exporter
steps:
- checkout
- setup_remote_docker
- run: make promu
- run: make
- run: rm -f apache_exporter
build:
machine: true
working_directory: /home/circleci/.go_workspace/src/github.com/Lusitaniae/apache_exporter
steps:
- checkout
- run: make promu
- run: promu crossbuild -v
- persist_to_workspace:
root: .
paths:
- .build
docker_hub_master:
docker:
- image: circleci/golang:1.10
working_directory: /go/src/github.com/Lusitaniae/apache_exporter
environment:
DOCKER_IMAGE_NAME: lusotycoon/apache-exporter
QUAY_IMAGE_NAME: quay.io/lusitaniae/apache-exporter
steps:
- checkout
- setup_remote_docker
- attach_workspace:
at: .
- run: ln -s .build/linux-amd64/apache_exporter apache_exporter
- run: make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME
- run: make docker DOCKER_IMAGE_NAME=$QUAY_IMAGE_NAME
- run: docker images
- run: docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
- run: docker login -u $QUAY_LOGIN -p $QUAY_PASSWORD quay.io
- run: docker push $DOCKER_IMAGE_NAME
- run: docker push $QUAY_IMAGE_NAME
docker_hub_release_tags:
docker:
- image: circleci/golang:1.10
working_directory: /go/src/github.com/Lusitaniae/apache_exporter
environment:
DOCKER_IMAGE_NAME: lusotycoon/apache-exporter
QUAY_IMAGE_NAME: quay.io/lusitaniae/apache-exporter
steps:
- checkout
- setup_remote_docker
- run: mkdir -v -p ${HOME}/bin
- run: curl -L 'https://github.com/aktau/github-release/releases/download/v0.7.2/linux-amd64-github-release.tar.bz2' | tar xvjf - --strip-components 3 -C ${HOME}/bin
- run: echo 'export PATH=${HOME}/bin:${PATH}' >> ${BASH_ENV}
- attach_workspace:
at: .
- run: make promu
- run: promu crossbuild tarballs
- run: promu checksum .tarballs
- run: promu release .tarballs
- store_artifacts:
path: .tarballs
destination: releases
- run: ln -s .build/linux-amd64/apache_exporter apache_exporter
- run: make docker DOCKER_IMAGE_NAME=$DOCKER_IMAGE_NAME DOCKER_IMAGE_TAG=$CIRCLE_TAG
- run: make docker DOCKER_IMAGE_NAME=$QUAY_IMAGE_NAME DOCKER_IMAGE_TAG=$CIRCLE_TAG
- run: docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
- run: docker login -u $QUAY_LOGIN -p $QUAY_PASSWORD quay.io
- run: |
if [[ "$CIRCLE_TAG" =~ ^v[0-9]+(\.[0-9]+){2}$ ]]; then
docker tag "$DOCKER_IMAGE_NAME:$CIRCLE_TAG" "$DOCKER_IMAGE_NAME:latest"
docker tag "$QUAY_IMAGE_NAME:$CIRCLE_TAG" "$QUAY_IMAGE_NAME:latest"
fi
- run: docker push $DOCKER_IMAGE_NAME
- run: docker push $QUAY_IMAGE_NAME
workflows:
version: 2
apache_exporter:
jobs:
- test:
filters:
tags:
only: /.*/
- build:
filters:
tags:
only: /.*/
- docker_hub_master:
requires:
- test
- build
filters:
branches:
only: master
- docker_hub_release_tags:
requires:
- test
- build
filters:
tags:
only: /^v[0-9]+(\.[0-9]+){2}(-.+|[^-.]*)$/
branches:
ignore: /.*/
prometheus-apache-exporter-0.7.0+ds/.promu.yml 0000664 0000000 0000000 00000001150 13557577635 0021367 0 ustar 00root root 0000000 0000000 repository:
path: github.com/Lusitaniae/apache_exporter
build:
flags: -a -tags netgo
ldflags: |
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Version={{.Version}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Revision={{.Revision}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.Branch={{.Branch}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildUser={{user}}@{{host}}
-X {{repoPath}}/vendor/github.com/prometheus/common/version.BuildDate={{date "20060102-15:04:05"}}
tarball:
files:
- LICENSE
prometheus-apache-exporter-0.7.0+ds/Dockerfile 0000664 0000000 0000000 00000000207 13557577635 0021420 0 ustar 00root root 0000000 0000000 FROM quay.io/prometheus/busybox:latest
COPY apache_exporter /bin/apache_exporter
ENTRYPOINT ["/bin/apache_exporter"]
EXPOSE 9117
prometheus-apache-exporter-0.7.0+ds/LICENSE 0000664 0000000 0000000 00000002063 13557577635 0020435 0 ustar 00root root 0000000 0000000 The MIT License (MIT)
Copyright (c) 2015 neezgee
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
prometheus-apache-exporter-0.7.0+ds/Makefile 0000664 0000000 0000000 00000003307 13557577635 0021072 0 ustar 00root root 0000000 0000000 # Copyright 2015 The Prometheus Authors
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
GO := GO15VENDOREXPERIMENT=1 go
PROMU := $(GOPATH)/bin/promu
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
PREFIX ?= $(shell pwd)
BIN_DIR ?= $(shell pwd)
DOCKER_IMAGE_NAME ?= apache-exporter
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
all: format build test
test:
@echo ">> running tests"
@$(GO) test -short $(pkgs)
style:
@echo ">> checking code style"
@! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
format:
@echo ">> formatting code"
@$(GO) fmt $(pkgs)
vet:
@echo ">> vetting code"
@$(GO) vet $(pkgs)
build: promu
@echo ">> building binaries"
@$(PROMU) build --prefix $(PREFIX)
tarball: promu
@echo ">> building release tarball"
@$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR)
docker:
@echo ">> building docker image"
@docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .
promu:
@GOOS=$(shell uname -s | tr A-Z a-z) \
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \
$(GO) get -u github.com/prometheus/promu
.PHONY: all style format build test vet tarball docker promu
prometheus-apache-exporter-0.7.0+ds/README.md 0000664 0000000 0000000 00000014020 13557577635 0020703 0 ustar 00root root 0000000 0000000
# Apache Exporter for Prometheus [![Build Status][buildstatus]][circleci]
[][release]

[][quay]
[][hub]
Exports apache mod_status statistics via HTTP for Prometheus consumption.
With working golang environment it can be built with `go get`. There is a [good article](https://machineperson.github.io/monitoring/2016/01/04/exporting-apache-metrics-to-prometheus.html) with build HOWTO and usage example.
Help on flags:
```
-insecure
Ignore server certificate if using https. (default false)
-scrape_uri string
URI to apache stub status page. (default "http://localhost/server-status/?auto")
-telemetry.address string
Address on which to expose metrics. (default ":9117")
-telemetry.endpoint string
Path under which to expose metrics. (default "/metrics")
-version
Version of the Apache exporter.
```
Tested on Apache 2.2 and Apache 2.4.
If your server-status page is secured by http auth, add the credentials to the scrape URL following this example:
```
http://user:password@localhost/server-status?auto
```
Override host name by runnning
```
./apache_exporter -host_override=example.com
```
# Using Docker
## Build the compatible binary
To make sure that exporter binary created by build job is suitable to run on busybox environment, generate the binary using Makefile definition. Inside project directory run:
```
make
```
*Please be aware that binary generated using `go get` or `go build` with defaults may not work in busybox/alpine base images.*
## Build image
Run the following commands from the project root directory.
```
docker build -t apache_exporter .
```
## Run
```
docker run -d -p 9117:9117 apache_exporter \
-scrape_uri "https://your.server.com/server-status/?auto"
```
## Collectors
Apache metrics:
```
# HELP apache_accesses_total Current total apache accesses (*)
# TYPE apache_accesses_total counter
# HELP apache_scoreboard Apache scoreboard statuses
# TYPE apache_scoreboard gauge
# HELP apache_sent_kilobytes_total Current total kbytes sent (*)
# TYPE apache_sent_kilobytes_total counter
# HELP apache_cpu_load CPU Load (*)
# TYPE apache_cpu_load gauge
# HELP apache_up Could the apache server be reached
# TYPE apache_up gauge
# HELP apache_uptime_seconds_total Current uptime in seconds (*)
# TYPE apache_uptime_seconds_total counter
# HELP apache_workers Apache worker statuses
# TYPE apache_workers gauge
```
Exporter process metrics:
```
# HELP http_request_duration_microseconds The HTTP request latencies in microseconds.
# TYPE http_request_duration_microseconds summary
# HELP http_request_size_bytes The HTTP request sizes in bytes.
# TYPE http_request_size_bytes summary
# HELP http_response_size_bytes The HTTP response sizes in bytes.
# TYPE http_response_size_bytes summary
# HELP process_cpu_seconds_total Total user and system CPU time spent in seconds.
# TYPE process_cpu_seconds_total counter
# HELP process_max_fds Maximum number of open file descriptors.
# TYPE process_max_fds gauge
# HELP process_open_fds Number of open file descriptors.
# TYPE process_open_fds gauge
# HELP process_resident_memory_bytes Resident memory size in bytes.
# TYPE process_resident_memory_bytes gauge
# HELP process_start_time_seconds Start time of the process since unix epoch in seconds.
# TYPE process_start_time_seconds gauge
# HELP process_virtual_memory_bytes Virtual memory size in bytes.
# TYPE process_virtual_memory_bytes gauge
```
Metrics marked '(*)' are only available if ExtendedStatus is On in apache webserver configuration. In version 2.3.6, loading mod_status will toggle ExtendedStatus On by default.
## FAQ
Q. Is there a Grafana dashboard for this exporter?
A. There's a 3rd party dashboard [here](https://grafana.com/dashboards/3894) which seems to work.
Q. Can you add additional metrics such as reqpersec, bytespersec and bytesperreq?
A. In line with the [best practices](https://prometheus.io/docs/instrumenting/writing_exporters/#drop-less-useful-statistics), the exporter only provides the totals and you should derive rates using [PromQL](https://prometheus.io/docs/prometheus/latest/querying/basics/).
> Like that:
> - `ReqPerSec` : `rate(apache_accesses_total[5m])`
> - `BytesPerSec`: `rate(apache_sent_kilobytes_total[5m])`
> - `BytesPerReq`: BytesPerSec / ReqPerSec
Q. Can I monitor multiple Apache instances?
A. In line with the [best practices](https://prometheus.io/docs/instrumenting/writing_exporters/#deployment), the answer is no. *Each process being monitored should be accompanied by **one** exporter*.
We suggest automating configuration and deployment using your favorite tools, e.g. Ansible/Chef/Kubernetes.
Q. Its not working! Apache_up shows as 0
A. When apache_up reports 0 it means the exporter is running however it is not able to connect to Apache.
Do you have this (or similar) configuration uncommented in your Apache instance?
```