1、安装和配置rabbitmq-exporter
1.1 使用helm安装rabbitmq-exporter
这里的rabbitmq-exporter通过helm在Kubernetes中进行安装,这里需要通过rabbitmq.url,rabbitmq.user和rabbitmq.password,设置正确的rabbitmq的url地址和用户/密码。
$ helm install prom-rabbit stable/prometheus-rabbitmq-exporter --set "rabbitmq.url=http://rabbit-service:15672" / --set "rabbitmq.user=user" --s set "rabbitmq.password=bitnami" --namespace=kube-public
rabbitmq-exporter具体配置信息请参考下表:
Parameter | Description | Default |
---|---|---|
replicaCount |
desired number of prometheus-rabbitmq-exporter pods | 1 |
image.repository |
prometheus-rabbitmq-exporter image repository | kbudde/rabbitmq-exporter |
image.tag |
prometheus-rabbitmq-exporter image tag | v0.29.0 |
image.pullPolicy |
image pull policy | IfNotPresent |
service.type |
desired service type | ClusterIP |
service.internalport |
service listening port | 9419 |
service.externalPort |
public service port | 9419 |
resources |
cpu/memory resource requests/limits | {} |
loglevel |
exporter log level | {} |
rabbitmq.url |
rabbitmq management url | http://myrabbit:15672 |
rabbitmq.user |
rabbitmq user login | guest |
rabbitmq.password |
rabbitmq password login | guest |
rabbitmq.existingPasswordSecret |
existing secret name containing password key | ~ |
rabbitmq.capabilities |
comma-separated list of capabilities supported by the RabbitMQ server | bert,no_sort |
rabbitmq.include_queues |
regex queue filter. just matching names are exported | .* |
rabbitmq.skip_queues |
regex, matching queue names are not exported | ^$ |
rabbitmq.include_vhost |
regex vhost filter. Only queues in matching vhosts are exported | .* |
rabbitmq.skip_vhost |
regex, matching vhost names are not exported. First performs include_vhost, then skip_vhost | ^$ |
rabbitmq.skip_verify |
true/0 will ignore certificate errors of the management plugin | false |
rabbitmq.exporters |
List of enabled modules. Just “connections” is not enabled by default | exchange,node,overview,queue |
rabbitmq.output_format |
Log ouput format. TTY and JSON are suported | TTY |
rabbitmq.timeout |
timeout in seconds for retrieving data from management plugin | 30 |
rabbitmq.max_queues |
max number of queues before we drop metrics (disabled if set to 0) | 0 |
annotations |
pod annotations for easier discovery | {} |
prometheus.monitor.enabled |
Set this to true to create ServiceMonitor for Prometheus operator |
false |
prometheus.monitor.additionalLabels |
Additional labels that can be used so ServiceMonitor will be discovered by Prometheus | {} |
prometheus.monitor.interval |
Interval at which Prometheus Operator scrapes exporter | 15s |
prometheus.monitor.namespace |
Selector to select which namespaces the Endpoints objects are discovered from. | [] |
1.2 查看rabbitmq指标数据
在浏览器中访问rabbitmq-exporter,能够看到所要监控的指标。
2、Prometheus监控
2.1 配置Prometheus
在Prometheus的配置文件(Prometheus.yaml)中,添加红色字体部分的内容。
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).# Alertmanager configuration
alerting:
alertmanagers:
– static_configs:
– targets:
# – alertmanager:9093# Load rules once and periodically evaluate them according to the global ‘evaluation_interval’.
rule_files:
# – “first_rules.yml”
# – “second_rules.yml”# A scrape configuration containing exactly one endpoint to scrape:
# Here it’s Prometheus itself.
scrape_configs:
# The job name is added as a label `job=` to any timeseries scraped from this config.
– job_name: ‘prometheus’# metrics_path defaults to ‘/metrics’
# scheme defaults to ‘http’.static_configs:
– targets: [‘localhost:9090’]# 配置从redis-exporter中获取数据,目标地址为:10.0.32.148:9182
– job_name: ‘rabbit’
static_configs:
– targets: [‘prom-rabbit-prometheus-rabbitmq-exporter:9419’]
2.2 配置验证
在浏览器的地址栏访问http://{prometheus}/targets,将会看到新配置的rabbitmq。
3 Grafana监控
3.1 配置Windows监控dashboard
下载rabbitmq-exporter的dashboard(rabbitmq-monitoring_rev4.json),下载地址:https://grafana.com/grafana/dashboards/4279
在grafana中导入dashboard:rabbitmq-monitoring_rev4.json。
导入后,通过此dashborad,管理员就可以监控rabbitmq的运行状态、内存、磁盘空间、消息队列和消息状态等指标。
作者简介:
季向远,北京神舟航天软件技术有限公司。本文版权归原作者所有。微博:ik8s