<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Prometheus Operator中探針的使用

          共 5645字,需瀏覽 12分鐘

           ·

          2023-07-12 21:14

          最近小白需要對服務(wù)器和線上業(yè)務(wù)進(jìn)行一些探針來定時撥測,用于對服務(wù)的存活性進(jìn)行監(jiān)控與告警。很早以前就知道prometheus社區(qū)提供了 blackbox 的探針方案,但一直沒有關(guān)注,正好趁這次機會了解一下。

          Blackbox Exporter 是 Prometheus 社區(qū)提供的官方黑盒監(jiān)控解決方案,其允許用戶通過:HTTP, HTTPS, DNS, TCP, ICMP 和 gRPC.的方式對網(wǎng)絡(luò)進(jìn)行探測。目前 proemtheus operator 中的 probe 資源已實現(xiàn)對 blackbox-exporter 的支持,本文的介紹的所有探針也均在 probe中實現(xiàn)。

          環(huán)境準(zhǔn)備

          在使用之前,須確保你的 k8s集群內(nèi)已經(jīng)部署了 prometheus operator和prometheus-blackbox-exporter,如果沒有安裝,可使用 helm命令直接部署。

                
                #?添加?promethues?社區(qū)?helm?源?并更新
          helm?repo?add?prometheus-community?https://prometheus-community.github.io/helm-charts
          helm?repo?update?prometheus-community

          #?安裝?prometheus
          helm?install?prometheus-community/prometheus-operator

          #?安裝?blackbox-exporter
          helm?install?prometheus-community/prometheus-blackbox-exporter

          安裝成功后,需手動配置 black-exporter的 configmpa,引入探針模塊。

          提示:可以在prometheus-blackbox-exporter的 helm values 中配置。文章為了直觀,所以直接修改 configmap

                
                ??blackbox.yaml:?|
          ????modules:
          ??????dns:
          ????????dns:
          ??????????preferred_ip_protocol:?ip4
          ??????????query_name:?kubernetes.default.svc.cluster.local
          ??????????transport_protocol:?tcp
          ????????prober:?dns
          ??????grpc:
          ????????grpc:
          ??????????preferred_ip_protocol:?ip4
          ??????????tls:?true
          ????????prober:?grpc
          ??????grpc_plain:
          ????????grpc:
          ??????????service:?service1
          ??????????tls:?false
          ????????prober:?grpc
          ??????http_2xx:
          ????????http:
          ??????????follow_redirects:?true
          ??????????preferred_ip_protocol:?ip4
          ??????????valid_http_versions:
          ??????????-?HTTP/1.1
          ??????????-?HTTP/2.0
          ????????prober:?http
          ????????timeout:?5s
          ??????http_post_2xx:
          ????????http:
          ??????????method:?POST
          ??????????preferred_ip_protocol:?ip4
          ??????????valid_http_versions:
          ??????????-?HTTP/1.1
          ??????????-?HTTP/2
          ????????prober:?http
          ????????headers:
          ??????????content-type:?application/json
          ????????body:?'{"k":?"v"}'???//自定義的?body?數(shù)據(jù)
          ????????timeout:?5s
          ??????ping:
          ????????icmp:
          ??????????preferred_ip_protocol:?ip4
          ????????prober:?icmp
          ????????timeout:?5s
          ??????tcp_connect:
          ????????prober:?tcp
          ????????timeout:?5s

          以上配置,讓 blackbox-exporter 加載了完整的網(wǎng)絡(luò)探針模塊。

          撥測

          probe實現(xiàn)了對 blackbox-exporter 的配置管理,極大的簡化配置。

          1. 撥測 ICMP

                
                kind:?Probe
          apiVersion:?monitoring.coreos.com/v1
          metadata:
          ??name:?icmp-probe
          ??namespace:?kubegems-monitoring
          spec:
          ??interval:?60s
          ??module:?ping
          ??prober:
          ????url:?prometheus-blackbox-exporter.kubegems-monitoring.svc.cluster.local:9115
          ??targets:
          ????staticConfig:
          ??????static:
          ??????-?114.114.114.114
          ??????-?baidu.com

          通過查詢PromQL count by (__name__) ({job="probe/kubegems-monitoring/icmp-probe"}),我們可以得到如下指標(biāo)

                
                probe_dns_lookup_time_seconds{}??//?icmp中域名解析耗時
          probe_duration_seconds{}??//?撥測耗時
          probe_icmp_duration_seconds{}??//?icmp?的耗時??????
          probe_success{}??//撥測結(jié)果

          撥測 DNS

                
                kind:?Probe
          apiVersion:?monitoring.coreos.com/v1
          metadata:
          ??name:?dns-probe
          ??namespace:?kubegems-monitoring
          spec:
          ??interval:?60s
          ??module:?dns
          ??prober:
          ????url:?prometheus-blackbox-exporter.kubegems-monitoring.svc.cluster.local:9115
          ??targets:
          ????staticConfig:
          ??????static:
          ??????-?kubegems.io

          通過查詢PromQL count by (__name__) ({job="probe/kubegems-monitoring/dns-probe"}),我們可以得到如下指標(biāo)

                
                probe_dns_additional_rrs{}???????????//?附加記錄列表中的條目數(shù)量
          probe_dns_answer_rrs{}????????????????//?響應(yīng)記錄列表中的條目數(shù)量
          probe_dns_authority_rrs{}?????????????//?權(quán)威記錄列表中的條目數(shù)量
          probe_dns_duration_seconds{}?????//?dns解析耗時

          撥測 TCP

                
                kind:?Probe
          apiVersion:?monitoring.coreos.com/v1
          metadata:
          ??name:?tcp-probe
          ??namespace:?kubegems-monitoring
          spec:
          ??interval:?60s
          ??module:?tcp_connect
          ??prober:
          ????url:?prometheus-blackbox-exporter.kubegems-monitoring.svc.cluster.local:9115
          ??targets:
          ????staticConfig:
          ??????static:
          ??????-?kubegems.io:443

          通過查詢PromQL count by (__name__) ({job="probe/kubegems-monitoring/tcp-probe"}),我們可以得到如下指標(biāo)

                
                probe_dns_lookup_time_seconds{}
          probe_duration_seconds{}
          probe_failed_due_to_regex{}
          probe_ip_addr_hash{}
          probe_ip_protocol{}
          probe_success{}

          撥測 HTTP GET

                
                kind:?Probe
          apiVersion:?monitoring.coreos.com/v1
          metadata:
          ??name:?http-probe
          ??namespace:?kubegems-monitoring
          spec:
          ??interval:?60s
          ??module:?http_2xx
          ??prober:
          ????path:?/probe
          ????url:?prometheus-blackbox-exporter.kubegems-monitoring.svc.cluster.local:9115
          ??targets:
          ????staticConfig:
          ??????static:
          ??????-?https://kubegems.io

          通過查詢PromQL count by (__name__) ({job="probe/kubegems-monitoring/http-probe"}),我們可以得到如下指標(biāo)

                
                probe_dns_lookup_time_seconds{}??// http撥測中的 dns 查詢耗時
          probe_duration_seconds{}
          probe_failed_due_to_regex{}
          probe_http_content_length{}
          probe_http_duration_seconds{}????//?http?handler?各階段處理耗時
          probe_http_last_modified_timestamp_seconds{}
          probe_http_redirects{}
          probe_http_ssl{}????//?是否啟用?https
          probe_http_status_code{}???//?http?狀態(tài)碼
          probe_http_uncompressed_body_length{}
          probe_http_version{}
          probe_ssl_earliest_cert_expiry{}??//?ssl證書過期時間
          probe_ssl_last_chain_expiry_timestamp_seconds{}
          probe_ssl_last_chain_info{}
          probe_success{}
          probe_tls_version_info{}???//?tls版本

          撥測 GRPC

                
                kind:?Probe
          apiVersion:?monitoring.coreos.com/v1
          metadata:
          ??name:?grpc-probe
          ??namespace:?kubegems-monitoring
          spec:
          ??interval:?60s
          ??module:?grpc_plain
          ??prober:
          ????url:?prometheus-blackbox-exporter.kubegems-monitoring.svc.cluster.local:9115
          ??targets:
          ????staticConfig:
          ??????static:
          ??????-?172.16.23.86:30590

          通過查詢PromQL count by (__name__) ({job="probe/kubegems-monitoring/grpc-probe"}),我們可以得到如下指標(biāo)

                
                probe_dns_lookup_time_seconds{}
          probe_duration_seconds{}
          probe_grpc_duration_seconds{}
          probe_grpc_healthcheck_response{}
          probe_grpc_ssl{}
          probe_grpc_status_code{}
          probe_ssl_earliest_cert_expiry{}
          probe_success{}

          瀏覽 111
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  欧美18禁 | 一级欧美另类 | 欧美日韩二区三区四区东京热 | 久久久精品国产 | 久久亚洲香蕉视频 |