Docker-CE 监控

Docker Action 记录 作者: LinkSystem 2017/08/12

Docker Action 是我关于Docker-CE的实践记录,该实践的构建环境以下:

[root@core ~]# cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core) 

[root@core ~]# docker version
Client:
 Version:      17.07.0-ce-rc2
 API version:  1.31
 Go version:   go1.8.3
 Git commit:   36ce605
 Built:        Mon Aug  7 23:43:46 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.07.0-ce-rc2
 API version:  1.31 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   36ce605
 Built:        Mon Aug  7 23:45:07 2017
 OS/Arch:      linux/amd64
 Experimental: false

Prometheus 简介

Prometheus是一个开源系统的监控和报警工具。你可以把Docker作为一个Prometheus的目标。这个主题向您展示了如何配置Docker,将Prometheus设置为Docker容器,并使用普罗米修斯监控您的Docker实例。

Docker-CE 配置

# 由于我的Docker-CE的宿主机是虚拟机,我本地访问存在问题故以下配置
# 若非与我的情况相同可配置为"metrics-addr" : "127.0.0.1:9323"
[root@core ~]# vi /etc/docker/daemon.json
{
  "metrics-addr" : "192.168.100.10:9323",
  "experimental" : true
}

[root@core ~]# sudo systemctl restart docker

Prometheus 配置

[root@core ~]# vi /tmp/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).

  # Attach these labels to any time series or alerts when communicating with
  # external systems (federation, remote storage, Alertmanager).
  external_labels:
      monitor: 'codelab-monitor'

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first.rules"
  # - "second.rules"

# 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.100.10:9090']

  - job_name: 'docker'
         # metrics_path defaults to '/metrics'
         # scheme defaults to 'http'.

    static_configs:
      - targets: ['192.168.100.10:9323']

Prometheus 运行

[root@core ~]# docker service create --replicas 1 --name my-prometheus \
>     --mount type=bind,source=/tmp/prometheus.yml,destination=/etc/prometheus/prometheus.yml \
>     --publish 9090:9090/tcp \
>     prom/prometheus

Prometheus 使用

创建图表。点击Prometheus UI中的图表链接。从执行按钮右侧的组合框中选择一个指标,然后单击 执行。下面的截图显示了图形 engine_daemon_network_actions_seconds_count。
prometheus-graph_idle.png

Prometheus 测试

[root@core ~]# [root@core ~]# docker service create \
> >   --replicas 10 \
> >   --name ping_service \
> >   alpine ping baidu.com

稍后,结果如图所示
prometheus-graph_load.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值