前言
借助docker来安装,新建目录docker-monitor,在里面创建文件docker-compose.yml
一、docker-compose.yml
version: "3" services: prometheus: image: prom/prometheus:v2.4.3 container_name: 'prometheus' volumes: - ./prometheus/:/etc/prometheus/ #映射prometheus的配置文件 - /etc/localtime:/etc/localtime:ro #同步容器与宿主机的时间,这个非常重要,如果时间不一致,会导致prometheus抓不到数据 ports: - '9090:9090'
二、prometheus.yml
在docker-monitor目录下新增prometheus目录,在里面创建prometheus配置文件prometheus.yml
global: #全局配置 scrape_interval: 15s #全局定时任务抓取性能数据间隔 scrape_configs: #抓取性能数据任务配置 - job_name: 'tulingmall-order' #抓取订单服务性能指标数据任务,一个job下可以配置多个抓紧的targets,比如订单服务多个实例机器 scrape_interval: 10s #每10s抓取一次 metrics_path: '/actuator/prometheus' #抓取的数据url static_configs: - targets: ['192.168.31.60:8844'] #抓取的服务器地址 labels: application: 'tulingmall-order-label' #抓取任务标签 - job_name: 'prometheus' #抓取prometheus自身性能指标数据任务 scrape_interval: 5s static_configs: - targets: ['localhost:9090']
三、启动
在docker-monitor目录下执行如下命令启动prometheus
在浏览器访问prometheus:http://106.14.132.94:9090/graph
总结
提示:以上就是今天要讲的内容,本文仅仅简单介绍了Prometheus安装与配置