目录
rabbitmq-exporter部署方式
来源
https://github.com/kbudde/rabbitmq_exporter/
说明
RabbitMQ 指标的 Prometheus 导出器。数据由prometheus 抓取。
请注意这是一个非官方插件。还有一个来自RabbitMQ.com的官方插件。查看与官方出口商的比较
部署方式
docker部署:
rabbitmq_exporter 与 rabbitmq 容器共享网络接口 -> 可以使用 localhost 和默认用户/密码(guest)。
-
启动rabbitMQ
docker run -d -e RABBITMQ_NODENAME=my-rabbit --name my-rabbit -p 9419:9419 rabbitmq:3-management
-
在容器中启动 rabbitmq_exporter
docker run -d --net=container:my-rabbit kbudde/rabbitmq-exporter
现在您的指标通过http://host:9419/metrics公开
配置文件配置
文件下载:
https://github.com/kbudde/rabbitmq_exporter/releases/download/v1.0.0-RC8/rabbitmq_exporter-1.0.0-RC8.linux-amd64.tar.gz
解压后进入目录;
Rabbitmq_exporter 可以使用 json 配置文件或环境变量进行配置。
Rabbitmq_exporter 需要“conf/rabbitmq.conf”中的配置文件。如果您在容器 (docker/kubernetes) 中运行导出器,则配置必须在“/conf/rabbitmq.conf”中。文件名可以用标志覆盖:
./rabbitmq_exporter -config-file config.example.json
具体格式如下:
{
"rabbit_url": "http://127.0.0.1:15672",
"rabbit_user": "guest",
"rabbit_pass": "guest",
"publish_port": "9419",
"publish_addr": "",
"output_format": "TTY",
"ca_file": "ca.pem",
"cert_file": "client-cert.pem",
"key_file": "client-key.pem",
"insecure_skip_verify": false,
"exlude_metrics": [],
"include_queues": ".*",
"skip_queues": "^$",
"skip_vhost": "^$",
"include_vhost": ".*",
"rabbit_capabilities": "no_sort,bert",
"enabled_exporters": [
"exchange",
"node",
"overview",
"queue"
],
"timeout": 30,
"max_queues": 0
}
注:
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_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
INCLUDE_VHOST
.*
regex vhost filter. Only queues in matching vhosts are exported
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
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
示例和推荐设置:
SKIP_QUEUES="RPC_.*" MAX_QUEUES=5000 ./rabbitmq_exporter
扩展的 RabbitMQ 功能
较新版本的 RabbitMQ 可以提供一些功能,以减少因抓取此导出器所需的数据而造成的开销。RABBIT_CAPABILITIESenv var目前支持以下功能 :
-
no_sort:默认情况下,RabbitMQ 管理插件使用 vhost/name 的默认排序顺序对结果进行排序。sort=从版本 3.6.8 开始,可以通过将空排序参数 ( )传递给 RabbitMQ来避免这种排序开销。在早期的 3.6.X 版本上可以安全地启用此选项,但它不会提供任何性能改进。它与 3.4.X 和 3.5.X 不兼容。
-
bert:从 3.6.9(参见 https://github.com/rabbitmq/rabbitmq-management/pull/367)开始,RabbitMQ 支持 BERT 编码作为 JSON 替代方案。鉴于 BERT 编码是在 Erlang VM 中用 C 实现的,它比纯 Erlang JSON 编码更有效。所以当我们在 RabbitMQ 中有很多对象时,这大大减少了监控开销。
rabbmitmq < 3.6 用户注意事项
默认情况下启用 no_sort 和 bert。您必须使用以下内容覆盖默认设置:RABBIT_CAPABILITIES=nobert ./rabbitmq_exporter
所有指标(golang/prometheus 指标除外)都以“rabbitmq_”为前缀。