這篇文章主要講解了“使用Prometheus的規(guī)則有哪些”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“使用Prometheus的規(guī)則有哪些”吧!

創(chuàng)新互聯(lián)是一家專業(yè)提供兗州企業(yè)網(wǎng)站建設(shè),專注與網(wǎng)站設(shè)計、成都做網(wǎng)站、H5場景定制、小程序制作等業(yè)務(wù)。10年已為兗州眾多企業(yè)、政府機(jī)構(gòu)等服務(wù)。創(chuàng)新互聯(lián)專業(yè)網(wǎng)站設(shè)計公司優(yōu)惠進(jìn)行中。
在配置系統(tǒng)監(jiān)控的時候,是不是即使絞盡腦汁監(jiān)控的也還是不夠全面,或者不知如何獲取想要的指標(biāo)。
Awesome Prometheus alerts 維護(hù)了一套開箱即用的 Prometheus 告警規(guī)則集合,有 300 多個告警規(guī)則。同時,還是說明如何獲取對應(yīng)的指標(biāo)。這些規(guī)則,對每個 Prometheus 都是通用的。
涉及如主機(jī)、硬件、容器等基礎(chǔ)資源,到數(shù)據(jù)庫、消息代理、運(yùn)行時、反向代理、負(fù)責(zé)均衡器,運(yùn)行時、服務(wù)編排,甚至是網(wǎng)絡(luò)層面和 Prometheus 自身和集群。Prometheus 的安裝和配置不做贅述,配置可以看這里。下面簡單看下幾個常用規(guī)則
主機(jī)和硬件資源的告警依賴 node-exporter 輸出的指標(biāo)。例如:
可用內(nèi)存低于閾值 10% 就會觸發(fā)告警。
- alert: HostOutOfMemory
expr: node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100 < 10
for: 2m
labels:
severity: warning
annotations:
summary: Host out of memory (instance {{ $labels.instance }})
description: "Node memory is filling up (< 10% left)\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"最近兩分鐘入站的流量超過 100m。
rate語法見這里。
- alert: HostUnusualNetworkThroughputIn
expr: sum by (instance) (rate(node_network_receive_bytes_total[2m])) / 1024 / 1024 > 100
for: 5m
labels:
severity: warning
annotations:
summary: Host unusual network throughput in (instance {{ $labels.instance }})
description: "Host network interfaces are probably receiving too much data (> 100 MB/s)\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"Mysql 的告警依賴 prometheus/mysqld_exporter 輸出的指標(biāo)。
Mysql 實例的連接數(shù)最近一分鐘的連接數(shù)超過最大值的 80% 觸發(fā)告警
- alert: MysqlTooManyConnections(>80%)
expr: avg by (instance) (rate(mysql_global_status_threads_connected[1m])) / avg by (instance) (mysql_global_variables_max_connections) * 100 > 80
for: 2m
labels:
severity: warning
annotations:
summary: MySQL too many connections (> 80%) (instance {{ $labels.instance }})
description: "More than 80% of MySQL connections are in use on {{ $labels.instance }}\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"最近一分鐘慢查詢數(shù)量大于 0 時觸發(fā)。
- alert: MysqlSlowQueries
expr: increase(mysql_global_status_slow_queries[1m]) > 0
for: 2m
labels:
severity: warning
annotations:
summary: MySQL slow queries (instance {{ $labels.instance }})
description: "MySQL server mysql has some new slow query.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"JVM 的運(yùn)行時告警,居然只有可憐巴巴的一個。堆空間占用超過 80% 觸發(fā)告警。
依賴 java-client 輸出的指標(biāo)。
- alert: JvmMemoryFillingUp
expr: (sum by (instance)(jvm_memory_used_bytes{area="heap"}) / sum by (instance)(jvm_memory_max_bytes{area="heap"})) * 100 > 80
for: 2m
labels:
severity: warning
annotations:
summary: JVM memory filling up (instance {{ $labels.instance }})
description: "JVM memory is filling up (> 80%)\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"Kubernetes 相關(guān)的告警規(guī)則有 33 個,比較豐富。
摘個比較常見的:容器OOM告警。
- alert: KubernetesContainerOomKiller
expr: (kube_pod_container_status_restarts_total - kube_pod_container_status_restarts_total offset 10m >= 1) and ignoring (reason) min_over_time(kube_pod_container_status_last_terminated_reason{reason="OOMKilled"}[10m]) == 1
for: 0m
labels:
severity: warning
annotations:
summary: Kubernetes container oom killer (instance {{ $labels.instance }})
description: "Container {{ $labels.container }} in pod {{ $labels.namespace }}/{{ $labels.pod }} has been OOMKilled {{ $value }} times in the last 10 minutes.\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"通過 輸出的指標(biāo),可以監(jiān)控證書過期:未來 7 天 有證書過期便會觸發(fā)告警。
- alert: SslCertificateExpiry(<7Days)
expr: ssl_verified_cert_not_after{chain_no="0"} - time() < 86400 * 7
for: 0m
labels:
severity: warning
annotations:
summary: SSL certificate expiry (< 7 days) (instance {{ $labels.instance }})
description: "{{ $labels.instance }} Certificate is expiring in 7 days\n VALUE = {{ $value }}\n LABELS = {{ $labels }}"感謝各位的閱讀,以上就是“使用Prometheus的規(guī)則有哪些”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對使用Prometheus的規(guī)則有哪些這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識點(diǎn)的文章,歡迎關(guān)注!
網(wǎng)站標(biāo)題:使用Prometheus的規(guī)則有哪些
當(dāng)前URL:http://www.chinadenli.net/article12/igpogc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供、移動網(wǎng)站建設(shè)、商城網(wǎng)站、域名注冊、手機(jī)網(wǎng)站建設(shè)、品牌網(wǎng)站設(shè)計
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)