<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告警

          共 2332字,需瀏覽 5分鐘

           ·

          2021-06-23 09:57

          在講解prometheus的時(shí)候我們說(shuō)其具有告警的特征,也就是prometheus在收集監(jiān)控?cái)?shù)據(jù)的時(shí)候會(huì)根據(jù)規(guī)則判斷相應(yīng)指標(biāo)是否達(dá)到了告警上線然后使用推送的方式進(jìn)行告警。但是要明確的一點(diǎn)是prometheus的僅僅是用來(lái)收集和查詢監(jiān)控?cái)?shù)據(jù)的,要讓我們的prometheus具有告警功能還需要prometheus體系的另一個(gè)組件altermanger,這塊我們大概的講解一下。
          https://prometheus.io/download/


          下載好altermanager之后,我們解壓。其中的altermanager.yml是altermanager的配置文件。主要用來(lái)管理告警信息發(fā)送的規(guī)則,也就是說(shuō)給誰(shuí)發(fā),用那種方式。

          這塊作者簡(jiǎn)單測(cè)試了一下監(jiān)控mysql的線程數(shù)的告警。首先配置一下prometheus的數(shù)據(jù)收集的規(guī)則和push告警信息的地址。

          groups:- name: test-mysql-rule  rules:  - alert: "連接數(shù)報(bào)警"    expr: mysql_global_variables_mysqlx_max_connections > 90   #連接數(shù)大于90就告警    for: 1s    labels:      severity: warning    annotations:      summary: "服務(wù)名:{{$labels.alertname}}"      description: "業(yè)務(wù)msyql連接數(shù)不夠報(bào)警: 當(dāng)前值為:{{ $value }}"      value: "{{ $value }}"

          在prometheus配置文件中添加這個(gè)告警規(guī)則

          # my global configglobal:  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).

          # Alertmanager configurationalerting: alertmanagers: - static_configs: - targets: ["localhost:9093"] #發(fā)送到altermanager的告警分析中# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.rule_files: - "tianjingle_rules.yml"# Here it's Prometheus itself.scrape_configs: # The job name is added as a label `job=` to any timeseries scraped from this config. - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] # 添加msyql的監(jiān)控 - job_name: 'mysql' # 靜態(tài)添加node static_configs: # 指定監(jiān)控端 - targets: ['localhost:9104']

          - job_name: 'bounter-monitor' scrape_interval: 5s metrics_path: '/actuator/prometheus' static_configs: - targets: ['localhost:8081']


          配置好上述配置之后對(duì)prometheus重啟。并在prometheus的alter欄目中查看告警是否觸發(fā)。發(fā)現(xiàn)已經(jīng)觸發(fā)了告警配置。

          在配置好prometheus的告警之后,我們需要配置altermanager的告警信息路由規(guī)則。我們修改altermanager.yml文件。

          global:  resolve_timeout: 5m  smtp_smarthost: 'smtp.qq.com:465'  smtp_from: '[email protected]'  smtp_auth_username: '[email protected]'  smtp_auth_password: '********'  smtp_require_tls: falseroute:  receiver: mailreceivers:  - name: 'mail'    email_configs:      - to: '[email protected]'

          配置好qq郵箱的報(bào)警提醒之后,我們重啟altermanager。然后看一下是否會(huì)收到報(bào)警的郵件。稍等片刻,在郵箱中收到了郵件,如圖。

          早~



          瀏覽 82
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <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>
                  日韩一级片免费观看 | 久草免费极品盛宴 | 操一操干一干 | 爱搞搞电影 | 亚洲日本高清在线 |