一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

Linux|Centos|Ubuntu|系統進程|Fedora|注冊表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服務器之家 - 服務器系統 - Centos - CentOS7搭建Prometheus 監控Linux主機

CentOS7搭建Prometheus 監控Linux主機

2021-01-08 23:19linux運維菜 Centos

prometheus可以拆分成多個節點進行指標收集。本文主要介紹CentOS7搭建Prometheus 監控Linux主機。

 簡介

prometheus可以拆分成多個節點進行指標收集。

安裝環境:CentOS7

CentOS7搭建Prometheus 監控Linux主機

安裝prometheus

wget -c https://github.com/prometheus/prometheus/releases/download/v2.23.0/prometheus-2.23.0.linux-amd64.tar.gz 

tar zxvf prometheus-2.23.0.linux-amd64.tar.gz  -C /opt/ 

cd /opt/ 

ln -s prometheus-2.23.0.linux-amd64 prometheus 

cat > /etc/systemd/system/prometheus.service <<EOF 

[Unit] 

Description=prometheus 

After=network.target 

 

[Service] 

Type=simple 

WorkingDirectory=/opt/prometheus 

ExecStart=/opt/prometheus/prometheus --config.file="/opt/prometheus/prometheus.yml" 

LimitNOFILE=65536 

PrivateTmp=true 

RestartSec=2 

StartLimitInterval=0 

Restart=always 

 

[Install] 

WantedBy=multi-user.target 

EOF 

systemctl daemon-reload  

systemctl enable prometheus 

systemctl start prometheus 

 CentOS7搭建Prometheus 監控Linux主機

配置Prometheus

這里配置的是監聽/opt/prometheus/servers/目錄下的json文件

cat > /opt/prometheus/prometheus.yml <<EOF 

# my global config 

global

  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 configuration 

alerting: 

  alertmanagers: 

  - static_configs: 

    - targets: 

      # - alertmanager:9093 

 

Load rules once and periodically evaluate them according to the global 'evaluation_interval'

rule_files: 

  # - "first_rules.yml" 

  # - "second_rules.yml" 

 

# A scrape configuration containing exactly one endpoint to scrape: 

# Here it's Prometheus itself. 

