国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

prometheus使用missing-container-metrics監(jiān)控pod

這篇具有很好參考價值的文章主要介紹了prometheus使用missing-container-metrics監(jiān)控pod。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

一、簡介

Kubernetes 默認(rèn)情況下使用 cAdvisor 來收集容器的各項指標(biāo),足以滿足大多數(shù)人的需求,但還是有所欠缺,比如缺少對以下幾個指標(biāo)的收集:

  • OOM kill

  • 容器重啟的次數(shù)

  • 容器的退出碼

missing-container-metrics 這個項目彌補了 cAdvisor 的缺陷,新增了以上幾個指標(biāo),集群管理員可以利用這些指標(biāo)迅速定位某些故障。例如,假設(shè)某個容器有多個子進(jìn)程,其中某個子進(jìn)程被 OOM kill,但容器還在運行,如果不對 OOM kill 進(jìn)行監(jiān)控,管理員很難對故障進(jìn)行定位。

二、安裝

官方提供了helm chart方式來進(jìn)行安裝,我們先添加helm倉庫

helm?repo?add?missing-container-metrics?https://draganm.github.io/missing-container-metrics

把這個chart下載到本地,我們需要修改value.yaml文件

[root@master-01 addons]# helm pull missing-container-metrics/missing-container-metrics
[root@master-01 addons]# ls
blackbox        dingtalk  harbor_exporter                      mysql-exporter    prometheusalert  rules                          servicemonitor  victoriametrics
blackbox-probe  etcd      missing-container-metrics-0.1.1.tgz  process-exporter  redis-exporter   scheduler-controller-svc.yaml  ssl-exporter
[root@master-01 addons]# tar xf  missing-container-metrics-0.1.1.tgz 

可配置項

Parameter Description Default
image.repository 鏡像名稱 dmilhdef/missing-container-metrics
image.pullPolicy 鏡像拉取策略 IfNotPresent
image.tag 鏡像tag v0.21.0
imagePullSecrets 拉取鏡像的secret []
nameOverride 覆蓋生成的圖表名稱。默認(rèn)為 .Chart.Name。
fullnameOverride 覆蓋生成的版本名稱。默認(rèn)為 .Release.Name。
podAnnotations Pod 的Annotations {"prometheus.io/scrape": "true", "prometheus.io/port": "3001"}
podSecurityContext 為 pod 設(shè)置安全上下文
securityContext 為 pod 中的容器設(shè)置安全上下文
resources PU/內(nèi)存資源請求/限制 {}
useDocker 從 Docker 獲取容器信息,如果容器運行時為docker ,設(shè)置為true false
useContainerd 從 Containerd 獲取容器信息,如果容器運行時為containers ,設(shè)置為true true

