prometheus基于consul的服务发现

news/2024/5/19 1:58:26 标签: prometheus, consul, 服务发现

文章目录


一、基础

在这里插入图片描述

consul_8">二、安装consul

下载地址

https://developer.hashicorp.com/consul/install
在这里插入图片描述

consul_13">启动consul

mkdir -p /app/consul/{data,etc,bin}
unzip /home/devops/consul_1.17.2_linux_amd64.zip -d /app/consul/bin/
ln -sv /app/consul/bin/consul /usr/local/bin/consul
consul -v
cd /app/consul/
nohup consul agent -dev -ui -data-dir=/app/consul/data/ -config-dir=/app/consul/etc/ -client=0.0.0.0 &

consul_23">访问consul

http://IP:8500/ui/
在这里插入图片描述

三、编写服务发现文件nodes.json

vim /app/consul/etc/nodes.json

{
  "services":[
    {
      "id":"node exporter-node01",
      "name": "node01",
      "address":"192.168.1.31",
      "port": 10050,
      "tags": ["nodes"] ,
      "checks": [{
        "http":"http://192.168.1.31:10050/metrics",
        "interval":"5s"
      }]
    },
    {
      "id":"node exporter-node02",
      "name": "node02",
      "address":"192.168.1.34",
      "port": 10050,
      "tags": ["nodes"] ,
      "checks": [{
        "http":"http://192.168.1.34:10050/metrics",
        "interval":"5s"
      }]
    },
    {
      "id":"node exporter-node03",
      "name": "node03",
      "address":"192.168.1.36",
      "port": 10050,
      "tags": ["nodes"] ,
      "checks": [{
        "http":"http://192.168.1.36:10050/metrics",
        "interval":"5s"
      }]
    }
  ]
}

consul reload #加载配置文件
在这里插入图片描述

prometheusconsul_69">四、prometheus配置consul发现

prometheusyml_70">修改prometheus.yml

增加如下配置

- job_name: "nodes"
  consul_sd_configs:
  - server: 192.168.1.34:8500
    tags:
      - "nodes"
    refresh_interval: 2m

在这里插入图片描述

重启Prometheus

systemctl restart prometheus
可以发现现在获取的Targets里面有consul的字段
在这里插入图片描述

参考

https://www.bilibili.com/video/BV1PT4y1P7bX/?from=search&seid=851756632097160928


http://www.niftyadmin.cn/n/5381759.html

相关文章

人工智能技术应用笔记(二):OpenAI SORA文生视频模型技术报告全文中英对照 (GPT4翻译+人工润色)

目录 Video generation models as world simulators(视频生成模型作为世界模拟器) Turning visual data into patches (将视觉数据转换为图像块) Video compression network (视频压缩网络) Spacetim…

自己搭建的幻兽帕鲁服务器怎么一键配置游戏参数?可视化面板调整参数

单击面板内的【调整参数】按钮,即可在下方表格中开启编辑模式。找到“死亡惩罚”配置项,并将它的值修改为:无丢失。 点击【保存】按钮,此时将弹出气泡,提示你当前操作需要在游戏服务重启后才可生效(不会…

【数据库】日常使用PL/SQL 登录ORACLE 数据库查询数据

一、PL/SQL 登录方式 username: ##访问数据库的账号 password: ##访问数据库的密码 Databse: ##数据库IP地址/实例名 & 数据库集群心跳地址/实例名 Connect as : ##Normal,如果使用sysdba账户登录选择SYSDBA 二、PL/SQL使用…

深度学习基础之《TensorFlow框架(5)—会话》

一、会话 2.x版本由于是即时执行模式,所以不需要会话。但是可以手工开启会话 1、什么是会话 一个运行TensorFlow operation的类。会话包含以下两种开启方式 (1)tf.compat.v1.Session:用于完整的程序当中 (2&#xff…

Eclipse - Expressions Add Watch Expression

Eclipse - Expressions & Add Watch Expression References Window -> Show View -> Other… Show View -> Debug -> Expressions -> Open Debug 模式下出现 Expressions 窗口 Debug 模式下,如果需要查看指定变量或者返回函数的值,直…

html的表单标签(上):form标签和input标签

表单标签 表单是让用户输入信息的重要途径。 用表单标签来完成与服务器的一次交互,比如你登录QQ账号时的场景。 表单分成两个部分: 表单域:包含表单元素的区域,用form标签来表示。表单控件:输入框,提交按…

Pytorch的常用模块和用途说明

关注B站可以观看更多实战教学视频:肆十二-的个人空间-肆十二-个人主页-哔哩哔哩视频 (bilibili.com) Hi,兄弟们,这里是肆十二,今天我们来讨论一下深Pytorch中的常用模块。 PyTorch是一个开源的深度学习平台,提供了许多…

使用git push,和使用git push origin HEAD:[分支名]有什么区别呢?

git push origin HEAD:branch2: 这个命令显式地指定了你要推送的本地引用(HEAD),以及远程仓库的目标引用(origin/branch2)。 HEAD 是一个引用,指向你当前所在的本地分支的最新提交。 这个命令的意图是将当…