方案选型
系统监控有很多成熟的方案,商业级监控、企业级监控、小集群监控、个人资源监控等,在不同的应用场景下选型不同的技术方案。
知名度比较高的 zabbix、Nagios、Prometheus等
15个最好的免费开源监控系统
[图片上传失败...(image-1329a-1732168013380)]
https://i-blog.csdnimg.cn/blog_migrate/6d5bbc436a13f6545f103cf1512195b4.png
此处对比两个可私人部署的免费方案
collectd+influxDB+Grafana搭建性能监控平台
Prometheus+Node_exporter+Grafana监控
监控资源的原理
- 数据采集 :探针程序, 负责收集被监控的终端主机上的cpu、内存、网络、进程等信息
- 数据存储 :通常采用时序数据库,存储监控的数据
- 数据显示 : 采用酷炫的前端网页,显示各种图表
- 数据报警 : 通过定义监控字段的阈值,设置邮件、短信、webhook等方式的报警
方案介绍 nodeexporter + prometheus + grafana
本方案从2018起,几乎是覆盖性席卷,云服务器搭载docker、 kerbuners的资源监控必备。
- node_exporter 用go写的,轻量级程序只有10M,采集主机上的监控数据
- prometheus 用go写的,集成了时序数据库TSDB ,负责从node_exporter拉取监控数据并存储, 支持数据的时序查询语法和复杂聚合查询
- grafana 专业的负责数据显示
特点在于,go写的,主动拉取式,其方案框架和周边如下图:
[图片上传失败...(image-97228c-1732168013381)]
[图片上传失败...(image-c73169-1732168166828)]
https://i-blog.csdnimg.cn/blog_migrate/9889c8de24a5bc67d0644f3b19a6137b.png
方案介绍 collectd + influxdb + grafana
collectd是c开发的,作为守护进程服务的探针程序。其本身不带数据库,可通过配置把采集的监控数据推送到其他数据库中。collectd可扩展各种数据采集插件,这也导致其看起来臃肿混乱。
[图片上传失败...(image-ba3f80-1732168013381)]
https://i-blog.csdnimg.cn/blog_migrate/a8418b8f4bb6106c13bef45434a983b5.png
方案对比
we will explore the key differences between Prometheus and collectd. Both Prometheus and collectd are popular monitoring tools used in the IT industry for collecting and visualizing metrics. However, they differ in several important aspects.
Data storage:
Prometheus stores data in a time series database, allowing users to query and analyze metrics over time. On the other hand, collectd does not have built-in data storage capabilities and requires integration with other databases or monitoring systems for data storage.Collection method:
Prometheus uses a pull-based model for metric collection, where it actively queries targets at regular intervals to gather metric data. In contrast, collectd uses a push-based model, where it relies on agents installed on target systems to send metric data to a centralized server.Metrics format:
Prometheus uses its own exposition format called Prometheus exposition format (text-based format), which is simple and human-readable. In contrast, collectd uses a binary format for transmitting metrics, which is more efficient for data transport but not as easily readable by humans.Monitoring system compatibility:
Prometheus is designed to be a standalone monitoring system and includes its own visualization and alerting capabilities. Collectd, on the other hand, is often used as a data collection agent for other monitoring systems like Graphite or InfluxDB, which handle visualization and alerting.Scalability and architecture:
Prometheus uses a federated architecture, allowing multiple Prometheus servers to be connected and form a highly scalable monitoring solution. Collectd, on the other hand, does not have native support for federation and may require additional tools or configurations for achieving similar scalability.Community and ecosystem:
Prometheus has a large and active community, with a wide range of exporters and integrations available. It also has strong integration with Kubernetes for containerized environments. Collectd also has a community and ecosystem, but it may not be as extensive and mature as Prometheus.
In summary, Prometheus and collectd differ in terms of data storage, collection method, metrics format, monitoring system compatibility, scalability and architecture, and community/ecosystem support. Each tool has its own strengths and use cases, so it is important to consider these differences when choosing the right monitoring solution for your specific needs.
环境安装
====================== Prometheus =============================
wget prometheu-amd64.tar.gz
tar -xzf prometheu-amd64.tar.gz
sudo mv -r prometheus-2.27.1.linux-amd64/ /usr/share/prometheus/
cd /usr/share/prometheus/
./prometheus --version
sudo gedit ./prometheus.yml add node_exporter 127.0.0.1:9100
nohup ./prometheus --config.file=prometheus.yml &
./prometheus
http://127.0.0.1:9090/metrics
http://127.0.0.1:9090/graph
====================== node_exporter =============================
https://github.com/prometheus/node_exporter/releases
wget https://github.com/prometheus/node_exporter/releases/download/v1.2.0/node_exporter-1.2.0.linux-amd64.tar.gz
tar -zxvf node_exporter-1.8.2.linux-amd64.tar.gz
sudo mv node_exporter-1.8.2.linux-amd64 /usr/share/node_exporter
cd /usr/share/node_exporter
./node_exporter --help
./node_exporter --version
nohup ./node_exporter &
====================== grafana =============================
2005 wget https://dl.grafana.com/enterprise/release/grafana-enterprise_11.3.1_amd64.deb
2006 ll -lh
2007 sudo dpkg -i grafana-enterprise_11.3.1_amd64.deb
2008 systemctl status grafana-server.service
2009 systemctl enable grafana-server.service
2010 systemctl status grafana-server.service
2011 sudo systemctl start grafana-server.service
http://127.0.0.1:3000 admin admin or 123456
add datasource add dashboards