实战Prometheus-consul_exporter

简介: Prometheus

8、consul_exporter-0.7.1 安装部署
官方下载地址:
https://github.com/prometheus/consul_exporter/releases/download/v0.7.1/consul_exporter-0.7.1.linux-amd64.tar.gz
Consul 是基于 GO 语言开发的开源工具,主要面向分布式,服务化的系统提供服务注册、服务发现和配置管理的功能。Consul 提供服务注册/发现、健康检查、Key/Value存储、多数据中心和分布式一致性保证等功能。之前我们通过 Prometheus 实现监控,当新增一个 Target 时,需要变更服务器上的配置文件,即使使用 file_sd_configs 配置,也需要登录服务器修改对应 Json 文件,会非常麻烦。不过 Prometheus 官方支持多种自动服务发现的类型,其中就支持 Consul。
1、consul_exporter 安装

https://github.com/prometheus/consul_exporter/releases/tag/v0.5.0
# 解压文件
tar xf consul_exporter-0.7.1.linux-amd64.tar.gz
cd consul_exporter-0.7.1.linux-amd64/

# 配置启动文件
vim  /usr/lib/systemd/system/consul_exporter.service
[Unit]
Description=blackbox_exporter
After=network.target

[Service]
User=root
Group=root
WorkingDirectory=/montion/consul_exporter-0.7.1.linux-amd64
ExecStart=/montion/consul_exporter-0.7.1.linux-amd64/consul_exporter
[Install]
WantedBy=multi-user.target

# 启动
systemctl restart consul_exporter.service

# 开机自启
systemctl enable consul_exporter.service

# 访问地址
浏览器访问 http://ip:9107

################# prometheus 配置###############
  - job_name: 'consul-export'
    metrics_path: "/v1/agent/metrics"
    scheme: 'http'
    param:
      format: ['prometheus']
    consul_sd_configs:
    - targets:
      - 'x.x.x.x:8500'




#########################  配置中心方法++++++++++++++
cat consul.json
{
  "ID": "consul-instance-x.x.x.x",
  "Name": "consul-instance-x.x.x.x",
  "Tags": [
    "consul_instance"
  ],
  "Address": "x.x.x.x",
  "Port": 9107,
  "Meta": {
    "instance": "consul-instance-x.x.x.x",
    "role": "test-it-consul-cluster-prod"
  },
  "EnableTagOverride": false,
  "Check": {
    "HTTP": "http://x.x.x.x:9107/metrics",
    "Interval": "10s"
  },
  "Weights": {
    "Passing": 10,
    "Warning": 1
  }
}
# 注册服务
curl -X PUT --data @consul.json http://x.x.x.x:8500/v1/agent/service/register
# 注销服务
curl  --request PUT  http://x.x.x.x:8500/v1/agent/service/deregister/consul-instance-x.x.x.x

# grafana 模板
https://grafana.com/grafana/dashboards/12049
相关文章
|
4月前
|
消息中间件 Prometheus 监控
Prometheus实战篇:什么是Exporter
所有可以向Prometheus提供监控样本数据的程序都可以被称为一个Exporter.而Exporter的一个实例称为target,如图下所示, Prometheus通过轮询的方式定期从这些target中获取样本数据
|
2月前
|
Prometheus 监控 Kubernetes
Prometheus Operator 与 kube-prometheus 之二 - 如何监控 1.23+ kubeadm 集群
Prometheus Operator 与 kube-prometheus 之二 - 如何监控 1.23+ kubeadm 集群
|
存储 Kubernetes 数据安全/隐私保护
在kubernetes上部署consul集群
本教程将帮助你在kubernetes上部署一个拥有3个节点的consul集群 备注:consul教程见Consul; 预览 consul 集群的三个节点部署方式使用 StatefulSet consul集群成员之间使用TLS进行安全通信 TLS and encryption keys 预备知识 本教程利用了Kubernetes 1.
4185 0
|
2月前
|
Prometheus Kubernetes 监控
Prometheus Operator 与 kube-prometheus 之一 - 简介
Prometheus Operator 与 kube-prometheus 之一 - 简介
|
6月前
|
Prometheus 监控 Cloud Native
Prometheus基于consul服务发现
Prometheus基于consul服务发现
|
9月前
|
Prometheus 监控 Cloud Native
【2023】Prometheus-Blackbox_exporter使用
【2023】Prometheus-Blackbox_exporter使用
199 0
|
9月前
|
JSON Prometheus 监控
使用Exporter为Prometheus添加监控对象(持续更新ing)
使用Exporter为Prometheus添加监控对象(持续更新ing)
199 0
|
9月前
|
Prometheus Cloud Native NoSQL
【2023】Prometheus-Prometheus与Alertmanager配置详解
【2023】Prometheus-Prometheus与Alertmanager配置详解
477 0
【2023】Prometheus-Prometheus与Alertmanager配置详解
|
11月前
|
Prometheus 监控 Cloud Native
Prometheus: ansible+consul自动发现,监控服务器
Prometheus: ansible+consul自动发现,监控服务器
386 0