备忘录二:Spring Boot Actuator+Prometheus+Grafana
短信预约 -IT技能 免费直播动态提醒
一:Spring Boot Actuator
Spring-boot-actuator 可在将应用程序投入生产时监视和管理应用程序。可以选择使用 HTTP 端点或 JMX 来管理和监控应用程序
Spring boot 应用中引入Spring-boot-actuator
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>
3.application.yml文件配置
# managementmanagement: endpoints: web: exposure: include: "*" endpoint: health: show-details: ALWAYS
Spring Boot Actuator内置Endpoints
二:Prometheus
将Micrometer Prometheus 注册添加到Spring Boot应用。
<dependency><groupId>io.micrometer</groupId><artifactId>micrometer-registry-prometheus</artifactId></dependency>
2.Docker 拉取Prometheus镜像
docker pull prom/prometheus
3.Prometheus 配置文件
# my global configglobal: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. # scrape_timeout is set to the global default (10s).# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.rule_files: # - "first_rules.yml" # - "second_rules.yml"# A scrape configuration containing exactly one endpoint to scrape:# Here it's Prometheus itself.scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: 'prometheus' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['127.0.0.1:9090'] - job_name: 'spring-actuator' metrics_path: '/mybatis/actuator/prometheus' scrape_interval: 5s static_configs: - targets: ['112.74.105.178:8888']
运行Prometheus容器
docker run -d --name=prometheus -p 9090:9090 -v /mnt/demo/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml
查看Prometheus运行情况
三:Grafana
Docker 运行Grafana镜像
docker run -d --name=grafana -p 3000:3000 grafana/grafana
2.Grafana 配置Prometheus数据源
监控dashboard
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341