参考: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)的更多相关文章

  1. centos7下安装docker(17.4docker监控----prometheus)

    Prometheus是一个非常优秀的监控工具.准确的说,应该是监控方案.Prometheus提供了监控数据搜集,存储,处理,可视化和告警一套完整的解决方案 Prometheus架构如盗图: 官网上的原 ...

  2. Grafana连接Prometheus监控Docker平台

    Grafana是一款开源的分析平台. Grafana allows you to query, visualize, alert on and understand your metrics no m ...

  3. Prometheus安装

    Prometheus安装 下载地址: https://prometheus.io/download/ 现在时间是: 2019.09.07 安装环境: Linux centos7 minimal 虚拟机 ...

  4. Prometheus 监控Docker服务器及Granfanna可视化

    Prometheus 监控Docker服务器及Granfanna可视化 cAdvisor(Container Advisor)用于收集正在运行的容器资源使用和性能信息. 使用Prometheus监控c ...

  5. Prometheus 安装部署

    Prometheus 安装部署 安装版本:prometheus-2.6.1 百度云下载:https://pan.baidu.com/s/1w16lQZKw8PCHqlRuSK2i7A 提取码:lw1q ...

  6. centos 7 安装 Docker Engine-CentOS 社区版

    获取Docker Engine-CentOS社区: https://docs.docker.com/install/linux/docker-ce/centos/ 1.操作系统要求 1.1 要安装 D ...

  7. Prometheus监控Docker Swarm集群(一)

    Prometheus监控Docker Swarm集群(一) cAdvisor简介 为了解决容器的监控问题,Google开发了一款容器监控工具cAdvisor(Container Advisor),它为 ...

  8. Prometheus安装教程

    Prometheus安装教程 欢迎关注H寻梦人公众号 参考目录 docker安装Prometheus 基于docker 搭建Prometheus+Grafana prometheus官方文档 dock ...

  9. CentOS7安装docker

    1. 查看系统版本 $ cat /etc/redhat-release   2. 安装docker $  yum install docker 3.检查安装是否成功$ docker version 若 ...

随机推荐

  1. Blend Brush介绍

    原文:Blend Brush介绍 这篇文章会介绍 Blend怎么设置Brush 全局画刷 1)blend面板的介绍 这5个rectangle分别对应 blend中的 5个设置 1 设置无颜色 2 设置 ...

  2. 分享windows 10 下部署 elasticsearch 和 logstash

    最近和es杠上了.以前只听说过es一直没有机会体验一下. 最近有点时间,就着手体验一把.因为是第一次接触es,没有任何基础.入门的第一件是就是用 百度了, [不过建议改名为白度,基本上查不到想要的,一 ...

  3. 2019-08-26 linux

    1.question:什么是linux? answer:Linux由林纳斯·托瓦兹开发的一套免费使用和自由传播的类Unix操作系统,是一个基于POSIX和Unix的多用户.多任务.支持多线程和多CPU ...

  4. 【开发笔记】- grails框架中在使用domain的save方法保存时保存不成功

    1.如果报错,自行根据异常查找错误,这里不说明 2.如果为报错,我遇到的就是domain中的字段属性与数据库中为同步 (1)你的domain是新的,在增加新的字段属性时未使用update更新数据库,造 ...

  5. HTML 从入门到精通 [目录]

    目录 一.服务器的认识 二.浏览器的认识 三.Web 标准 四.HTML 的认识 五.HTML 文本标签 六.HTML 图像标签 七.HTML 路径 八.HTML 链接标签 九.HTML 列表 十.H ...

  6. [转]QT中的D指针与Q指针

    Qt为了使其动态库最大程度上实现二进制兼容,引入了d指针的概念. 那么为什么d指针能实现二进制兼容呢? 为了回答这个问题,首先弄清楚什么是二进制兼容? 所谓二进制兼容动态库,指的是一个在老版本库下运行 ...

  7. 12个有趣的C语言问答

    转自:http://www.admin10000.com/document/913.html 1,gets() 方法 Q:以下代码有个被隐藏住的问题,你能找到它吗? 1 2 3 4 5 6 7 8 9 ...

  8. vmware关闭嘟嘟嘟嘟警告

    在使用VMware workstation时,安装的windows或者Linux遇到错误操作时,会发生刺耳的嘟嘟声.如何关闭呢?在VMware虚拟机windows系统中的命令提示符处键入以下命令, 然 ...

  9. SQL Server 修改表结构(转载)

    SQL Server 修改表结构 本文链接:https://blog.csdn.net/petezh/article/details/81744374 查看指定表结构 exec sp_help Rep ...

  10. vmware虚拟机安装T6客户端

    1.虚拟机安装T6 经过测试,vmware 里系统装T6  网络适配器必须使用桥接,nat模式是无法连接数据库的