rabbitmq_exporter

package module
v0.0.0-...-5f8513c Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MIT Imports: 25 Imported by: 0

README ¶

📣 EOL Announcement

IMPORTANT: This exporter only works with RabbitMQ 3. Please use the official exporter for RabbitMQ 4 or newer. See https://github.com/kbudde/rabbitmq_exporter/issues/383 for details.

RabbitMQ Exporter Build Status Coverage Status

Prometheus exporter for RabbitMQ metrics. Data is scraped by prometheus.

Please note this an unofficial plugin. There is also an official plugin from RabbitMQ.com. See comparison to official exporter

Installation

Binary release

You can download the latest release on the release page. Docker images are push to docker hub

docker: rabbitmq container with network sharing

The rabbitmq_exporter is sharing the network interface with the rabbitmq container -> it is possible to use localhost and default user/password (guest).

  1. Start rabbitMQ

     docker run -d -e RABBITMQ_NODENAME=my-rabbit --name my-rabbit -p 9419:9419 rabbitmq:3-management
    
  2. Start rabbitmq_exporter in container.

     docker run -d --net=container:my-rabbit kbudde/rabbitmq-exporter
    

Now your metrics are exposed through http://host:9419/metrics. The management plugin does not need to be exposed.

Configuration

Rabbitmq_exporter can be configured using json config file or environment variables for configuration.

Config file

Rabbitmq_exporter expects config file in "conf/rabbitmq.conf". If you are running the exporter in a container (docker/kubernetes) the config must be in "/conf/rabbitmq.conf" The name of the file can be overriden with flag:

./rabbitmq_exporter -config-file config.example.json

You can find an example here. Note: If you are using a config file, you must provide all values as there is no default value.

Settings
Environment variable default description
RABBIT_URL http://127.0.0.1:15672 url to rabbitMQ management plugin (must start with http(s)://)
RABBIT_USER guest username for rabbitMQ management plugin. User needs monitoring tag!
RABBIT_PASSWORD guest password for rabbitMQ management plugin
RABBIT_CONNECTION direct direct or loadbalancer, strips the self label when loadbalancer
RABBIT_USER_FILE location of file with username (useful for docker secrets)
RABBIT_PASSWORD_FILE location of file with password (useful for docker secrets)
PUBLISH_PORT 9419 Listening port for the exporter
PUBLISH_ADDR "" Listening host/IP for the exporter
OUTPUT_FORMAT TTY Log ouput format. TTY and JSON are suported
LOG_LEVEL info log level. possible values: "debug", "info", "warning", "error", "fatal", or "panic"
CAFILE ca.pem path to root certificate for access management plugin. Just needed if self signed certificate is used. Will be ignored if the file does not exist
CERTFILE client-cert.pem path to client certificate used to verify the exporter's authenticity. Will be ignored if the file does not exist
KEYFILE client-key.pem path to private key used with certificate to verify the exporter's authenticity. Will be ignored if the file does not exist
SKIPVERIFY false true/0 will ignore certificate errors of the management plugin
SKIP_VHOST ^$ regex, matching vhost names are not exported. First performs INCLUDE_VHOST, then SKIP_VHOST. Applies to queues and exchanges
INCLUDE_VHOST .* regex vhost filter. Only matching vhosts are exported. Applies to queues and exchanges
INCLUDE_QUEUES .* regex queue filter. Just matching names are exported
SKIP_QUEUES ^$ regex, matching queue names are not exported (useful for short-lived rpc queues). First performed INCLUDE, after SKIP
INCLUDE_EXCHANGES .* regex exchange filter. (Only exchanges in matching vhosts are exported)
SKIP_EXCHANGES ^$ regex, matching exchanges names are not exported. First performed INCLUDE, after SKIP
RABBIT_CAPABILITIES bert,no_sort comma-separated list of extended scraping capabilities supported by the target RabbitMQ server
RABBIT_EXPORTERS exchange,node,queue List of enabled modules. Possible modules: connections,shovel,federation,exchange,node,queue,memory
RABBIT_TIMEOUT 30 timeout in seconds for retrieving data from management plugin.
MAX_QUEUES 0 max number of queues before we drop metrics (disabled if set to 0)
EXCLUDE_METRICS Metric names to exclude from export. comma-seperated. e.g. "recv_oct, recv_cnt". See exporter_*.go for names

