夜莺监控搭建V6.0
夜莺监控介绍
官网:https://flashcat.cloud/
GitHub:https://github.com/ccfos/nightingale

架构图
1.自己画的架构图。方便理解

1.1 软件包安装
[root@aly ~]
[root@aly ~]
[root@aly ~]
[root@aly ~]
1.2 启动普罗米修斯时序库
[root@aly ~]
[Unit]
Description="prometheus"
Documentation=https://prometheus.io/
After=network.target
[Service]
Type=simple
ExecStart=/opt/prometheus/prometheus --config.file=/opt/prometheus/prometheus.yml --storage.tsdb.path=/opt/prometheus/data --web.enable-lifecycle --enable-feature=remote-write-receiver --query.lookback-delta=2m
Restart=on-failure
SuccessExitStatus=0
LimitNOFILE=65536
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=prometheus
[Install]
WantedBy=multi-user.target
EOF
[root@aly ~]
[root@aly ~]
[root@aly ~]
1.2 依赖软件安装
1.mysql安装
[root@aly ~]
[root@aly ~]
mysql -e "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('1234');"
set global validate_password_policy=LOW;
set global validate_password_length=6;
2.redis安装
[root@aly ~]
[root@aly ~]
1.3 安装夜莺
[root@aly ~]
[root@aly n9e]
[root@aly n9e]
[root@aly n9e]
[root@aly n9e]
[Redis]
Address = "127.0.0.1:6379"
[DB]
DSN="root:123456@tcp(127.0.0.1:3306)/n9e_v6?charset=utf8mb4&parseTime=True&loc=Local&allowNativePasswords=true"
[[Pushgw.Writers]]
Url = "http://127.0.0.1:9090/api/v1/write"
BasicAuthUser = ""
BasicAuthPass = ""
Headers = ["X-From", "n9e"]
Timeout = 10000
DialTimeout = 3000
TLSHandshakeTimeout = 30000
ExpectContinueTimeout = 1000
IdleConnTimeout = 90000
KeepAlive = 30000
MaxConnsPerHost = 0
MaxIdleConns = 100
MaxIdleConnsPerHost = 100
[root@aly n9e]
[Unit]
Description="n9e.service"
After=network.target
[Service]
Type=simple
ExecStart=/opt/n9e/n9e server
WorkingDirectory=/opt/n9e
Restart=on-failure
SuccessExitStatus=0
LimitNOFILE=65536
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=n9e.service
[Install]
WantedBy=multi-user.target
EOF
[root@aly n9e]
[root@aly n9e]
agent端安装categraf采集器,配置文件中编写nginx的域名->nginx中配置反向代理+负载均衡将流量转发给n9e-server->n9e-server暴漏17000端口将请求接收后转发给配置文件Pushg.writers的时序库vminsert:8428端口将数据进行存储!
1.3.1 安装时序库VM(可选)
VictoriaMetrics 架构简单,可靠性高,在性能,成本,可扩展性方面表现出色,社区活跃,且和 Prometheus 生态绑定紧密。如果单机版本的 Prometheus 无法在容量上满足贵司的需求,可以使用 VictoriaMetrics 作为时序数据库。
VictoriaMetrics 提供单机版和集群版。如果您的每秒写入数据点数小于100万(这个数量是个什么概念呢,如果只是做机器设备的监控,每个机器差不多采集200个指标,采集频率是10秒的话每台机器每秒采集20个指标左右,100万/20=5万台机器),VictoriaMetrics 官方默认推荐您使用单机版,单机版可以通过增加服务器的CPU核心数,增加内存,增加IOPS来获得线性的性能提升。且单机版易于配置和运维,
它可以用作普罗米修斯的长期储存。
它可以用作 Grafana中Prometheus 的直接替代品,因为它支持 Prometheus 查询 API。
它可以用作Grafana中Graphite的直接替代品,因为它支持Graphite API。与Graphite相比,VictoriaMetrics允许将基础设施成本降低10倍以上 - 请参阅此案例研究。
易于设置和操作:
VictoriaMetrics由一个没有外部依赖关系的小可执行文件组成。
所有配置都是通过具有合理默认值的显式命令行标志完成的。
所有数据存储在命令行标志指向的单个目录中。-storageDataPath
使用vmbackup/vmrestore工具可以轻松快速地从即时快照进行备份。有关更多详细信息,请参阅此文章。
它实现了类似 PromQL 的查询语言 - MetricsQL,它在 PromQL 之上提供了改进的功能。
它提供全局查询视图。多个 Prometheus 实例或任何其他数据源可能会将数据摄取到 VictoriaMetrics 中。稍后可以通过单个查询查询此数据。
它为数据引入和数据查询提供了高性能以及良好的垂直和水平可扩展性。它的性能比InfluxDB和TimescaleDB高出20倍。
在处理数百万个独特的时间序列(又称高基数)时,它使用的 RAM 比 InfluxDB 少 10 倍,比普罗米修斯、灭霸或 Cortex 少 7 倍。
可以说VictoriaMetrics是企业版的普罗米修斯。
!!!!!!如果按照上方采用了Prometheus那么就可以不用VM。vm需要集群版功能才比较齐全。单机版没有报警没啥子意义!!!
1.[root@flshcat-server opt]
2.[root@flshcat-server opt]
3.[root@flshcat-server vm]
4.[root@flshcat-server vm]
5.[root@flshcat-server vm]
victoria-metrics-linux-amd64-v1.90.0.tar.gz victoria-metrics-prod
6.[root@flshcat-server vm]
[Unit]
Description="VictoriaMetrics"
Documentation=https://docs.victoriametrics.com/
After=network.target
[Service]
Type=simple
ExecStart=/opt/vm/victoria-metrics-prod
Restart=on-failure
SuccessExitStatus=0
LimitNOFILE=65536
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=victoria-metrics
[Install]
WantedBy=multi-user.target
EOF
7.[root@flshcat-server vm]
8.[root@flshcat-server vm]
9.[root@flshcat-server vm]
LISTEN 0 128 *:8428 *:* users:(("victoria-metric",pid=21095,fd=10))
1.3.2 VM时序库修改n9e配置
[[Pushgw.Writers]]
Url = "http://127.0.0.1:9090/api/v1/write"
BasicAuthUser = ""
BasicAuthPass = ""
Headers = ["X-From", "n9e"]
Timeout = 10000
DialTimeout = 3000
TLSHandshakeTimeout = 30000
ExpectContinueTimeout = 1000
IdleConnTimeout = 90000
KeepAlive = 30000
MaxConnsPerHost = 0
MaxIdleConns = 100
MaxIdleConnsPerHost = 100
[[Pushgw.Writers]]
Url = "http://127.0.0.1:8428/api/v1/write"
BasicAuthUser = ""
BasicAuthPass = ""
Headers = ["X-From", "n9e"]
Timeout = 10000
DialTimeout = 3000
TLSHandshakeTimeout = 30000
ExpectContinueTimeout = 1000
IdleConnTimeout = 90000
KeepAlive = 30000
MaxConnsPerHost = 0
MaxIdleConns = 100
MaxIdleConnsPerHost = 100
[root@flshcat-server etc]
[root@flshcat-server etc]
1.4 安装ibex告警自愈(server)
1.[root@flshcat-server]
2.[root@flshcat-server ibex]
3.[root@flshcat-server ibex]
[MySQL]
Address = "127.0.0.1:3306"
User = "root"
Password = "123456"
DBName = "ibex"
4.[root@aly n9e]
[Unit]
Description="ibex.service"
After=network.target
[Service]
Type=simple
ExecStart=/opt/ibex/ibex server
WorkingDirectory=/opt/ibex
Restart=on-failure
SuccessExitStatus=0
LimitNOFILE=65536
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=ibex.service
[Install]
WantedBy=multi-user.target
EOF
5.[root@flshcat-server ibex]
6.[root@flshcat-server ibex]
1.5 安装categraf采集器(agent)
[root@aly yeyin]
[root@aly yeyin]
[root@aly yeyin]
[root@aly yeyin]
[root@aly yeyin]
[root@aly yeyin]
1.6 访问夜莺
http://8.130.93.111:17000/metric/explorer
![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-SfYaHtTY-1686996000037)(D:\文档\assets-监控\image-20230414141428802.png)]](https://i-blog.csdnimg.cn/blog_migrate/3679d24aa4d3a697d493c3c4d92efcce.png)
1.7 agent配置
1.
vim /opt/categraf/conf/config.toml
[[writers]]
url = "http://8.130.93.111:17000/prometheus/v1/write"
[heartbeat]
enable = true
url = "http://8.130.93.111:17000/v1/