发布时间:2025-12-09 13:51:23 浏览次数:5
Prometheus(普罗米修斯)是一套开源的监控&报警&时间序列数据库的组合,由 SoundCloud 公司开发。
Prometheus 基本原理是通过 HTTP 协议周期性抓取被监控组件的状态,这样做的好处是任意组件只要提供 HTTP 接口就可以接入监控系统,不需要任何 SDK 或者其他的集成过程。这样做非常适合虚拟化环境比如 VM 或者 Docker 。
Prometheus 应该是为数不多的适合 Docker、Mesos、Kubernetes 环境的监控系统之一。
易于管理:
强大的查询语言 PromQL:
高效:
可扩展:
sharding)+ 联邦集群(federation)可以对其进行扩展。易于集成:
可视化:
[root@Prometheus ~]# vim /usr/local/prometheus/prometheus.yml在最后面添加:remote_write: - url: "http://localhost:8086/api/v1/prom/write?db=prometheus"remote_read: - url: "http://localhost:8086/api/v1/prom/read?db=prometheus"[root@Prometheus ~]# systemctl restart prometheus# 重启 Prometheusinfluxdb 配置密码,请参考 官网文档 来进行配置。[root@Client ~]# wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz[root@Client ~]# tar xf node_exporter-0.18.1.linux-amd64.tar.gz[root@Client ~]# mv node_exporter-0.18.1.linux-amd64 /usr/local/exporter/[root@Client ~]# vim /usr/lib/systemd/system/node_exporter.service[Unit]Description=node_exporterAfter=network.target [Service]User=prometheusGroup=prometheusExecStart=/usr/local/exporter/node_exporter \ --web.listen-address=:20001 \ --collector.systemd \ --collector.systemd.unit-whitelist=(sshd|nginx).service \ --collector.processes[Install]WantedBy=multi-user.target[root@Client ~]# systemctl daemon-reload[root@Client ~]# systemctl enable --now node_exporter当启动 node_exporter 服务后,便可以通过 20001 端口来访问 Client 的监控指标。
[root@Prometheus ~]# vim /usr/local/prometheus/prometheus.yml- job_name: "Client" static_configs: - targets: - "192.168.1.2:20001"[root@Prometheus ~]# systemctl restart prometheus
[root@Grafana ~]# wget https://dl.grafana.com/oss/release/grafana-6.1.4-1.x86_64.rpm[root@Grafana ~]# tar xf grafana-6.1.4-1.x86_64.rpm[root@Grafana ~]# systemctl enable --now grafana-server[root@Grafana ~]# netstat -anpt | grep 3000
Add data source(添加数据源)
Import(导入模板)