上海政均電子科技有限公司主營:??低暠O(jiān)控攝像機,海康威視門禁系統(tǒng),海康停車場系統(tǒng),網(wǎng)絡(luò)攝像機等產(chǎn)品,歡迎咨詢!

搜索
您當前所在位置:網(wǎng)站首頁 > 新聞動態(tài) > 行業(yè)新聞
上海政均電子科技有限公司是一家專業(yè)從事數(shù)字化、網(wǎng)絡(luò)化、智能化產(chǎn)品經(jīng)營的高科技安防公司。

如何打造漂亮的監(jiān)控系統(tǒng)

發(fā)布時間:2020-03-23

瀏覽次數(shù):416


  監(jiān)控系統(tǒng)在一家公司是尤為重要的,它能幫你在7x24小時的實時的關(guān)注線上服務(wù)器的運行情況,當有問題的時候第一時間通知給相應(yīng)的人員今天說下我們的主角就是我們prometheus+grafana+node_exporter


如何打造漂亮的監(jiān)控系統(tǒng)

  Prometheus介紹

  Prometheus 是一套開源的系統(tǒng)監(jiān)控報警框架。它啟發(fā)于 Google 的 borgmon 監(jiān)控系統(tǒng),由工作在 SoundCloud 的 google 前員工在 2012 年創(chuàng)建,作為社區(qū)開源項目進行開發(fā),并于 2015 年正式發(fā)布。2016 年,Prometheus 正式加入 Cloud Native Computing Foundation,成為受歡迎度僅次于 Kubernetes 的項目。

  Prometheus作為TSDB具有以下特點:

  具有由指標名稱和鍵/值對標識的時間序列數(shù)據(jù)的多維度數(shù)據(jù)模型。PromQL靈活的查詢語言。不依賴分布式存儲,單個服務(wù)器節(jié)點是自主的。通過基于HTTP的pull方式采集時序數(shù)據(jù)。可以通過中間網(wǎng)關(guān)(Pushgateway)進行時序列數(shù)據(jù)推送。通過服務(wù)發(fā)現(xiàn)或者靜態(tài)配置來發(fā)現(xiàn)目標服務(wù)對象。支持多種多樣的圖表和界面展示,比如Grafana等。

  Prometheus的安裝

  下載二進制安裝包

  wget https://github.com/prometheus/prometheus/releases/download/v2.16.0/prometheus-2.16.0.linux-amd64.tar.gz

  解壓prometheus壓縮包

  $ tar zxvf prometheus-2.16.0.linux-amd64.tar.gz -C /usr/local/prometheus

  添加prometheus 用戶

  $ groupadd prometheus$ useradd -g prometheus -s /sbin/nologin prometheus

  創(chuàng)建prometheus 啟動文件

  cat > /usr/lib/systemd/system/prometheus.service << EOF[Unit]Description=PrometheusDocumentation=https://prometheus.io/After=network.target[Service]Type=simpleUser=prometheusExecStart=/usr/local/prometheus/prometheus --config.file=/usr/local/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheusRestart=on-failure[Install]WantedBy=multi-user.targetEOF

  啟動服務(wù)并設(shè)為開機啟動

  $ systemctl start prometheus$ systemctl enable prometheus

  以下為一個簡單的prometheus.yml示例:

  # Prometheus全局配置項global: scrape_interval: 15s # 設(shè)定抓取數(shù)據(jù)的周期,默認為1min evaluation_interval: 15s # 設(shè)定更新rules文件的周期,默認為1min scrape_timeout: 15s # 設(shè)定抓取數(shù)據(jù)的超時時間,默認為10s external_labels: # 額外的屬性,會添加到拉取得數(shù)據(jù)并存到數(shù)據(jù)庫中 monitor: 'codelab_monitor'# Alertmanager配置alerting: alertmanagers: - static_configs: - targets: ["localhost:9093"] # 設(shè)定alertmanager和prometheus交互的接口,即alertmanager監(jiān)聽的ip地址和端口# rule配置,首次讀取默認加載,之后根據(jù)evaluation_interval設(shè)定的周期加載rule_files: - "alertmanager_rules.yml" - "prometheus_rules.yml"# scrape配置scrape_configs:- job_name: 'prometheus' # job_name默認寫入timeseries的labels中,可以用于查詢使用 scrape_interval: 15s # 抓取周期,默認采用global配置 static_configs: # 靜態(tài)配置 - targets: ['localhost:9090'] # prometheus所要抓取數(shù)據(jù)的地址,即instance實例項 - job_name: 'node_exporter' # job_name默認寫入timeseries的labels中,可以用于查詢使用 scrape_interval: 15s # 抓取周期,默認采用global配置 static_configs: # 靜態(tài)配置 - targets: ['localhost:9100'] # prometheus所要抓取數(shù)據(jù)的地址,即instance實例項

  安裝 node_exporter

  RHEL/CentOS

  $ curl -Lo /etc/yum.repos.d/_copr_ibotty-prometheus-exporters.repo https://copr.fedorainfracloud.org/coprs/ibotty/prometheus-exporters/repo/epel-7/ibotty-prometheus-exporters-epel-7.repo$ yum install node_exporter$ systemctl start node_exporter

  配置grafana

  1.添加 prometheus 數(shù)據(jù)源


如何打造漂亮的監(jiān)控系統(tǒng)

  ?

  導(dǎo)入node_exporter 模板 ?


如何打造漂亮的監(jiān)控系統(tǒng)

  接下來就能看到實際的效果了,今天只給大家簡單的介紹一下,接下來會為大家詳細的介紹,prometheus 的語法 自動發(fā)現(xiàn) 告警 以及怎么實現(xiàn)數(shù)據(jù)的長時間存儲。

新聞動態(tài)
相關(guān)新聞

   以上是【上海政均電子科技有限公司】為大家分享的相關(guān)新聞。我司是一家專業(yè)從事數(shù)字化、網(wǎng)絡(luò)化、智能化產(chǎn)品經(jīng)營的高科技安防公司。業(yè)務(wù)核心為:閉路數(shù)字監(jiān)控、公共廣播、防盜報警、門禁系統(tǒng)、小區(qū)智能化改造、企業(yè)一卡通管理系統(tǒng)等產(chǎn)品銷售、安裝和售后服務(wù)。為用戶提供各種性能可靠、技術(shù)先進的產(chǎn)品和解決方案始終是我們的業(yè)務(wù)重點?!?a href="http://www.026sh.com" target="_blank">http://www.026sh.com】歡迎大家進入官網(wǎng)點擊查看!