我們這里修改missing-container-metrics/values.yaml中``useDockertrue`,然后安裝

[root@master-01 addons]# kubectl create namespace missing-container-metrics
namespace/missing-container-metrics created
[root@master-01 addons]# helm install missing-container-metrics  missing-container-metrics -n missing-container-metrics
NAME: missing-container-metrics
LAST DEPLOYED: Tue Jul  6 10:47:35 2021
NAMESPACE: missing-container-metrics
STATUS: deployed
REVISION: 1
TEST SUITE: None
[root@master-01 addons]# helm -n missing-container-metrics list
NAME                            NAMESPACE                       REVISION        UPDATED                                 STATUS          CHART                           APP VERSION
missing-container-metrics       missing-container-metrics       1               2021-07-06 10:47:35.261058822 +0800 CST deployed        missing-container-metrics-0.1.1 0.21.0     
##因為我只有一個節(jié)點,所以這里daemonset 就只有一個pod
[root@master-01 addons]# kubectl get pod -n missing-container-metrics 
NAME                              READY   STATUS    RESTARTS   AGE
missing-container-metrics-s9cgk   1/1     Running   0          115s

我們可以訪問服務(wù)的3001端口查看metrics,例如

[root@master-01 addons]# curl 100.67.79.150:3001/metrics
# HELP container_last_exit_code Last exit code of the container
# TYPE container_last_exit_code gauge
container_last_exit_code{container_id="docker://0133fb5d739ba98b3985bdc7766fa200334bbbf29de9a61f98a463ec00de53de",container_short_id="0133fb5d739b",docker_container_id="0133fb5d739ba98b3985bdc7766fa200334bbbf29de9a61f98a463ec00de53de",image_id="docker-pullable://k8s.gcr.io/pause:3.2",name="k8s_POD_dns-autoscaler-565bf94d6c-dc6v4_kube-system_96437fe8-200c-4845-a7cc-a27790c6c5a7_0",namespace="kube-system",pod="dns-autoscaler-565bf94d6c-dc6v4"} 0
container_last_exit_code{container_id="docker://0388ba15b0181fead17cfc3606a57aeef0a9b8b73cf3f97eb901565c8aa1702c",container_short_id="0388ba15b018",docker_container_id="0388ba15b0181fead17cfc3606a57aeef0a9b8b73cf3f97eb901565c8aa1702c",image_id="docker-pullable://sha256:e20d2ec0d0ed8ffd693b435af9f2943095a608440e3b845331d6d00344025455",name="k8s_victoriametrics_victoriametrics-0_kube-system_7b381d2c-791b-4e38-8cbb-43485afcb285_0",namespace="kube-system",pod="victoriametrics-0"} 0
container_last_exit_code{container_id="docker://0400f7e29dab47304f97669cb52b5c7c9310fbb5c156c07d0dc9bfca6b8ee14d",container_short_id="0400f7e29dab",docker_container_id="0400f7e29dab47304f97669cb52b5c7c9310fbb5c156c07d0dc9bfca6b8ee14d",image_id="docker-pullable://k8s.gcr.io/pause:3.2",name="k8s_POD_csi-resizer-f6d66495f-s4vkv_longhorn-system_282278da-2638-4e26-8411-802bf57c1ed8_0",namespace="longhorn-system",pod="csi-resizer-f6d66495f-s4vkv"} 0
container_last_exit_code{container_id="docker://04e2c60777ce277c62c7137f1d7b40d9c1523bb3edf9127efd357590f39ba79c",container_short_id="04e2c60777ce",docker_container_id="04e2c60777ce277c62c7137f1d7b40d9c1523bb3edf9127efd357590f39ba79c",image_id="docker-pullable://k8s.gcr.io/pause:3.2",name="k8s_POD_kube-state-metrics-859b6bf99-q8tdf_monitoring_529aa188-f7a0-4b5c-9608-cd8fc473ac8c_2",namespace="monitoring",pod="kube-state-metrics-859b6bf99-q8tdf"} 0

服務(wù)公開了如下的指標(biāo):

  • container_restarts?:容器的重啟次數(shù)。

  • container_ooms?:容器的 OOM 殺死數(shù)。這涵蓋了容器 cgroup 中任何進(jìn)程的 OOM 終止。

  • container_last_exit_code?:容器的最后退出代碼。

每一個指標(biāo)包含如下標(biāo)簽:

  • docker_container_id:容器的完整 ID。

  • container_short_id:Docker 容器 ID 的前 6 個字節(jié)。

  • container_id:容器 id 以與 kubernetes pod 指標(biāo)相同的格式表示 - 以容器運行時為前綴docker://containerd://取決于容器運行時。這使得 Prometheus 中的kube_pod_container_info指標(biāo)可以輕松連接。

  • name:容器的名稱。

  • image_id:圖像 id 以與 k8s pod 的指標(biāo)相同的格式表示。這使得 Prometheus 中的kube_pod_container_info指標(biāo)可以輕松連接。

  • pod:如果io.kubernetes.pod.name在容器上設(shè)置了pod標(biāo)簽,則其值將設(shè)置為指標(biāo)中的標(biāo)簽

  • namespace:如果io.kubernetes.pod.namespace容器上設(shè)置了namespace標(biāo)簽,則其值將設(shè)置為指標(biāo)的標(biāo)簽。

三、添加PodMonitor 和 PrometheusRule(針對Prometheus Operator)

在template目錄下創(chuàng)建文件podmonitor.yaml

{{ if .Values.prometheusOperator.podMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PodMonitor
metadata:
  name: {{ include "missing-container-metrics.fullname" . }}
  {{- with .Values.prometheusOperator.podMonitor.namespace }}
  namespace: {{ . }}
  {{- end }}
  labels:
    {{- include "missing-container-metrics.labels" . | nindent 4 }}
    {{- with .Values.prometheusOperator.podMonitor.selector }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
spec:
  selector:
    matchLabels:
      {{- include "missing-container-metrics.selectorLabels" . | nindent 6 }}
  podMetricsEndpoints:
  - port: http
  namespaceSelector:
    matchNames:
      - {{ .Release.Namespace }}
{{ end }}

在template目錄下創(chuàng)建文件prometheusrule.yaml

{{ if .Values.prometheusOperator.prometheusRule.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: {{ include "missing-container-metrics.fullname" . }}
  {{- with .Values.prometheusOperator.prometheusRule.namespace }}
  namespace: {{ . }}
  {{- end }}
  labels:
    {{- include "missing-container-metrics.labels" . | nindent 4 }}
    {{- with .Values.prometheusOperator.prometheusRule.selector }}
    {{- toYaml . | nindent 4 }}
    {{- end }}
spec:
  groups:
  - name: {{ include "missing-container-metrics.fullname" . }}
    rules:
      {{- toYaml .Values.prometheusOperator.prometheusRule.rules | nindent 6 }}
{{ end }}

修改value.yaml,添加如下

useDocker: true
useContainerd: false
###添加
prometheusOperator:
  podMonitor:
    # Create a Prometheus Operator PodMonitor resource
    enabled: true
    # Namespace defaults to the Release namespace but can be overridden
    namespace: ""
    # Additional labels to add to the PodMonitor so it matches the Operator's podMonitorSelector
    selector:
      app.kubernetes.io/name: missing-container-metrics

  prometheusRule:
    # Create a Prometheus Operator PrometheusRule resource
    enabled: true
    # Namespace defaults to the Release namespace but can be overridden
    namespace: ""
    # Additional labels to add to the PrometheusRule so it matches the Operator's ruleSelector
    selector:
      prometheus: k8s
      role: alert-rules
    # The rules can be set here. An example is defined here but can be overridden.
    rules:
    - alert: ContainerOOMObserved
      annotations:
        message: A process in this Pod has been OOMKilled due to exceeding the Kubernetes memory limit at least twice in the last 15 minutes. Look at the metrics to determine if a memory limit increase is required.
      expr: sum(increase(container_ooms[15m])) by (exported_namespace, exported_pod) > 2
      labels:
        severity: warning
    - alert: ContainerOOMObserved
      annotations:
        message: A process in this Pod has been OOMKilled due to exceeding the Kubernetes memory limit at least ten times in the last 15 minutes. Look at the metrics to determine if a memory limit increase is required.
      expr: sum(increase(container_ooms[15m])) by (exported_namespace, exported_pod) > 10
      labels:
        severity: critical

使用下面命令更新

[root@master-01 addons]# helm upgrade missing-container-metrics -n missing-container-metrics missing-container-metrics/
Release "missing-container-metrics" has been upgraded. Happy Helming!
NAME: missing-container-metrics
LAST DEPLOYED: Tue Jul  6 11:36:02 2021
NAMESPACE: missing-container-metrics
STATUS: deployed
REVISION: 2
TEST SUITE: None

更新后會創(chuàng)建podmonitor和prometeusrules

[root@master-01 addons]# kubectl get prometheusrules.monitoring.coreos.com  -n missing-container-metrics 
NAME                        AGE
missing-container-metrics   15s
[root@master-01 addons]# kubectl get podmonitors.monitoring.coreos.com  -n missing-container-metrics 
NAME                        AGE
missing-container-metrics   35s

我們可以在prometheus ui 上看到相關(guān)target和rules

prometheus使用missing-container-metrics監(jiān)控pod文章來源地址http://www.zghlxwxcb.cn/news/detail-475031.html

到了這里,關(guān)于prometheus使用missing-container-metrics監(jiān)控pod的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • java prometheus 自定義exporter開發(fā),以及實現(xiàn)多個接口返回metrics

    ??exporter的作用是采集需要監(jiān)控的數(shù)據(jù),并將采集到的數(shù)據(jù)轉(zhuǎn)換成prometheus所需要的數(shù)據(jù)格式,將這些轉(zhuǎn)換后的數(shù)據(jù)返回,供給prometheus 使用。 java 編寫自定義exporter所需要的pom.xml: exporter的四類指標(biāo)說明 數(shù)據(jù)類型 解釋 Counter Counter類型代表一種樣本數(shù)據(jù)單調(diào)遞增的指標(biāo),即

    2023年04月08日
    瀏覽(29)
  • k8s v1.27.4 部署metrics-serverv:0.6.4,kube-prometheus

    k8s v1.27.4 部署metrics-serverv:0.6.4,kube-prometheus

    只有一個問題,原來的httpGet存活、就緒檢測一直不通過,于是改為tcpSocket后pod正常。 修改后的yaml文件,鏡像修改為阿里云 部署kube-prometheus 兼容1.27的為main分支 只克隆main分支 處理: 修改prometheus-clusterRole.yaml 使用ServiceMonitor添加監(jiān)控: 以ingress-nginx為例 修改ingress-nginx.yaml的

    2024年02月12日
    瀏覽(20)
  • k8s v1.27.4 部署metrics-serverv:0.6.4,kube-prometheus,鏡像下載問題處理

    k8s v1.27.4 部署metrics-serverv:0.6.4,kube-prometheus,鏡像下載問題處理

    只有一個問題,原來的httpGet存活、就緒檢測一直不通過,于是改為tcpSocket后pod正常。 修改后的yaml文件,鏡像修改為阿里云 部署kube-prometheus 兼容1.27的為main分支 只克隆main分支 處理: 修改prometheus-clusterRole.yaml 使用ServiceMonitor添加監(jiān)控: 以ingress-nginx為例 修改ingress-nginx.yaml的

    2024年02月05日
    瀏覽(20)
  • Prometheus配置通過file_sd_configs中每個目標(biāo)的module標(biāo)簽信息重置每個目標(biāo)的metrics_path

    配置方式如下: 這里: 通過前 3 個 relabel_config 從 address 和 port 標(biāo)簽生成 host 和 port module 標(biāo)簽的值通過最后一個 relabel_config 直接作為 metrics_path 所以 module 標(biāo)簽的值會覆蓋通過 regex 生成的默認(rèn)路徑 例如,targets.json 中有以下目標(biāo): 那么 Prometheus 最終會使用以下 metrics_path: /app1 /app

    2024年02月10日
    瀏覽(16)
  • 【k8s】:部署、使用 metrics-server

    【k8s】:部署、使用 metrics-server

    ??The Begin??點點關(guān)注,收藏不迷路?? 基于Kubernetes 集群,并已經(jīng)安裝并配置好 kubectl 工具。 Metrics Server 可以幫助我們監(jiān)控集群中節(jié)點和容器的資源使用情況。 在本篇 CSDN 博客中,我將詳細(xì)介紹如何部署 Metrics Server 到 Kubernetes 集群中。 工作流程說明: 1、用戶執(zhí)行 kubectl

    2024年04月16日
    瀏覽(21)
  • SpringBoot中間件使用之EventBus、Metric、CommandLineRunner

    SpringBoot中間件使用之EventBus、Metric、CommandLineRunner

    1、EventBus 使用EventBus 事件總線的方式可以實現(xiàn)消息的 發(fā)布/訂閱 功能,EventBus是一個輕量級的消息服務(wù)組件,適用于Android和Java。 // 1.注冊事件通過 EventBus.getDefault().register(); // 2.發(fā)布事件 EventBus.getDefault().post(“事件內(nèi)容”); // 3.監(jiān)聽事件,通過在方法上添加注解 @Subscribe實現(xiàn)

    2024年02月13日
    瀏覽(26)
  • kube-state-metrics和cAdvisorc結(jié)合使用的好處

    kube-state-metrics是Kubernetes監(jiān)控系統(tǒng)的重要組成部分,它提供了對集群中對象狀態(tài)的實時監(jiān)控。具體來說,kube-state-metrics通過監(jiān)聽API Server生成有關(guān)資源對象的狀態(tài)指標(biāo),比如Deployment、Node、Pod等。kube-state-metrics只是簡單提供一個metrics數(shù)據(jù),并不會存儲這些指標(biāo)數(shù)據(jù),所以通???/p>

    2024年04月27日
    瀏覽(31)
  • Jmeter插件PerfMon Metrics Collector安裝使用及報錯解決

    Jmeter插件PerfMon Metrics Collector安裝使用及報錯解決

    Jmeter作為一個輕量級的性能測試工具,開源、小巧、靈活的特性使其越來越受到測試人員喜愛。在實際的項目中,特別是跨地區(qū)項目,排除合作方指定要求使用Loadrunner作為性能測試工具外,Jmeter會是首選。 本篇文章,就著重介紹下Jmeter服務(wù)器性能監(jiān)控插件PerfMon Metrics Collec

    2024年02月10日
    瀏覽(61)
  • k8s(1.28)使用Helm安裝metrics-server

    提示:文章寫完后,目錄可以自動生成,如何生成可參考右邊的幫助文檔 提示:這里可以添加本文要記錄的大概內(nèi)容: metrics-server安裝后,可以查看集群的node和pod的CPU和Memory占用情況,非常有用。 提示:以下是本篇文章正文內(nèi)容,下面案例可供參考 官網(wǎng)地址:https://github

    2024年02月19日
    瀏覽(42)
  • centos 安裝contained,contained的使用

    k8s從1.24版本開始默認(rèn)是containerd作為容器運行時,不在使用docker作為容器運行時。所以,本篇講解containerd的基本安裝及使用方法。 containerd沒有單獨的yum源,我們可以從docker-ce的yum源中安裝containerd。 CLI是 \\\"Command Line Interface\\\" 的英文縮寫,意思是\\\"命令行界面\\\",常見的容器CLI包

    2024年02月09日
    瀏覽(27)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包