AspNet Core 下利用普罗米修斯+Grafana构建Metrics和服务器性能的监控 (2)

sudo vim /etc/prometheus/prometheus.yml
注意YML配置文件的缩进

global: scrape_interval: 15s evaluation_interval: 15s scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] - job_name: 'node_exporter' scrape_interval: 5s static_configs: - targets: ['localhost:9100'] 配置所有者

sudo chown prometheus:prometheus /etc/prometheus/prometheus.yml

启动prometheus

sudo -u prometheus /usr/local/bin/prometheus --config.file /etc/prometheus/prometheus.yml --storage.tsdb.path /var/lib/prometheus/ --web.console.templates=http://www.likecs.com/etc/prometheus/consoles --web.console.libraries=http://www.likecs.com/etc/prometheus/console_libraries

检测

服务器ip:9090

AspNet Core 下利用普罗米修斯+Grafana构建Metrics和服务器性能的监控

配置自启动

sudo vim /etc/systemd/system/prometheus.service

[Unit] Description=Prometheus Monitoring Wants=network-online.target After=network-online.target [Service] User=prometheus Group=prometheus Type=simple ExecStart=http://www.likecs.com/usr/local/bin/prometheus \ --config.file /etc/prometheus/prometheus.yml \ --storage.tsdb.path /var/lib/prometheus/ \ --web.console.templates=http://www.likecs.com/etc/prometheus/consoles \ --web.console.libraries=http://www.likecs.com/etc/prometheus/console_libraries ExecReload=http://www.likecs.com/bin/kill -HUP $MAINPID [Install] WantedBy=multi-user.target

sudo systemctl daemon-reload
sudo systemctl enable prometheus
sudo systemctl start prometheus
sudo systemctl status prometheus

配置安装Grafna

cd /tmp
wget https://dl.grafana.com/oss/release/grafana-6.0.1-1.x86_64.rpm
sudo yum localinstall grafana-6.0.1-1.x86_64.rpm

配置自启动

sudo systemctl daemon-reload && sudo systemctl enable grafana-server && sudo systemctl start grafana-server

登录

启动grafana后可以通过 :3000登录

AspNet Core 下利用普罗米修斯+Grafana构建Metrics和服务器性能的监控

初始用户名和密码都是 admin
初次登录后会要求修改密码

配置数据源到之前的Prometheus

AspNet Core 下利用普罗米修斯+Grafana构建Metrics和服务器性能的监控

选择Prometheus数据源

AspNet Core 下利用普罗米修斯+Grafana构建Metrics和服务器性能的监控

AspNet Core 下利用普罗米修斯+Grafana构建Metrics和服务器性能的监控

配置仪表盘

安装饼图插件

grafana-cli plugins install grafana-piechart-panel

导入仪表样本

样本来源,打开浏览器打开如下地址并记录id

https://grafana.com/dashboards/8919

AspNet Core 下利用普罗米修斯+Grafana构建Metrics和服务器性能的监控

AspNet Core 下利用普罗米修斯+Grafana构建Metrics和服务器性能的监控

选择Import

AspNet Core 下利用普罗米修斯+Grafana构建Metrics和服务器性能的监控

然后输入之前记录的id

AspNet Core 下利用普罗米修斯+Grafana构建Metrics和服务器性能的监控

选择prometheus的数据源,之后打开dashboard就可以看到漂亮的仪表盘了

AspNet Core 下利用普罗米修斯+Grafana构建Metrics和服务器性能的监控

AspNet Core App Metrics的监控配置 nuget安装包

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zyjspp.html