代码拉取完成,页面将自动刷新
Introduction:收纳日志监控分析告警相关的知识总结!
[TOC]
# 下载
wget https://github.com/prometheus/prometheus/releases/download/v2.35.0-rc1/prometheus-2.35.0-rc1.linux-amd64.tar.gz
# 解压
tar -zxvf prometheus-2.35.0-rc1.linux-amd64.tar.gz
mv prometheus-2.35.0-rc1.linux-amd64 prometheus
# 启动
./prometheus --config.file=./prometheus.yml --web.enable-lifecycle
# --config.file=./prometheus.yml 指定配置
# --web.enable-lifecycle这个参数的主要目的是为了运行时重载配置
# 测试地址:http://localhost:9090/targets
# 启动prometheus
docker run -d --name=prometheus -p 9090:9090 \
-v /home/soft/monitor/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \
-v /etc/localtime:/etc/localtime:ro \
prom/prometheus
node_exporter用于采集服务器层面的运行指标,包括机器的loadavg、filesystem、meminfo等基础监控,类似于传统主机监控维度的zabbix-agent。node_exporter由prometheus官方提供、维护,不会捆绑安装,但基本上是必备的exporter。建议最好安装在linux上使用。
# 下载地址https://github.com/prometheus/node_exporter/releases
wget https://github.91chi.fun//https://github.com//prometheus/node_exporter/releases/download/v1.3.1/node_exporter-1.3.1.linux-386.tar.gz
# 解压
tar -zxvf node_exporter-1.3.1.linux-386.tar.gz
# 启动node_exporter
nohup ./node_exporter --web.listen-address 172.16.1.167:8081 &
# 访问地址:http://172.16.1.167:8081/metrics
- job_name: 'node_local'
static_configs:
- targets: ['localhost:9100']
https://grafana.com/grafana/dashboards/1860
https://grafana.com/grafana/dashboards/9276
# 下载地址:https://github.com/prometheus/mysqld_exporter/releases
wget https://github.91chi.fun//https://github.com//prometheus/mysqld_exporter/releases/download/v0.14.0/mysqld_exporter-0.14.0.linux-386.tar.gz
export DATA_SOURCE_NAME='root:123456@(127.0.0.1:3306)/'
https://grafana.com/grafana/dashboards/7362
# 启动grafana
docker run -d -p 3000:3000 --name=grafana \
-v /home/soft/monitor/grafana/Grafana-storage:/var/lib/Grafana \
-v /etc/localtime:/etc/localtime:ro \
grafana/grafana
使用方式
Docker部署cAdvisor,用于监控docker的容器的运行指标。
# 启动cAdvisor
docker run -d \
–volume=/:/rootfs:ro \
–volume=/var/run:/var/run:ro \
–volume=/sys:/sys:ro \
–volume=/var/lib/docker/:/var/lib/docker:ro \
–volume=/dev/disk/:/dev/disk:ro \
-v /etc/localtime:/etc/localtime:ro \
–publish=8080:8080 \
–detach=true \
–name=cadvisor \
google/cadvisor:latest
访问方法:192.168.200.137:8080 可以看到cAdvisor是否启动 访问:http://192.168.200.137:8080/metrics有数据就说明cAdvisor是启动好了的
- job_name: 'docker'
static_configs:
- targets: ['192.168.200.137:8080']
labels:
instance: docker
https://grafana.com/grafana/dashboards/193
监控springboot。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!--prometheus监控 https://prometheus.io/docs/introduction/overview/-->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
scrape_configs:
- job_name: 'demo-server-monitor'
metrics_path: '/actuator/prometheus'
scrape_interval: 2s
static_configs:
- targets: ['localhost:8080']
https://grafana.com/grafana/dashboards/12900
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。