Prometheus是一套开源的监控&报警&时间序列数据库的组合,基于应用的metrics来进行监控的开源工具 。

一、下载Prometheus

官方文档:https://prometheus.io/docs/prometheus/latest/getting_started/
下载地址: https://prometheus.io/download/ 下载如下版本:

下载解压查看:
1)下载: wget https://github.com/prometheus/prometheus/releases/download/v2.34.0/prometheus-2.34.0.linux-amd64.tar.gz
2)解压:tar -zxvf prometheus-2.34.0.linux-amd64.tar.gz

[root@VM-0-2-centos srv]# wget https://github.com/prometheus/prometheus/releases/download/v2.34.0/prometheus-2.34.0.linux-amd64.tar.gz
--2022-04-15 21:44:14--  https://github.com/prometheus/prometheus/releases/download/v2.34.0/prometheus-2.34.0.linux-amd64.tar.gz
Resolving github.com (github.com)... 20.205.243.166
Connecting to github.com (github.com)|20.205.243.166|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/6838921/408c8e8d-cf9a-4902-a7b4-679a51d5db85?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220415%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220415T134415Z&X-Amz-Expires=300&X-Amz-Signature=c9d52cc5bff876bbd31cd155fe3e9af87e12651a35faea3c3588aecaf144166a&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=6838921&response-content-disposition=attachment%3B%20filename%3Dprometheus-2.34.0.linux-amd64.tar.gz&response-content-type=application%2Foctet-stream [following]
--2022-04-15 21:44:15--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/6838921/408c8e8d-cf9a-4902-a7b4-679a51d5db85?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220415%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220415T134415Z&X-Amz-Expires=300&X-Amz-Signature=c9d52cc5bff876bbd31cd155fe3e9af87e12651a35faea3c3588aecaf144166a&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=6838921&response-content-disposition=attachment%3B%20filename%3Dprometheus-2.34.0.linux-amd64.tar.gz&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.108.133, 185.199.111.133, 185.199.110.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.108.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 76299772 (73M) [application/octet-stream]
Saving to: ‘prometheus-2.34.0.linux-amd64.tar.gz’100%[=============================================================================================================================================================================================================================>] 76,299,772   406KB/s   in 6m 14s 2022-04-15 21:50:30 (199 KB/s) - ‘prometheus-2.34.0.linux-amd64.tar.gz’ saved [76299772/76299772]
[root@VM-0-2-centos srv]# tar -zxvf prometheus-2.34.0.linux-amd64.tar.gz
prometheus-2.34.0.linux-amd64/
prometheus-2.34.0.linux-amd64/consoles/
prometheus-2.34.0.linux-amd64/consoles/index.html.example
prometheus-2.34.0.linux-amd64/consoles/node-cpu.html
prometheus-2.34.0.linux-amd64/consoles/node-disk.html
prometheus-2.34.0.linux-amd64/consoles/node-overview.html
prometheus-2.34.0.linux-amd64/consoles/node.html
prometheus-2.34.0.linux-amd64/consoles/prometheus-overview.html
prometheus-2.34.0.linux-amd64/consoles/prometheus.html
prometheus-2.34.0.linux-amd64/console_libraries/
prometheus-2.34.0.linux-amd64/console_libraries/menu.lib
prometheus-2.34.0.linux-amd64/console_libraries/prom.lib
prometheus-2.34.0.linux-amd64/prometheus.yml
prometheus-2.34.0.linux-amd64/LICENSE
prometheus-2.34.0.linux-amd64/NOTICE
prometheus-2.34.0.linux-amd64/prometheus
prometheus-2.34.0.linux-amd64/promtool
[root@VM-0-2-centos srv]# ls
prometheus-2.34.0.linux-amd64  prometheus-2.34.0.linux-amd64.tar.gz

二、查看配置文件 prometheus.yml

