zoukankan      html  css  js  c++  java
  • 51cto 先超Prometheus+Grafana监控告警系统实战

    cadvisor监控:

    curl -k https://10.10.10.95:10250/metrics -H "Authorization: Bearer token-qz4w7:b5s2kwwsh8v47xq8gl7b97zrjgjkb7srr78n2wxrmmvlvc8gqgd7fr" 

    cadvisor中获取到的典型监控指标如下:

    指标名称                                                  类型              含义

    container_cpu_load_average_10s           gauge           过去10秒容器CPU的平均负载

    container_cpu_usage_seconds_total       counter         容器在每个CPU内核上的累积占用时间 (单位:秒)

    container_cpu_system_seconds_total      counter         System CPU累积占用时间(单位:秒)

    container_cpu_user_seconds_total          counter          User CPU累积占用时间(单位:秒)

    container_fs_usage_bytes                         gauge           容器中文件系统的使用量(单位:字节)

    container_fs_limit_bytes                           gauge           容器可以使用的文件系统总量(单位:字节)

    container_fs_reads_bytes_total                 counter         容器累积读取数据的总量(单位:字节)

    container_fs_writes_bytes_total                counter         容器累积写入数据的总量(单位:字节)

    container_memory_max_usage_bytes      gauge           容器的最大内存使用量(单位:字节)

    container_memory_usage_bytes               gauge           容器当前的内存使用量(单位:字节

    container_spec_memory_limit_bytes        gauge            容器的内存使用量限制

    machine_memory_bytes                              gauge            当前主机的内存总量

    container_network_receive_bytes_total     counter           容器网络累积接收数据总量(单位:字节)

    container_network_transmit_bytes_total   counter           容器网络累积传输数据总量(单位:字节)

    4.当能够正常采集到cAdvisor的样本数据后,可以通过以下表达式计算容器的CPU使用率:

    (1)sum(irate(container_cpu_usage_seconds_total{image!=""}[1m])) without (cpu)

    容器CPU使用率

    (2)container_memory_usage_bytes{image!=""}

    查询容器内存使用量(单位:字节):

    (3)sum(rate(container_network_receive_bytes_total{image!=""}[1m])) without (interface)

    查询容器网络接收量(速率)(单位:字节/秒):

    (4)sum(rate(container_network_transmit_bytes_total{image!=""}[1m])) without (interface)

    容器网络传输量 字节/秒

    (5)sum(rate(container_fs_reads_bytes_total{image!=""}[1m])) without (device)

    容器文件系统读取速率 字节/秒

    (6)sum(rate(container_fs_writes_bytes_total{image!=""}[1m])) without (device)

    容器文件系统写入速率 字节/秒

    5.cadvisor 常用容器监控指标

    (1)网络流量

    sum(rate(container_network_receive_bytes_total{name=~".+"}[1m])) by (name)

     ##容器网络接收的字节数(1分钟内),根据名称查询 name=~".+"

    sum(rate(container_network_transmit_bytes_total{name=~".+"}[1m])) by (name)

     ##容器网络传输的字节数(1分钟内),根据名称查询 name=~".+"

    (2)容器 CPU相关

    sum(rate(container_cpu_system_seconds_total[1m]))

    ###所用容器system cpu的累计使用时间(1min钟内)

    sum(irate(container_cpu_system_seconds_total{image!=""}[1m])) without (cpu)

     ###每个容器system cpu的使用时间(1min钟内)

    sum(rate(container_cpu_usage_seconds_total{name=~".+"}[1m])) by (name) * 100

    #每个容器的cpu使用率

    sum(sum(rate(container_cpu_usage_seconds_total{name=~".+"}[1m])) by (name) * 100)

    #总容器的cpu使用率

    relabel的保留:

    - job_name: 'kubernetes-service-endpoints'

          kubernetes_sd_configs:

          - role: endpoints

          relabel_configs:

          - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape]

            action: keep

            regex: true

          - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scheme]

            action: replace

            target_label: __scheme__

            regex: (https?)

          - source_labels: [__meta_kubernetes_service_annotation_prometheus_io_path]

            action: replace

            target_label: __metrics_path__

            regex: (.+)

          - source_labels: [__address__, __meta_kubernetes_service_annotation_prometheus_io_port]

            action: replace

            target_label: __address__

            regex: ([^:]+)(?::d+)?;(d+)

            replacement: $1:$2

          - action: labelmap

            regex: __meta_kubernetes_service_label_(.+)

          - source_labels: [__meta_kubernetes_namespace]

            action: replace

            target_label: kubernetes_namespace

          - source_labels: [__meta_kubernetes_service_name]

            action: replace

            target_label: kubernetes_name

    如果在service的annotation里发现prometheus.io/scrape为true,就抓取。   ( [__meta_kubernetes_service_annotation_prometheus_io_scrape] )

  • 相关阅读:
    iOS学习之MVC,MVVM,MVP模式优缺点
    iOS学习之单例模式
    iOS学习之观察者模式
    iOS学习之设计模式
    iOS学习之SKTagView的使用
    iOS学习之cocoaPods
    iOS学习之git的使用
    iOS学习之block
    [学习笔记]一个实例理解Lingo的灵敏性分析
    爬虫实例(二)——爬取某宝评论
  • 原文地址:https://www.cnblogs.com/alexhjl/p/14121521.html
Copyright © 2011-2022 走看看