exporter

package module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 18, 2018 License: MIT Imports: 17 Imported by: 0

README

php-fpm-exporter

Export php-fpm metrics in Prometheus format.

See Releases for pre-built binaries.

Also availible on Docker Hub bakins/php-fpm-exporter

Build

Requires Go. Tested with Go 1.8+.

Clone this repo into your GOPATH ($HOME/go by default) and run build:

mkdir -p $HOME/go/src/github.com/bakins
cd $HOME/go/src/github.com/bakins
git clone https://github.com/bakins/php-fpm-exporter
cd php-fpm-exporter
./script/build

You should then have two executables: php-fpm-exporter.linux.amd64 and php-fpm-exporter.darwin.amd64

You may want to rename for your local OS, ie mv php-fpm-exporter.darwin.amd64 php-fpm-exporter

Running

./php-fpm-exporter --help
php-fpm metrics exporter

Usage:
  php-fpm-exporter [flags]

Flags:
      --addr string       listen address for metrics handler (default "127.0.0.1:8080")
      --endpoint string   url for php-fpm status (default "http://127.0.0.1:9000/status")
      --fastcgi string    fastcgi url. If this is set, fastcgi will be used instead of HTTP

When running, a simple healthcheck is available on /healthz

To use the HTTP endpoint you must pass through /status in your webserver and configure php-fpm to handle status requests. Example for nginx: https://easyengine.io/tutorials/php/fpm-status-page/

To use Fastcgi, set --fastcgi to a url such as tcp://127.0.0.1:9090/status if php-fpm is listening on a tcp socket or unix:///path/to/php.sock for a unix socket. Note: php-fpm must be configured to use /status if using a unix socket, php-fpm-exporter does not currently support changing this.

Metrics

Metrics will be exposes on /metrics

LICENSE

See LICENSE

loosely based on https://github.com/peakgames/php-fpm-prometheus/ which is MIT.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger() (*zap.Logger, error)

NewLogger creates a new logger with our prefered options

func SetAddress

func SetAddress(addr string) func(*Exporter) error

SetAddress creates a function that will set the listening address. Generally only used when create a new Exporter.

func SetEndpoint

func SetEndpoint(rawurl string) func(*Exporter) error

SetEndpoint creates a function that will set the URL endpoint to contact php-fpm. Generally only used when create a new Exporter.

func SetFastcgi added in v0.4.0

func SetFastcgi(rawurl string) func(*Exporter) error

SetFastcgi creates a function that will set the fastcgi URL endpoint to contact php-fpm. If this is set, then fastcgi is used rather than HTTP. Generally only used when create a new Exporter.

func SetLogger

func SetLogger(l *zap.Logger) func(*Exporter) error

SetLogger creates a function that will set the logger. Generally only used when create a new Exporter.

Types

type Exporter

type Exporter struct {
	// contains filtered or unexported fields
}

Exporter handles serving the metrics

func New

func New(options ...OptionsFunc) (*Exporter, error)

New creates an exporter.

func (*Exporter) Run

func (e *Exporter) Run() error

Run starts the http server and collecting metrics. It generally does not return.

type OptionsFunc

type OptionsFunc func(*Exporter) error

OptionsFunc is a function passed to new for setting options on a new Exporter.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL