exporter

package module
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: MIT Imports: 15 Imported by: 0

README

gearman-exporter

Export gearman metrics in Prometheus format.

Build Status Docker Image

Usage

See Releases for pre-built binaries.

Running

./gearman-exporter --help
Gearman metrics exporter

Usage:
  gearman-exporter [flags]

Flags:
      --addr string       listen address for metrics handler (default "127.0.0.1:9418")
      --gearmand string   address of gearmand (default "127.0.0.1:4730")

When running, a simple healthcheck is availible on /healthz

Docker

A docker image is published from the Travis build to Docker Hub.

docker run -p9418:9418 gearmanexporter/gearman-exporter --addr 0.0.0.0:9418

Metrics

Metrics will be exposed on /metrics

curl http://localhost:9418/metrics

# HELP gearman_jobs number of jobs queued or running
# TYPE gearman_jobs gauge
gearman_jobs{function="bar"} 0
gearman_jobs{function="foo"} 0

# HELP gearman_jobs_running number of running jobs
# TYPE gearman_jobs_running gauge
gearman_jobs_running{function="bar"} 0
gearman_jobs_running{function="foo"} 0

# HELP gearman_jobs_waiting number of jobs waiting for an available worker
# TYPE gearman_jobs_waiting gauge
gearman_jobs_waiting{function="bar"} 0
gearman_jobs_waiting{function="foo"} 0

# HELP gearman_workers number of capable workers
# TYPE gearman_workers gauge
gearman_workers{function="bar"} 1
gearman_workers{function="foo"} 1

# HELP gearman_up is gearman up
# TYPE gearman_up gauge
gearman_up 1

# HELP gearman_version_info gearman version
# TYPE gearman_version_info gauge
gearman_version_info{version="1.1.18"} 1

Grafana

https://grafana.com/grafana/dashboards/11423

Development

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/gearman-exporter
cd gearman-exporter
make build

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

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

Run Gearman server for testing

For testing you might want to run a gearman server with Docker:

docker run -p 4730:4730 cargomedia/gearman

While the server is running you could attach a worker function "foo" like this:

docker exec $(docker ps -qf ancestor=cargomedia/gearman) gearman -t9999 -wnf foo

Release new version

  1. Push a tag vX.Y.Z to Github
  2. Travis will build the program and create a Github release

LICENSE

See LICENSE

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 SetGearmanAddress

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

SetGearmanAddress creates a function that will set the address to contact gearman. 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