# my global config 全局配置
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=<job_name>` to any timeseries scraped from this config.# 监控对象名称,按自己的意愿起名- job_name: "prometheus"# 监控指标路径(prometheus默认为/metrics)# metrics_path defaults to '/metrics'# 监控指标请求类型# scheme defaults to 'http'.# 目标对象地址集合static_configs:- targets: ["localhost:9090"]

三、启动 Prometheus

启动:./prometheus --config.file=prometheus.yml &

[root@VM-0-2-centos prometheus2.34.0]# ./prometheus --config.file=prometheus.yml &
[1] 6948
[root@VM-0-2-centos prometheus2.34.0]# ts=2022-04-15T14:13:01.983Z caller=main.go:479 level=info msg="No time or size retention was set so using the default time retention" duration=15d
ts=2022-04-15T14:13:01.984Z caller=main.go:516 level=info msg="Starting Prometheus" version="(version=2.34.0, branch=HEAD, revision=881111fec4332c33094a6fb2680c71fffc427275)"
ts=2022-04-15T14:13:01.984Z caller=main.go:521 level=info build_context="(go=go1.17.8, user=root@121ad7ea5487, date=20220315-15:18:00)"
ts=2022-04-15T14:13:01.984Z caller=main.go:522 level=info host_details="(Linux 3.10.0-1160.11.1.el7.x86_64 #1 SMP Fri Dec 18 16:34:56 UTC 2020 x86_64 VM-0-2-centos (none))"
ts=2022-04-15T14:13:01.984Z caller=main.go:523 level=info fd_limits="(soft=100001, hard=100002)"
ts=2022-04-15T14:13:01.984Z caller=main.go:524 level=info vm_limits="(soft=unlimited, hard=unlimited)"
ts=2022-04-15T14:13:01.987Z caller=web.go:540 level=info component=web msg="Start listening for connections" address=0.0.0.0:9090
ts=2022-04-15T14:13:01.987Z caller=main.go:937 level=info msg="Starting TSDB ..."
ts=2022-04-15T14:13:01.988Z caller=tls_config.go:195 level=info component=web msg="TLS is disabled." http2=false
ts=2022-04-15T14:13:01.990Z caller=head.go:493 level=info component=tsdb msg="Replaying on-disk memory mappable chunks if any"
ts=2022-04-15T14:13:01.991Z caller=head.go:536 level=info component=tsdb msg="On-disk memory mappable chunks replay completed" duration=11.305µs
ts=2022-04-15T14:13:01.991Z caller=head.go:542 level=info component=tsdb msg="Replaying WAL, this may take a while"
ts=2022-04-15T14:13:01.991Z caller=head.go:613 level=info component=tsdb msg="WAL segment loaded" segment=0 maxSegment=1
ts=2022-04-15T14:13:01.991Z caller=head.go:613 level=info component=tsdb msg="WAL segment loaded" segment=1 maxSegment=1
ts=2022-04-15T14:13:01.991Z caller=head.go:619 level=info component=tsdb msg="WAL replay completed" checkpoint_replay_duration=28.768µs wal_replay_duration=720.155µs total_replay_duration=778.494µs
ts=2022-04-15T14:13:01.993Z caller=main.go:958 level=info fs_type=EXT4_SUPER_MAGIC
ts=2022-04-15T14:13:01.993Z caller=main.go:961 level=info msg="TSDB started"
ts=2022-04-15T14:13:01.993Z caller=main.go:1142 level=info msg="Loading configuration file" filename=prometheus.yml
ts=2022-04-15T14:13:01.994Z caller=main.go:1179 level=info msg="Completed loading of configuration file" filename=prometheus.yml totalDuration=813.979µs db_storage=1.076µs remote_storage=4.125µs web_handler=411ns query_engine=2.695µs scrape=329.984µs scrape_sd=53.915µs notify=57.209µs notify_sd=14.981µs rules=2.86µs tracing=10.344µs
ts=2022-04-15T14:13:01.994Z caller=main.go:910 level=info msg="Server is ready to receive web requests."[root@VM-0-2-centos prometheus2.34.0]# ps -ef | grep prometheus
root      7712  2615  1 22:18 pts/0    00:00:00 ./prometheus --config.file=prometheus.yml
root      7729  2615  0 22:18 pts/0    00:00:00 grep --color=auto prometheus

四、访问Prometheus

浏览器上输入服务器ip:9090即可访问。如下图所示,则表明成功。

4.1 查看监控对象

说明:http://localhost:9090/metrics是查看采集到的性能指标。从prometheus.yml可以看出,prometheus 是默认监控自己的。

4.2 查看监控对象metrics

http://ip:9090/metrics 得到如下输出:

4.3 查看配置信息

4.4 查看服务发现情况

我这边后截图的,所以多了2个其他服务,请忽略。

五、热启动 Prometheus (无需kill重启)

启动时添加–web.enable-lifecycle 参数

./prometheus --web.enable-lifecycle --config.file=prometheus.yml &

修改完配置文件后,执行如下命令curl -XPOST http://127.0.0.1:9090/-/reload进行热启动:

[root@sg data]# curl -XPOST http://127.0.0.1:9090/-/reload
ts=2022-06-15T07:35:20.592Z caller=main.go:1142 level=info msg="Loading configuration file" filename=prometheus.yml
ts=2022-06-15T07:35:20.593Z caller=main.go:1179 level=info msg="Completed loading of configuration file" filename=prometheus.yml totalDuration=520.986µs db_storage=1.636µs remote_storage=2.363µs web_handler=762ns query_engine=1.022µs scrape=116.287µs scrape_sd=44.924µs notify=17.303µs notify_sd=11.038µs rules=1.743µs tracing=3.334µs

END

服务监控(一)之安装Prometheus相关推荐

  1. Prometheus( 普罗⽶修斯) 监控系统----介绍安装、Grafana出图

    Promethus(普罗⽶修斯)监控系统 能够安装prometheus服务器 能够通过安装node_exporter监控远程linux 能够通过安装mysqld_exporter监控远程mysql数据 ...

  2. Kubernetes 微服务监控体系

    作者|无敌码农 来源|无敌码农 监控系统是运维体系乃至整个软件产品生命周期中最重要的一环,完善的监控可以帮助我们事前及时发现故障,事后快速追查定位问题.而在以微服务为代表的云原生架构体系中,系统分为多 ...

  3. DeVOpS 实战:Kubernetes 微服务监控体系

    来源 | 无敌码农 责编 | 寇雪芹 头图 | 下载于视觉中国 监控系统是运维体系乃至整个软件产品生命周期中最重要的一环,完善的监控可以帮助我们事前及时发现故障,事后快速追查定位问题. 而在以微服务为 ...

  4. Linux安装prometheus+grafana监控

    一.在业务中遇到服务器负载过高问题,由于没有监控,一直没发现,直到业务方反馈网站打开速度慢,才发现问题.这样显得开发很被动.所以是时候搭建一套监控系统了. 由于是业余时间自己捯饬,所以神马业务层面的监 ...

  5. prometheus 配置服务器监控、服务监控、容器中服务监控与告警

    最近公司有几个服务遇到了瓶颈,也就是数据量增加了,没有人发现,这不是缺少一个监控服务和告警的系统吗? 主要需求是监控每个服务,顺带监控一下服务器和一些中间件,这里采集的2种,zabbix和promet ...

  6. Prometheus监控系列一 | 安装部署及配置

    Prometheus监控系列一 | 安装部署及配置 文章目录 0 简介 1 基础环境 2 安装Prometheus 2.1 安装 2.2 配置开机自启动 2.3 启动服务 2.4 验证 3 安装Gra ...

  7. prometheus服务监控之mysql监控

    文章目录 上传解压安装mysqld_exporter 安装mariadb 在数据库里创建mysql账号用户收集数据 在mysql_exporter中设置mysql配置信息 启动mysql_export ...

  8. 网易云基于Prometheus的微服务监控实践

    当监控遇上微服务 在过去数年里,微服务的落地一直都是业界重点关注的问题,其始终面临着部署.监控.配置和治理等方面的挑战.轻舟微服务平台是网易云为企业提供的一套微服务解决方案,其中微服务监控是其关注的重 ...

  9. Mac安装prometheus+grafana监控

    软件安装 Prometheus 官网下载(https://prometheus.io/),支持Linux.Mac.Windows系统,很好很强大.我这里安装过Centos和Mac,这里的实例以Mac为 ...

  10. 微服务监控告警:Prometheus

    来源: <微服务架构实战160讲> 微服务监控告警 prometheus是多维度(标签)的,使用拉模式,黑盒白盒都支持,对DevOps友好,适用中小规模 支持的Metric种类:计数器.测 ...

最新文章

  1. android怎么垂直居中且靠右,placeholder 靠右垂直居中/位置兼容
  2. mysql恢复数据库 慢_Mysqldump导入数据库很慢的解决办法
  3. 腾讯云与阿里云竞争激烈:销售团队积极争取每一笔交易
  4. 95-864-040-源码-HDFS-Flink 和 HDFS 的交互
  5. 什么? 搞不定 Redis 分布式锁?
  6. 植物病理学分类的高效网络体系结构的半监督噪声学生预训练
  7. Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1)问题解决
  8. PTA—求整数段和(C语言)
  9. bzoj 5029 poj 2528 nyoj 1009: 贴小广告(线段树)
  10. 大小端转换定义结构体的技巧
  11. 思科交换机配置试题_思科交换机配置命令大全 思科交换机配置手册
  12. font-family 使用设置
  13. 解决多旅行商(MTSP)的分组遗传算法(GGA-SS)
  14. 电脑安装哪款linux系统好,四款linux操作系统总有一款适合你
  15. 数据库连接报错代码-08S01
  16. 为什么需要开发X 波段带通滤波器
  17. http常见状态返回码
  18. 注意力缺陷/多动障碍和睡眠障碍之间有什么联系?基于大规模队列多模态研究
  19. 小程序 【头像昵称填写能力】使用
  20. 理论力学知识要点(九)

热门文章

  1. 无线院2018下半年技术教练认证-专业能力测评初试
  2. Linux一句话精彩问答
  3. map集合和set集合
  4. 开平方算法的C++实现
  5. python求小于n的最大素数_枚举1--求小于n的最大素数
  6. 基于beautifulSoup进行电影网站排名的获取与格式化输出
  7. 日文輸入法学习和日文键盘图
  8. 位运算判断两个数是否异号
  9. 计算机科学型,函数计算器1005B学生专用 多功能计算机科学函数型
  10. matlab中画花瓣,matlab花瓣图的编程原理是什么,向天下大侠求解!!!!给力的? 爱问知识人...