scrape_configs: 

  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. 

  - job_name: 'prometheus' 

 

    # metrics_path defaults to '/metrics' 

    # scheme defaults to 'http'

 

    static_configs: 

    - targets: ['localhost:9090'

     

  - job_name: 'servers' 

    file_sd_configs: 

    - refresh_interval: 61s 

      files: 

        - /opt/prometheus/servers/*.json 

EOF 

systemctl restart prometheus 

json格式

CentOS7搭建Prometheus 監控Linux主機

每個json文件需要是一個數組對象,如果不需要自定義標簽,可以直接寫到targets里面去也可以,可以有多個文件

[     

    { 

        "targets": [ 

            "192.168.1.164:9100" 

        ], 

        "labels": { 

            "instance""192.168.1.164"

            "job""node_exporter" 

        } 

    }, 

    { 

        "targets": [ 

            "192.168.1.167:9100" 

        ], 

        "labels": { 

            "instance""192.168.1.167"

            "job""node_exporter" 

        } 

    } 

安裝node_exporter

安裝到/opt/node_exporter路徑下,保持默認的端口

https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gz 

tar zxvf node_exporter-1.0.1.linux-amd64.tar.gz -C /opt/ 

cd /opt/ 

ln -s  node_exporter-1.0.1.linux-amd64 node_exporter 

cat > /etc/systemd/system/node_exporter.service <<EOF 

[Unit] 

Description=node_exporter 

After=network.target 

 

[Service] 

Type=simple 

WorkingDirectory=/opt/node_exporter 

ExecStart=/opt/node_exporter/node_exporter 

LimitNOFILE=65536 

PrivateTmp=true 

RestartSec=2 

StartLimitInterval=0 

Restart=always 

 

[Install] 

WantedBy=multi-user.target 

EOF 

systemctl daemon-reload 

systemctl enable node_exporter 

systemctl start node_exporter 

圖形展示

直接安裝grafana進行展示

yum -y install   https://dl.grafana.com/oss/release/grafana-7.3.6-1.x86_64.rpm 

systemctl enable grafana-server 

systemctl start grafana-server 

啟動之后,grafana默認監聽的是3000端口,直接使用瀏覽器進行訪問就可以了,默認用戶名密碼是admin/admin,第一次登陸之后會提示修改。

CentOS7搭建Prometheus 監控Linux主機

配置數據源:鼠標左邊的菜單 Configuration -> Data Source -> Add data source -> 選擇prometheus -> url那欄填入prometheus的地址就可以了 -> 最后 Save & test 就可以了。

grafana.com/grafana/dashboards 官網已經有人做好的模板,我們直接import進來就可以了。

導入面板:鼠標左邊的菜單 Dashboards -> Import -> 填入id -> Load -> 選擇數據源就可以了。

我經常用的是:1860 、8919 這兩個來查看node_exporter監控

CentOS7搭建Prometheus 監控Linux主機

總結

安裝這些服務都是使用systemd進行管理的,操作起來比較方便的。

這里沒有設置告警,可以根據自己的需要設置對應的告警規則,使用alertmanager進行告警。

原文地址:https://www.toutiao.com/i6914917162675192324/

延伸 · 閱讀

精彩推薦
  • CentosCentOS6.5下Redis安裝與配置詳細步驟

    CentOS6.5下Redis安裝與配置詳細步驟

    本篇文章主要介紹了CentOS6.5下Redis安裝與配置詳細步驟,詳細介紹redis單機單實例安裝與配置,服務及開機自啟動。有興趣的可以了解一下。...

    飛流11452021-12-24
  • CentosCentos7運用/dev/shm進行網站優化

    Centos7運用/dev/shm進行網站優化

    這篇文章主要介紹了LINUX中Centos7運用/dev/shm進行網站優化相關知識點,對此有興趣的朋友參考學習下。...

    彬菌9912022-03-02
  • CentosCentos 7開啟網卡自動獲取IP的詳細方法

    Centos 7開啟網卡自動獲取IP的詳細方法

    本篇文章主要介紹了Centos 7開啟網卡自動獲取IP的詳細方法,小編覺得挺不錯的,現在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧...

    凌鋒8972021-12-29
  • CentosCentOS下Uptime命令詳解

    CentOS下Uptime命令詳解

    在Linux下,我們可以使用uptime命令,而且此命令不必使用root權限。uptime命令在系統中已經默認安裝了。今天小編為大家帶來的是CentOS下Uptime命令詳解;希望...

    CentOS之家11482019-06-19
  • CentosCentOS7設置日期和時間方法以及基本概念介紹

    CentOS7設置日期和時間方法以及基本概念介紹

    這篇文章主要介紹了CentOS7設置日期和時間方法以及基本概念介紹,本文講解使用CentOS7中的新命令timedatectl設置日期時間方法,需要的朋友可以參考下 ...

    CentOS之家6522019-09-19
  • CentosCentOS 6.6實現永久修改DNS地址的方法

    CentOS 6.6實現永久修改DNS地址的方法

    這篇文章主要介紹了CentOS 6.6實現永久修改DNS地址的方法,涉及針對CentOS配置文件的相關設置技巧,具有一定參考借鑒價值,需要的朋友可以參考下 ...

    Linux社區4472020-08-21
  • Centoscentos 安裝與操作方法

    centos 安裝與操作方法

    這篇文章主要介紹了centos 安裝與操作方法,需要的朋友可以參考下...

    centos之家5272019-07-11
  • Centoscentos不小心刪除/root目錄該如何解決?

    centos不小心刪除/root目錄該如何解決?

    一些朋友最近在問小編centos不小心刪除/root目錄該如何解決?今天小編就為大家分享centos不小心刪除/root目錄解決辦法;希望對大家會有幫助,有需要的朋友...

    腳本之家8022019-05-29
主站蜘蛛池模板: 40分钟在线观看免费 | 欧美成人tv在线观看免费 | 国产欧美精品一区二区三区–老狼 | 日本春菜花在线中文字幕 | bt岛www| www.好吊操| 日韩精品欧美高清区 | 丝袜护士强制脚足取精 | 青草香蕉精品视频在线观看 | 亚洲 日韩经典 中文字幕 | 免费看一级大片 | 亚洲国内精品 | 关晓彤被调教出奶水的视频 | 2020韩国r级理论片在线观看 | 午夜看片a福利在线观看 | 精品人人做人人爽久久久 | 青青草视频破解版 | 特级淫片欧美高清视频蜜桃 | 国产精品亚洲午夜不卡 | 九九精品免费视频 | 小早川怜子亚洲综合中文字幕 | avtt天堂网 手机资源 | 国产精品亚洲综合久久 | 精品国产品香蕉在线观看 | 美女脱了内裤让男生玩屁股 | 亚洲日韩男人网在线 | 精品91一区二区三区 | 99久久免费看精品国产一区 | 交欧美 | 日本中文字幕二区三区 | 日本一区二区三区四区无限 | 欧美成人福利视频 | 极品久久 | 波多野结衣久久国产精品 | 国内精品一区二区三区东京 | 免费观看欧美成人禁片 | 久久综合久久伊人 | 韩国三级年轻的小婊孑 | 九九在线精品视频 | 手机看片日韩1024你懂的首页 | 99国产精品免费视频 |