docker 版本prometheus
缘由
之前是jar 安装到服务器,但是服务器重启后,没有自启动,而且很多都是docker维护,有平台方便重启,
最后还是决定docker 安装prometheus
安装
docker run -itd --name=prometheus --restart=always -p 9090:9090 prom/prometheus
容器创建成功后,即可通过浏览器访问 http: / /{ip}:9090 来进行验证
配置
复制docker内配置文件出来
docker cp prometheus:/etc/prometheus/prometheus.yml $PWD
[root@Docker ~]# vim prometheus.yml 在Prometheus配置文件按以下内容修改: 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: ['localhost:9090'] labels: instance: prometheus - job_name: linux static_configs: - targets: ['192.168.1.1:9100'] #被监控端的IP地址和端口号(有多个被监控端可用 逗号 隔开) labels: instance: localhost
修改后 复制回去
docker cp $PWD/prometheus.yml prometheus:/etc/prometheus/prometheus.yml
最后重启prometheus