PrometheusPrometheus是一个开源监控解决方案,用于收集和聚合指标作为时间序列数据 。更简单地说,Prometheus 商店中的每个项目都是一个指标事件,并带有它发生的时间戳 。
mac 搭建Prometheus地址:https://prometheus.io/
Mac 安装
brew install prometheus
默认安装路径:
/usr/local/Cellar/prometheus
默认配置文件:
/usr/local/etc/prometheus.yml
启动prometheus --config.file=/usr/local/etc/prometheus.yml
访问:http://localhost:9090
Spring boot 结合springboot的web项目,pom依赖:
<dependencies><!--web 依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>io.micrometer</groupId><artifactId>micrometer-registry-prometheus</artifactId></dependency></dependencies>
Yml配置文件:
server:port: 8080# 暴露监控端点management:endpoints:web:exposure:include: '*'
监控端点:
http://127.0.0.1:8080/actuator/prometheus
# HELP executor_queued_tasks The Approximate number of tasks that are queued for execution# TYPE executor_queued_tasks gaugeexecutor_queued_tasks{name="applicationTaskExecutor",} 0.0# HELP executor_pool_max_threads The maximum allowed number of threads in the pool# TYPE executor_pool_max_threads gaugeexecutor_pool_max_threads{name="applicationTaskExecutor",} 2.147483647E9# HELP jvm_gc_pause_seconds Time spent in GC pause# TYPE jvm_gc_pause_seconds summaryjvm_gc_pause_seconds_count{action="end of major GC",cause="Metadata GC Threshold",} 1.0jvm_gc_pause_seconds_sum{action="end of major GC",cause="Metadata GC Threshold",} 0.072jvm_gc_pause_seconds_count{action="end of minor GC",cause="Metadata GC Threshold",} 1.0jvm_gc_pause_seconds_sum{action="end of minor GC",cause="Metadata GC Threshold",} 0.014# HELP jvm_gc_pause_seconds_max Time spent in GC pause# TYPE jvm_gc_pause_seconds_max gaugejvm_gc_pause_seconds_max{action="end of major GC",cause="Metadata GC Threshold",} 0.0jvm_gc_pause_seconds_max{action="end of minor GC",cause="Metadata GC Threshold",} 0.0# HELP jvm_classes_loaded_classes The number of classes that are currently loaded in the JAVA virtual machine# TYPE jvm_classes_loaded_classes gaugejvm_classes_loaded_classes 7566.0# HELP jvm_gc_memory_promoted_bytes_total Count of positive increases in the size of the old generation memory pool before GC to after GC# TYPE jvm_gc_memory_promoted_bytes_total counterjvm_gc_memory_promoted_bytes_total 3235200.0# HELP Tomcat_sessions_active_current_sessions# TYPE tomcat_sessions_active_current_sessions gaugetomcat_sessions_active_current_sessions 0.0# HELP executor_pool_size_threads The current number of threads in the pool
文章插图
【监控软件:Prometheus】
配置 prometheus.yml
global:scrape_interval: 15sscrape_configs:- job_name: "prometheus"static_configs:- targets: ["localhost:9090"]# 创建job- job_name: "tomato-study-prometheus"scrape_interval: 5smetrics_path: '/actuator/prometheus'static_configs:- targets: ["localhost:8080"]
重启 prometheus:http://localhost:9090/targets
文章插图
安装 grafana展示各种漂亮的图表 。
Mac 安装
brew install grafana
默认安装路径:/usr/local/Cellar/grafana/
启动:grafana-server --config=/usr/local/etc/grafana/grafana.ini --homepath /usr/local/share/grafana --packaging=brew cfg:default.paths.logs=/usr/local/var/log/grafana cfg:default.paths.data=https://www.isolves.com/usr/local/var/lib/grafana cfg:default.paths.plugins=/usr/local/var/lib/grafana/plugins
注:如需修改默认端口,可修改/usr/local/etc/grafana/grafana.ini
访问:http://localhost:3000/ admin/admin
使用前必须更改密码 admin/123qwe
配置 grafanagrafana只是一个图表展示工具,必须添加数据源,才能读取到数据 。
文章插图
文章插图
配置 Grafana DashBoard文件推荐的 Grafana DashBoard:
JVM (Micrometer)-(https://grafana.com/grafana/dashboards/4701)
推荐阅读
- 微软防病毒软件defender windowsdefender防病毒
- 跟附近人约会的最好的软件 有什么好的交友软件可以约会到附近人
- Linux下网络流量常用那些监控工具
- 迅雷再见!在全球交友网站Github,找到的6款神软件
- linux 调优各项监控指标
- 10种常见的软件架构模式
- 你必须知道的那些好用的MacOS免费软件
- 在 Linux 上使用开源软件创建 SDN
- 利用qq等聊天软件抓取真实地址
- 交管12123违章多久能查出来?