exporter

package module
v0.0.0-...-88d05c0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 18 Imported by: 0

README

php-fpm-exporter

增加了application参数

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.12.

Clone this repo locally and run build:

mkdir -p $HOME/src
cd $HOME/src
git clone https://github.com/beckbikang/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

./main
usage: main [<flags>]

Flags:
  -h, --help                   Show context-sensitive help (also try --help-long and --help-man).
      --addr="127.0.0.1:8080"  listen address for metrics handler
      --application="default"  application name
      --endpoint="http://127.0.0.1:9000/status"  
                               url for php-fpm status
      --fastcgi=FASTCGI        fastcgi url. If this is set, fastcgi will be used instead of HTTP
      --web.telemetry-path="/metrics"  
                               Path under which to expose metrics. Cannot be 

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 SetApplication

func SetApplication(application 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

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.

func SetMetricsEndpoint

func SetMetricsEndpoint(path string) func(*Exporter) error

SetMetricsEndpoint sets the path under which to expose metrics. 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.

Jump to

Keyboard shortcuts

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