鉴于近期正好在研究监控方面的工具,因此有了这篇搭建随笔。鉴因而随笔,因此有些地方没有详细解释,后期会慢慢补上,这里仅写了如何搭建。html
1.软件安装规划node
介于我的虚拟机只有2台,linux
故安排:nginx
172.16.16.80redis
安排上 所有的exporter+prometheus+grafana浏览器
172.16.16.74curl
安装单机rediside
和nginx工具
2.软件获取post
连接: https://pan.baidu.com/s/1u1OjTQctdhZU3M-tqnckFQ 提取码: iy8n
里面包含了
prometheus,负责采集exporter指标和提供查询语句
node_exporter,监控主机性能好比内存,cpu等
redis_exporter,监控redis
black_box_exporter,提供icmp;get,post等模块检测页面
grafana --可视化展现
1.主机监控和展现
2.redis监控和展现
3.监控某一个页面,主机地址,Tcp链接和展现
1.tar -xvf prometheus-2.10.0.linux-amd64.tar.gz
2.vi prometheus.yml
3.
这里要.yml文件注意格式问题。否则会报错,因为这是直接copy我本身的配置因此下面这个要注意格式问题
scrape_configs:
- job_name: 'node_exporter'
metrics_path: "/metrics"
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
static_configs:
- targets: ['localhost:9100']
贴图:
4.nohup ./prometheus &
1.tar -xvf node_exporter-0.18.1.linux-amd64.tar.gz
2.nohup ./node_exporter &
3.tail -f nohup.out
4.测试:curl http://172.16.16.80:9100/metrics
有返回就正常OK。或者浏览器带端口9100访问
5.http://172.16.16.80:9090/targets 进去查看exporter状态
这样就配置好了。
1.配置数据源
2.展现:
Dashboard创建一个模板
add query
选择数据源
输入指标:node_load5{instance="localhost:9100"} / on (instance) count(count(node_cpu_seconds_total{instance="localhost:9100"}) by (instance,cpu))by(instance) * 100
3.关于指标的问题只能本身搜索是咋用。并且指标只要访问9100这个端口都能看获得。后期会专门写一下经常使用的指标和grafana的一些用法
4.关于指标的使用我的用相似html标签理解,指标名称+各类属性过滤数据 node_load5{instance="localhost:9100"}