Example and recommended settings:

SKIP_QUEUES="RPC_.*" MAX_QUEUES=5000 ./rabbitmq_exporter
Extended RabbitMQ capabilities

Newer version of RabbitMQ can provide some features that reduce overhead imposed by scraping the data needed by this exporter. The following capabilities are currently supported in RABBIT_CAPABILITIES env var:

  • no_sort: By default RabbitMQ management plugin sorts results using the default sort order of vhost/name. This sorting overhead can be avoided by passing empty sort argument (?sort=) to RabbitMQ starting from version 3.6.8. This option can be safely enabled on earlier 3.6.X versions, but it'll not give any performance improvements. And it's incompatible with 3.4.X and 3.5.X.
  • bert: Since 3.6.9 (see https://github.com/rabbitmq/rabbitmq-management/pull/367) RabbitMQ supports BERT encoding as a JSON alternative. Given that BERT encoding is implemented in C inside the Erlang VM, it's way more effective than pure-Erlang JSON encoding. So this greatly reduces monitoring overhead when we have a lot of objects in RabbitMQ.

Comparison to official exporter

official exporter:

  • has runtime/erlang metrics
  • aggregated or per-object metrics
  • missing filter

This exporter:

  • works also with older versions of rabbitmq
  • has more configuration options/ filtering of objects
  • (bad) depends on data from management interface which can be slow/delayed

probalby best solution is to use both exporters: comment from shamil

common errors / FAQ

msg: Error while retrieving data from rabbitHost statusCode: 500

This exporter expects capabilities from rabbitmq 3.6.8 or newer by default. If you are running older than 3.6.8 you must disable bert and no_sort with the setting RABBIT_CAPABILITIES=compat. If you are running 3.13.0 or newer you must disable no_sort with the setting RABBIT_CAPABILITIES=no_sort.

missing data in graphs

If there is a load balancer between the exporter and the RabbitMQApi, the setting RABBIT_CONNECTION=loadbalancer must be activated. See https://github.com/kbudde/rabbitmq_exporter/issues/131 for details.

build and test

This project uses goreleaser to build and release the project. You can build the project with the following command:

goreleaser build --snapshot

go build will also work, but it will not include the version information, uses cgo, etc.

To run the tests, use the following command:

go test -v ./...

If you have docker installed, you can run the tests with the following command:

go test -v ./... --tags integration

This will start a rabbitmq container and run the tests against it.

Metrics

The metrics are documented in the metrics.md file.

Documentation ¶

Index ¶

Constants ¶

This section is empty.

Variables ¶

View Source
var (
	//Version of Rabbitmq Exporter is set during build.
	Version string
	//Revision of Rabbitmq Exporter is set during build.
	Revision string
	//Branch of Rabbitmq Exporter is set during build.
	Branch string
	//BuildDate of Rabbitmq Exporter is set during build.
	BuildDate string
)

BuildInfo is a metric with a constant '1' value labeled by version, revision, branch and build date on which the rabbitmq_exporter was built

Functions ¶

func InitLogger ¶

func InitLogger(config *RabbitExporterConfig) *logrus.Logger

func RegisterExporter ¶

func RegisterExporter(name string, f func(*http.Client, *RabbitExporterConfig) Exporter)

RegisterExporter makes an exporter available by the provided name.

func SetLogger ¶

func SetLogger(l *logrus.Logger)

Types ¶

type AlivenessInfo ¶

type AlivenessInfo struct {
	Status string
	Error  string
	Reason string
}

type Exporter ¶

type Exporter interface {
	Collect(ctx context.Context, ch chan<- prometheus.Metric) error
	Describe(ch chan<- *prometheus.Desc)
}

Exporter interface for prometheus metrics. Collect is fetching the data and therefore can return an error

type MetricMap ¶

type MetricMap map[string]float64

MetricMap maps name to float64 metric

type NodeInfo ¶

type NodeInfo struct {
	Node            string
	RabbitmqVersion string
	ErlangVersion   string
	ClusterName     string
	TotalQueues     int
}

NodeInfo presents the name and version of fetched rabbitmq

type RabbitCapabilitySet ¶

type RabbitCapabilitySet map[rabbitCapability]bool

func ParseCapabilities ¶

func ParseCapabilities(raw string) RabbitCapabilitySet

type RabbitExporterConfig ¶

type RabbitExporterConfig struct {
	RabbitURL                string              `json:"rabbit_url"`
	RabbitUsername           string              `json:"rabbit_user"`
	RabbitPassword           string              `json:"rabbit_pass"`
	RabbitConnection         string              `json:"rabbit_connection"`
	PublishPort              string              `json:"publish_port"`
	PublishAddr              string              `json:"publish_addr"`
	OutputFormat             string              `json:"output_format"`
	CAFile                   string              `json:"ca_file"`
	CertFile                 string              `json:"cert_file"`
	KeyFile                  string              `json:"key_file"`
	InsecureSkipVerify       bool                `json:"insecure_skip_verify"`
	ExcludeMetrics           []string            `json:"exlude_metrics"`
	SkipExchanges            *regexp.Regexp      `json:"-"`
	IncludeExchanges         *regexp.Regexp      `json:"-"`
	SkipQueues               *regexp.Regexp      `json:"-"`
	IncludeQueues            *regexp.Regexp      `json:"-"`
	SkipVHost                *regexp.Regexp      `json:"-"`
	IncludeVHost             *regexp.Regexp      `json:"-"`
	IncludeExchangesString   string              `json:"include_exchanges"`
	SkipExchangesString      string              `json:"skip_exchanges"`
	IncludeQueuesString      string              `json:"include_queues"`
	SkipQueuesString         string              `json:"skip_queues"`
	SkipVHostString          string              `json:"skip_vhost"`
	IncludeVHostString       string              `json:"include_vhost"`
	RabbitCapabilitiesString string              `json:"rabbit_capabilities"`
	RabbitCapabilities       RabbitCapabilitySet `json:"-"`
	AlivenessVhost           string              `json:"aliveness_vhost"`
	EnabledExporters         []string            `json:"enabled_exporters"`
	Timeout                  int                 `json:"timeout"`
	MaxQueues                int                 `json:"max_queues"`
}

type RabbitMQExporter ¶

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

func NewExporter ¶

func NewExporter(config *RabbitExporterConfig) *RabbitMQExporter

func (*RabbitMQExporter) Collect ¶

func (e *RabbitMQExporter) Collect(ch chan<- prometheus.Metric)

func (*RabbitMQExporter) Describe ¶

func (e *RabbitMQExporter) Describe(ch chan<- *prometheus.Desc)

func (*RabbitMQExporter) LastScrapeOK ¶

func (e *RabbitMQExporter) LastScrapeOK() bool

type RabbitReply ¶

type RabbitReply interface {
	// MakeMap makes a flat map from string to float values from a
	// RabbitMQ reply. Processing happens recursively and nesting
	// is represented by '.'-separated keys. Entries are added
	// only for values that can be reasonably converted to float
	// (numbers and booleans). Failure to parse should result in
	// an empty result map.
	MakeMap() MetricMap

	// MakeStatsInfo parses a list of details about some named
	// RabbitMQ objects (i.e. list of queues, exchanges, etc.).
	// Failure to parse should result in an empty result list.
	MakeStatsInfo([]string) []StatsInfo

	// GetString returns the string value for the given key
	// If the key cannot be found the second return is false
	GetString(key string) (string, bool)
}

RabbitReply is an inteface responsible for extracting usable information from RabbitMQ HTTP API replies, independent of the actual transfer format used.

func MakeReply ¶

func MakeReply(contentType string, body []byte) (RabbitReply, error)

MakeReply instantiates the apropriate reply parser for a given reply and the content-type header

type StatsInfo ¶

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

StatsInfo describes one statistic (queue or exchange): its name, vhost it belongs to, and all associated metrics.

Directories ¶

Path Synopsis
Package testenv provides a rabbitmq test environment in docker for a full set of integration tests.
Package testenv provides a rabbitmq test environment in docker for a full set of integration tests.

Jump to

Keyboard shortcuts

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