生产环境安装配置Prometheus+Grafana(windows版)
阿里云国内75折 回扣 微信号:monov8 |
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6 |
生产环境安装配置Prometheus+Grafanawindows版
1.介绍
1.1.Prometheus是什么?
Prometheus普罗米修斯是一个最初在SoundCloud上构建的监控系统。自2012年成为社区开源项目拥有非常活跃的开发人员和用户社区。为强调开源及独立维护Prometheus于2016年加入云原生云计算基金会CNCF成为继Kubernetes之后的第二个托管项目。
作为新一代的监控框架Prometheus 具有以下特点
• 多维数据模型由度量名称和键值对标识的时间序列数据
• PromSQL一种灵活的查询语言可以利用多维数据完成复杂的查询
• 不依赖分布式存储单个服务器节点可直接工作
• 基于HTTP的pull方式采集时间序列数据
• 推送时间序列数据通过PushGateway组件支持
• 通过服务发现或静态配置发现目标
• 多种图形模式及仪表盘支持
Prometheus适用于以机器为中心的监控以及高度动态面向服务架构的监控。
1.2.Grafana是什么
Grafana是一个开源的度量分析和可视化系统。
Grafana支持查询普罗米修斯。自Grafana 2.5.02015-10-28以来包含了Prometheus的Grafana数据源。
https://grafana.com/grafana/download
从Grafana.com导入预先构建的仪表板。
Grafana.com维护着一组共享仪表板 可以下载并与Grafana的独立实例一起使用。
https://grafana.com/dashboards/9276
简单来说Grafana提供了比Prometheus更加友好美观的展示界面
2.前期准备
依赖JDK1.8
安装包
组件 | 说明 |
---|---|
prometheus-2.39.1.windows-amd64 | 监控server端用于汇总展示各收集器的资源情况界面丑 |
windows_exporter-0.20.0-386 | windows资源收集器将宿主机的资源情况汇报给server端 |
blackbox_exporter-0.18.0.windows-amd64 | 黑盒收集器可配置tcp监听和http监听 |
grafana-8.1.2.windows-amd64 | 度量分析可视化系统仪表盘多替换prometheus默认展示界面 |
3.部署配置Prometheus
-
在全英文路径下解压prometheus-2.39.1.windows-amd64.zip
-
修改prometheus.yml将localhost改为127.0.0.1避免出现莫名其妙的问题其它涉及到localhost的配置也是改为127.0.0.1
- 双击prometheus.exe启动prometheus任务栏会新增一个黑窗口不要关闭
- 浏览器打开http://127.0.0.1:9090/targetsprometheus状态为up出现如下界面即成功
4.部署配置windows资源采集器
-
用管理员身份运行windows_exporter-0.20.0-386.msi运行成功后服务中可以看到windows_exporter服务
-
将服务状态改为“自动延迟启动”
- 浏览器访问http://127.0.0.1:9182/metrics看到如下界面成功
-
在prometheus端配置windows_exporter采集器地址在prometheus.yml同级目录新建windows.yml
-
windows.yml输入如下内容 注意缩进
- targets: ["127.0.0.1:9182"] labels: instance: 127.0.0.1 serverName: '本地windows服务器'
-
prometheus.yml中添加如下内容 注意缩进
- job_name: "windows" file_sd_configs: - refresh_interval: 15s files: - ".\\windows.yml"
- 重启prometheus端打开http://127.0.0.1:9090/targetswindows状态为up即成功
5.部署配置黑盒采集器
-
在全英文路径下解压blackbox_exporter-0.18.0.windows-amd64.zip双击blackbox_exporter.exe任务栏会新增一个黑窗口不要关闭
-
浏览器访问http://127.0.0.1:9115看到如下界面成功
-
在prometheus端配置blackbox_exporter采集器地址在prometheus.yml同级目录新建tcp.yml
-
tcp.yml输入如下内容 注意缩进
- targets: ['127.0.0.1:3306'] labels: group: 'app' appName: 'mysql' describe: 'mysql数据库'
这里以采集mysql端口存活情况为例我本机已提前启动mysql服务端口3306生产环境配置成具体服务即可其中group取值app为中间件group取值server为微服务具体效果见最后一张图
-
prometheus.yml中添加如下内容 注意缩进
- job_name: "telnet_port" metrics_path: /probe params: module: [tcp_connect] file_sd_configs: - refresh_interval: 15s files: - ".\\tcp.yml" relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: 127.0.0.1:9115
- 重启prometheus端打开http://127.0.0.1:9090/targetstelnet_port状态为up即成功
6.部署配置Grafana
可以看到prometheus的默认界面比较单一可看到的关键资源信息不多下面使用Grafana展示具体资源状况
-
在全英文路径下解压grafana-8.1.2.windows-amd64.zip双击bin目录下grafana-server.exe任务栏会新增一个黑窗户不要关闭
-
浏览器打开http://127.0.0.1:3000默认账号密码都是admin
-
创建数据源关联prometheus端
1、点击设置小齿轮选择Data sources
2、点击Add data source选择Prometheus
3、全部使用默认配置 这里一定要将localhost改为127.0.0.1下拉点击Save & test
-
导入仪表盘
1、打开Dashboards-Manage点击import
2、点击Upload JSON file上传仪表盘json文件一次上传一个选择模板点击import
-
打开Dashboards这里已经添加了[windows资源监控]、[中间件和微服务监控]两个仪表盘选择对应的打开详情如下
完结
如需仪表盘JSON模板请留言
阿里云国内75折 回扣 微信号:monov8 |
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6 |