prometheus安装(docker)
参考:https://github.com/songjiayang/prometheus_practice
https://github.com/kjanshair/docker-prometheus
https://github.com/vegasbrianc/prometheus
alertmanager
mkdir /opt/alertmanager -p
vim /opt/alertmanager/Dockerfile
FROM prom/alertmanager:v0.19.0
EXPOSE 9093
vim /opt/alertmanager/docker-compose.yml
version: "3.7"
services:
alertmanager:
image: v-alertmanager
container_name: alertmanager
build:
context: .
dockerfile: Dockerfile
restart: always
ports:
- 9093:9093
volumes:
- /opt/alertmanager/etc/alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml
- /var/lib/alertmanager:/alertmanager
command:
- '--config.file=/etc/alertmanager/alertmanager.yml'
- '--storage.path=/alertmanager'
mkdir -p /var/lib/alertmanager;chmod -R 777 /var/lib/alertmanager
vim /opt/alertmanager/etc/alertmanager/alertmanager.yml
global:
resolve_timeout: 5m route:
group_by: ['alertname']
group_wait: 10s
group_interval: 10s
repeat_interval: 1h
receiver: 'web.hook'
receivers:
- name: 'web.hook'
webhook_configs:
- url: 'http://127.0.0.1:5001/'
inhibit_rules:
- source_match:
severity: 'critical'
target_match:
severity: 'warning'
equal: ['alertname', 'dev', 'instance']
global:
resolve_timeout: 5m
route:
repeat_interval: 2h
receiver: email-1
routes:
- match:
alertname: httpd_down
receiver: email-1 - match:
alertname: nginx_down
receiver: email-2 receivers:
- name: email-1
email_configs:
- to: <to-email>
from: <from-email>
smarthost: <smtp:port>
auth_username: "<user-name>"
auth_identity: "<user-name>"
auth_password: "<user-app-specific-password>" - name: email-2
email_configs:
- to: <to-email>
from: <from-email>
smarthost: <smtp:port>
auth_username: "<user-name>"
auth_identity: "<user-name>"
auth_password: "<user-app-specific-password>"
生成启动
cd /opt/alertmanager
docker-compose build --no-cache
docker-compose up -d --force-recreate
docker-compose down
docker-compose restart
查看进程
netstat -anltp|grep 9093
查看日志
docker logs --tail="500" alertmanager
docker logs -f alertmanager
进入容器
docker exec -it alertmanager /bin/sh
docker cp alertmanager:/etc/alertmanager/alertmanager.yml /opt/alertmanager/alertmanager_bak.yml
node_exporter
数据采集,不向中央服务器发送,而是等待抓取。默认暴露地址http://CURRENT_IP:9100/metrics
mkdir /opt/node-exporter -p
vim /opt/node-exporter/Dockerfile
FROM prom/node-exporter:v0.18.1
EXPOSE 9100
vim /opt/node-exporter/docker-compose.yml
version: '3.7'
services:
node-exporter:
image: v-node-exporter
container_name: node-exporter
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
ports:
- 9100:9100
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- '--path.procfs=/host/proc'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.ignored-mount-points="^/(sys|proc|dev|host|etc)($$|/)"'
注意别与elasticsearch-head的9100端口重叠
生成启动
cd /opt/node-exporter/
docker-compose build
docker-compose up -d --force-recreate
docker-compose down
docker-compose restart
查看进程
netstat -anltp|grep 9100
查看日志
docker logs --tail="500" node-exporter
docker logs -f node-exporter
进入容器
docker exec -it node-exporter /bin/sh
查看帮助
./node_exporter -h
prometheus
mkdir /opt/prometheus -p
vim /opt/prometheus/Dockerfile
FROM prom/prometheus:v2.14.0
EXPOSE 9090
vim /opt/prometheus/docker-compose.yml
version: "3.7"
services:
prometheus:
image: v-prometheus
container_name: prometheus
build:
context: .
dockerfile: Dockerfile
restart: always
ports:
- 9090:9090
volumes:
- ./etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- /var/lib/prometheus:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
mkdir -p /var/lib/prometheus;chmod -R 777 /var/lib/prometheus
chown -R 1000:1000 /opt/prometheus/etc/prometheus
vim /opt/prometheus/etc/prometheus/prometheus.yml
# my global config
global:
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). # alertmanager configuration
altering:
alertmanagers:
- static_configs:
- targets:
- alertmanagerserver1:9093 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files:
# - "1_rules.yml"
# - "2_rules.yml" # A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['prometheusserver1:9090']
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
vim vim /opt/prometheus/etc/prometheus/1_rules.yml
groups: - name: httpd
rules:
- alert: httpd_down
expr: probe_success{instance="http://httpd:80",job="httpd"} == 0
for: 1s
labels:
severity: critical
annotations:
summary: "httpd is down" - name: nginx
rules:
- alert: nginx_down
expr: probe_success{instance="http://nginx:80",job="nginx"} == 0
for: 1s
labels:
severity: warning
annotations:
summary: "nginx is down"
生成启动
cd /opt/prometheus/
docker-compose build
docker-compose up -d --force-recreate
docker-compose down
docker-compose restart
查看进程
netstat -anltp|grep 9090
查看日志
docker logs --tail="500" prometheus
docker logs -f prometheus
进入容器
docker exec -it prometheus /bin/sh
docker cp prometheus:/etc/prometheus/prometheus.yml /opt/prometheus/prometheus_bak.yml
PushGateway
mkdir /opt/pushgateway -p
vim /opt/pushgateway/Dockerfile
FROM prom/pushgateway:v1.0.0
EXPOSE 9091
blackbox-exporter
mkdir /opt/blackbox-exporter -p
vim /opt/blackbox-exporter/Dockerfile
FROM prom/blackbox-exporter:v0.16.0
EXPOSE
vim /opt/blackbox-exporter/docker-compose.yml
version: "3.7"
services:
blackbox-exporter:
image: v-blackbox-exporter
container_name: blackbox
build:
context: .
dockerfile: Dockerfile
restart: unless-stopped
ports:
- "9115:9115"
Grafana
构建Dockerfile
mkdir /opt/grafana
vim /opt/grafana/Dockerfile
FROM grafana/grafana:6.5.1
EXPOSE 3000
vim /opt/grafana/docker-compose.yml
version: '3.7'
services:
grafana:
image: v-grafana
container_name: grafana
build:
context: .
dockerfile: Dockerfile
ports:
- 3000:3000
environment:
- GF_SECURITY_ADMIN_USER=${ADMIN_USER:-admin}
- GF_SECURITY_ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin}
- GF_USERS_ALLOW_SIGN_UP=true
volumes:
- /var/lib/grafana:/var/lib/grafana
- /var/log/grafana:/var/log/grafana
- ./etc/grafana/provisioning:/etc/grafana/provisioning
- /etc/localtime:/etc/localtime:ro
restart: unless-stopped
mkdir -p /var/lib/grafana;chmod -R 777 /var/lib/grafana
mkdir -p /var/log/grafana;chmod -R 777 /var/log/grafana
mkdir -p /opt/grafana/etc/grafana/provisioning/datasources;
mkdir -p /opt/grafana/etc/grafana/provisioning/notifiers;
mkdir -p /opt/grafana/etc/grafana/provisioning/dashboards;
chmod -R 777 /opt/grafana/etc/grafana/provisioning
/var/lib/grafana 为数据库所在目录
生成启动
cd /opt/grafana/
docker-compose build
docker-compose up -d --force-recreate
docker-compose down
docker-compose restart
查看进程
netstat -anltp|grep 3000
查看日志
docker logs --tail="500" grafana
docker logs -f grafana
进入容器
docker exec -it grafana /bin/bash
进入网站 用户名密码都是admin
prometheus集群 Thanos(略)
prometheus安装(docker)的更多相关文章
- centos7下安装docker(17.4docker监控----prometheus)
Prometheus是一个非常优秀的监控工具.准确的说,应该是监控方案.Prometheus提供了监控数据搜集,存储,处理,可视化和告警一套完整的解决方案 Prometheus架构如盗图: 官网上的原 ...
- Grafana连接Prometheus监控Docker平台
Grafana是一款开源的分析平台. Grafana allows you to query, visualize, alert on and understand your metrics no m ...
- Prometheus安装
Prometheus安装 下载地址: https://prometheus.io/download/ 现在时间是: 2019.09.07 安装环境: Linux centos7 minimal 虚拟机 ...
- Prometheus 监控Docker服务器及Granfanna可视化
Prometheus 监控Docker服务器及Granfanna可视化 cAdvisor(Container Advisor)用于收集正在运行的容器资源使用和性能信息. 使用Prometheus监控c ...
- Prometheus 安装部署
Prometheus 安装部署 安装版本:prometheus-2.6.1 百度云下载:https://pan.baidu.com/s/1w16lQZKw8PCHqlRuSK2i7A 提取码:lw1q ...
- centos 7 安装 Docker Engine-CentOS 社区版
获取Docker Engine-CentOS社区: https://docs.docker.com/install/linux/docker-ce/centos/ 1.操作系统要求 1.1 要安装 D ...
- Prometheus监控Docker Swarm集群(一)
Prometheus监控Docker Swarm集群(一) cAdvisor简介 为了解决容器的监控问题,Google开发了一款容器监控工具cAdvisor(Container Advisor),它为 ...
- Prometheus安装教程
Prometheus安装教程 欢迎关注H寻梦人公众号 参考目录 docker安装Prometheus 基于docker 搭建Prometheus+Grafana prometheus官方文档 dock ...
- CentOS7安装docker
1. 查看系统版本 $ cat /etc/redhat-release 2. 安装docker $ yum install docker 3.检查安装是否成功$ docker version 若 ...
随机推荐
- 2019-11-29-win10-uwp-关联文件
原文:2019-11-29-win10-uwp-关联文件 title author date CreateTime categories win10 uwp 关联文件 lindexi 2019-11- ...
- svg图片拖动与缩放
引入jquery.js文件,svg-pan-zoom.min.js文件 和 hammer.min.js 文件 这三个文件可以在网上搜一下下载 //svg拖动和缩放 initPanZoom() { th ...
- windows 2012 IIS 部署 .net core HTTP Error 502.5 - Process Failure 错误解决办法
安装系统补丁: 2012 R2对应>Windows8.1-KB2999226-x64.msu 下载地址: https://www.microsoft.com/zh-CN/download/det ...
- 初学者学习golang可能遇到的坑
我也是个golang初学者,刚入门的话,有些"坑"还是不好发现的.如map只是定义了然后就拿来使用,变量的值覆盖等. 本来打算写一篇的,后面发现有人写的挺不错的,我就把里面的有些坑 ...
- Git remote: ERROR: missing Change-Id in commit message
D:\code\项目仓库目录>git push origin HEAD:refs/for/dev/wangteng/XXXXX key_load_public: invalid format E ...
- echarts 更改tooltip提示框CSS样式
最近 做项目,用过echarts,发现tooltip提示z-index级别很高,想更改下,看了下文档:https://www.echartsjs.com/zh/option.html#tooltip. ...
- android studio学习---Android studio 导入github工程
无论是那种方式,都最好是先把github上的工程项目下载到本地,然后修改文件再import 首先要知道 自己的build.gradle,在project下面的版本号是多少,比如我的: depende ...
- 结对项目(JAVA)
项目成员: 邓镇港 3117004608 陈嘉欣 3117004604 一.Github项目地址: https://github.com/kestrelcjx/operation_expression ...
- CentOS7升级内核kernel5.0
升级过程: 原系统:CentOS7.3 [root@my-e450 ~]# uname -r3.10.0-514.el7.x86_64 安装必需的软件包: # yum update# yum inst ...
- MySQL修炼之路四
1. 外键(foreign key) 1. 定义:让当前表字段的值在另一个表的范围内选择 2. 语法 foreign key(参考字段名) references 主表(被参考字段名) on delet ...