Prometheus是一个最初在SoundCloud上构建的监控系统。自2012年成为社区开源项目,拥 有非常活跃的开发人员和用户社区。为强调开源及独立维护,Prometheus于2016年加入云原生云计算基金 会(CNCF),成为继Kubernetes之后的第二个托管项目。
原理:Prometheus的基本原理是通过各种exporter提供的HTTP协议接口 周期性抓取被监控组件的状态,任意组件只要提供对应的HTTP接口就可以接入监控。 不需要任何SDK或者其他的集成过程,非常适合做虚拟化环境监控系统,比如VM、Docker、Kubernetes等。 互联网公司常用的组件大部分都有exporter可以直接使用,如Nginx、MySQL、Linux系统信息等。
[root@localhost prometheus]# ll
total 62792
-rw-r--r-- 1 root root 64298432 Dec 1 00:17 prometheus-2.23.0.linux-amd64 (1).tar.gz
[root@localhost prometheus]# tar xvfz prometheus-*.tar.gz
prometheus-2.23.0.linux-amd64/
prometheus-2.23.0.linux-amd64/LICENSE
prometheus-2.23.0.linux-amd64/consoles/
prometheus-2.23.0.linux-amd64/consoles/node-cpu.html
prometheus-2.23.0.linux-amd64/consoles/prometheus-overview.html
prometheus-2.23.0.linux-amd64/consoles/node-overview.html
prometheus-2.23.0.linux-amd64/consoles/node.html
prometheus-2.23.0.linux-amd64/consoles/node-disk.html
prometheus-2.23.0.linux-amd64/consoles/index.html.example
prometheus-2.23.0.linux-amd64/consoles/prometheus.html
prometheus-2.23.0.linux-amd64/prometheus
prometheus-2.23.0.linux-amd64/console_libraries/
prometheus-2.23.0.linux-amd64/console_libraries/prom.lib
prometheus-2.23.0.linux-amd64/console_libraries/menu.lib
prometheus-2.23.0.linux-amd64/prometheus.yml
prometheus-2.23.0.linux-amd64/promtool
prometheus-2.23.0.linux-amd64/NOTICE
[root@localhost prometheus]#
[root@localhost prometheus-2.23.0.linux-amd64]# cat 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'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9090']
[root@localhost prometheus-2.23.0.linux-amd64]# ll
total 162452
drwxr-xr-x 2 3434 3434 38 Nov 26 20:47 console_libraries
drwxr-xr-x 2 3434 3434 173 Nov 26 20:47 consoles
-rw-r--r-- 1 3434 3434 11357 Nov 26 20:47 LICENSE
-rw-r--r-- 1 3434 3434 3420 Nov 26 20:47 NOTICE
-rwxr-xr-x 1 3434 3434 88153522 Nov 26 18:58 prometheus
-rw-r--r-- 1 3434 3434 926 Nov 26 20:47 prometheus.yml
-rwxr-xr-x 1 3434 3434 78172790 Nov 26 19:00 promtool
[root@localhost prometheus-2.23.0.linux-amd64]# ./prometheus --config.file=prometheus.yml
# 5.验证
此时登录系统ip:9090
此时登录系统ip:9090/metrics可以查看到监控的数据
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有