rabbitmq-exporter部署方式

rabbitmq-exporter部署方式

来源

https://github.com/kbudde/rabbitmq_exporter/

说明

RabbitMQ 指标的 Prometheus 导出器。数据由prometheus 抓取。

请注意这是一个非官方插件。还有一个来自RabbitMQ.com的官方插件。查看与官方出口商的比较

部署方式

docker部署:

rabbitmq_exporter 与 rabbitmq 容器共享网络接口 -> 可以使用 localhost 和默认用户/密码(guest)。

  1. 启动rabbitMQ
 docker run -d -e RABBITMQ_NODENAME=my-rabbit --name my-rabbit -p 9419:9419 rabbitmq:3-management
  1. 在容器中启动 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
}

注:

Environmentvariabledefault description
RABBIT_URLhttp://127.0.0.1:15672url to rabbitMQ management plugin (must start with http(s)😕/)
RABBIT_USERguestusername for rabbitMQ management plugin. User needs monitoring tag!
RABBIT_PASSWORDguestpassword for rabbitMQ management plugin
RABBIT_USER_FILElocation of file with username (useful for docker secrets)
RABBIT_PASSWORD_FILElocation of file with password (useful for docker secrets)
PUBLISH_PORT9419Listening port for the exporter
PUBLISH_ADDR“”Listening host/IP for the exporter
OUTPUT_FORMATTTYLog ouput format. TTY and JSON are suported
LOG_LEVELinfolog level. possible values: “debug”, “info”, “warning”, “error”, “fatal”, or “panic”
CAFILEca.pempath to root certificate for access management plugin. Just needed if self signed certificate is used. Will be ignored if the file does not exist
CERTFILEclient-cert.pempath to client certificate used to verify the exporter’s authenticity. Will be ignored if the file does not exist
KEYFILEclient-key.pempath to private key used with certificate to verify the exporter’s authenticity. Will be ignored if the file does not exist
SKIPVERIFYfalsetrue/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_CAPABILITIESbert,no_sortcomma-separated list of extended scraping capabilities supported by the target RabbitMQ server
RABBIT_EXPORTERSexchange,node,queueList of enabled modules. Possible modules: connections,shovel,federation,exchange,node,queue,memory
RABBIT_TIMEOUT30timeout in seconds for retrieving data from management plugin.
MAX_QUEUES0max number of queues before we drop metrics (disabled if set to 0)
EXCLUDE_METRICSMetric 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_”为前缀。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值