Prometheus+Grafana部署监控docker服务

1.环境
192.168.244.128 Prometheus 监控服务器
192.168.244.129 docker 服务(被监控端)
注:都是centos7.5系统

2.下载安装包
https://prometheus.io/download/ (需要的安装包都可以下载)
wget https://github.com/prometheus/prometheus/releases/download/v2.3.2/prometheus-2.3.2.linux-amd64.tar.gz

服务端(监控server)
3.安装prometheus
部署到/usr/local/目录
promethus不用编译安装,解压目录中有配置文件与启动文件
tar -zxvf prometheus-2.3.2.linux-amd64.tar.gz -C /usr/local/
cd /usr/local/ && mv prometheus-2.3.2.linux-amd64/ prometheus
验证
[[email protected] local]# cd prometheus/
[[email protected] prometheus]# ./prometheus --version
prometheus, version 2.3.2 (branch: HEAD, revision: 71af5e29e815795e9dd14742ee7725682fa14b7b)
build user: [email protected]
build date: 20180712-14:02:52
go version: go1.10.3

备份配置文件并配置
cp prometheus.yml prometheus.yml-bak

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

alerting:
alertmanagers:

  • static_configs:

    • targets:

      - alertmanager:9093

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: [‘192.168.244.128:9090‘,‘192.168.244.129:8080‘]

添加需要监控的服务器IP和端口

启动(后台启动)
./prometheus --config.file=prometheus.yml &
然后我们可以访问 http://<服务器IP地址>:9090,验证Prometheus是否已安装成功,web显示应该如下

通过点击下拉栏选取指标,点击”Excute” 我们能够看到Prometheus的性能指标。
点击”status”可以查看相关状态。

4.node_exporter安装
wget https://github.com/prometheus/node_exporter/releases/download/v0.16.0/node_exporter-0.16.0.linux-amd64.tar.gz
解压并安装
tar xf node_exporter-0.16.0.linux-amd64.tar.gz C /usr/local/
cd /usr/local/ && mv mv node_exporter-0.16.0 node_exporter
cd node_exporter/ && ./node_exporter &

返回一大堆指标

5.grafana安装
wget https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.2.3-1.x86_64.rpm
sudo yum localinstall grafana-5.2.3-1.x86_64.rpm
服务端图像呈现组件安装
yum install fontconfig freetype* urw-fonts -y
开启系统默认启动
systemctl enable grafana-server
启动服务
systemctl start grafana-server
查看服务是否正常启动
systemctl status grafana-server
[[email protected] ~]# systemctl status grafana-server
● grafana-server.service - Grafana instance
Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; enabled; vendor preset: disabled)
Active: active (running) since 四 2018-08-30 16:18:55 CST; 3h 23min ago
Docs: http://docs.grafana.org
Main PID: 10535 (grafana-server)
CGroup: /system.slice/grafana-server.service
└─10535 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/grafana-server.pid ...
访问grafana, http://<服务器IP>:3000
默认用户名密码:admin/admin

客户端(被监控)
6.安装cAdvisor 来收集容器信息 所有节点运行以下命令来安装cAdvisor
docker run \
--volume=/:/rootfs:ro \
--volume=/var/run:/var/run:rw \
--volume=/sys:/sys:ro \
--volume=/var/lib/docker/:/var/lib/docker:ro \
--publish=8080:8080 \
--detach=true \
--name=cadvisor \
--net=host \
-v "/etc/localtime:/etc/localtime" \
google/cadvisor:latest

为grafana添加Prometheus数据源

导入监控模板
https://grafana.com/dashboards?search=docker 多种docker 监控模板


添加钉钉报警

测试

原文地址:http://blog.51cto.com/10158955/2167075

时间: 2024-07-31 18:59:25

Prometheus+Grafana部署监控docker服务的相关文章

k8s+Prometheus+Grafana的监控部署

一.安装部署k8s集群 可以参考https://www.cnblogs.com/liugp/p/12115945.html 二.Prometheus+Grafana的监控部署 2.1.master/node节点环境部署 在[master]可以进行安装部署安装git,并下载相关yaml文件 https://gitee.com/liugpwwwroot/k8s-prometheus-grafana.git 在[node]节点下载监控所需镜像(非必须) docker pull prom/node-ex

Prometheus + Grafana 部署说明之安装

说明 在前面的Prometheus学习系列文章里,大致介绍说明了Prometheus和Grafana的一些使用,现在开始介绍如何从头开始部署Prometheus+Grafana,来监控各个相关的指标数据来进行展示. 部署 Prometheus基于Golang编写(需要安装),编译后的软件包,不依赖于任何的第三方依赖.用户只需要下载对应平台的二进制包,解压并且添加基本的配置即可正常启动Prometheus Server. 环境: 系统: centos-release-7-4.1708.el7.ce

istio+prometheus+grafana 流量监控

从零到一配置 OpenAP: 概要        Istio采集指标prometheus+grafana方案,搭建(promethues+prometheus-postgresql-adapter+pg_prometheus) promethues·监控存储平台, 通过Istio+grafana 进行istio流量注入grafana图表展示,实现对API流量的统计. 配置 Prometheus 并且把数据存储至  Postgres (Prometheus + Postgres[Timescale

Prometheus监控docker服务

操作步骤: sudo docker run --restart=always --volume=/:/rootfs:ro --volume=/var/run:/var/run:ro --volume=/sys:/sys:ro --volume=/var/lib/docker/:/var/lib/docker:ro --volume=/dev/disk/:/dev/disk:ro --publish=8080:8080 --detach=true --name=cadvisor google/ca

springboot2+exporter+prometheus+grafana搭建监控体系

项目中需要监控系统指标(JVM,CPU,IO,MySQL等),这时候可以使用Prometheus来做.如果是需要监控日志系统,可以使用ELK stack.监控=日志(ELK)+指标(Prometheus). step1 编写springboot2程序 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</art

基于prometheus+grafana 搭建监控mysql redis mongodb等

先把题目定好,具体待这几天整理我的笔记补充进来. 官方网站 https://prometheus.io/ 参考文档: http://www.cnblogs.com/sfnz/p/6566951.html http://www.jb51.net/article/107386.htm https://www.iamle.com/archives/2130.html

Prometheus+Grafana监控部署实践

参考文档: Prometheus github:https://github.com/prometheus grafana github:https://github.com/grafana/grafana Prometheus getting_started:https://prometheus.io/docs/prometheus/latest/getting_started/ Prometheus node_exporter:https://github.com/prometheus/no

Prometheus+Node_exporter+Grafana+Alertmanager 监控部署

一.Prometheus 安装及配置 1.下载及解压安装包 cd /usr/local/src/ export VER="2.13.1" wget https://github.com/prometheus/prometheus/releases/download/v${VER}/prometheus-${VER}.linux-amd64.tar.gz mkdir -p /data0/prometheus groupadd prometheus useradd -g prometheu

cAdvisor+Prometheus+Grafana监控docker

cAdvisor+Prometheus+Grafana监控docker 一.cAdvisor(需要监控的主机都要安装) 官方地址:https://github.com/google/cadvisor CAdvisor是谷歌开发的用于分析运行中容器的资源占用和性能指标的开源工具.CAdvisor是一个运行时的守护进程,负责收集.聚合.处理和输出运行中容器的信息.注意在查找相关资料后发现这是最新版cAdvisor的bug,换成版本为google/cadvisor:v0.24.1 就ok了,映射主机端