grafana prometheus 監(jiān)控

1.grafana安裝

sudo yum install https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.3.4-1.x86_64.rpm?

修改配置

vim /etc/grafana/grafana.ini

? [paths]

# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used)

data = /var/lib/grafana

# Directory where grafana can store logs

logs = /var/log/grafana

# Directory where grafana will automatically scan and look for plugins

plugins = /var/lib/grafana/plugins

# The ip address to bind to, empty will bind to all interfaces

http_addr =0.0.0.0

# The http port? to use

http_port = 9300

# If you use reverse proxy and sub path specify full url (with sub path)

root_url = http://127.0.0.1:9300

安裝插件

grafana-cli plugins install grafana-piechart-panel

grafana-cli plugins install grafana-worldmap-panel

重啟配置?

service grafana-server restart

2.prometheus安裝

wget? https://github.com/prometheus/prometheus/releases/download/v2.5.0/prometheus-2.5.0.linux-amd64.tar.gz

tar -zxvf prometheus-2.5.0.linux-amd64.tar.gz

配置prometheus.yml

global:

? scrape_interval:? ? 1s

? evaluation_interval: 1s

scrape_configs:

? - job_name: prometheus

? ? static_configs:

? ? ? - targets: ['127.0.0.1:9301']

? ? ? ? labels:

? ? ? ? ? instance: prometheus

? - job_name: linux

? ? static_configs:

? ? ? - targets: ['127.0.0.1:9100']

? ? ? ? labels:

? ? ? ? ? instance:? Nelab-3-server

? ? ? - targets: ['127.0.0.1:9100']

? ? ? ? labels:

? ? ? ? ? instance: crontab-server

? ? ? - targets: ['127.0.0.1:9100']

? ? ? ? labels:

? ? ? ? ? instance: socket-server

? - job_name: 'mysql'

? ? static_configs:

? ? ? - targets: ['127.0.0.1:9104']

? ? ? ? labels:

? ? ? ? ? instance: Nelab-3-db

? - job_name: redis

? ? static_configs:

? ? ? - targets: ['127.0.0.1:9121']

? ? ? ? labels:

? ? ? ? ? instance: db1

啟動(dòng)

? ./prometheus --config.file=prometheus.yml --web.listen-address=:9301

3.安裝 prometheus_exporters

wget https://github.com/prometheus/mysqld_exporter/releases/download/v0.11.0/mysqld_exporter-0.11.0.linux-amd64.tar.gz

wget https://github.com/prometheus/node_exporter/releases/download/v0.17.0-rc.0/node_exporter-0.17.0-rc.0.linux-amd64.tar.gz

wget https://github.com//oliver006/redis_exporter/releases/download/v0.22.0/redis_exporter-v0.22.0.linux-amd64.tar.gz

【mysql】

? vim .my.cnf

? [client]

? host=172.31.26.69

? port=3306

? user=game

? password=CvSMOyYW

? nohup ./mysqld_exporter --config.my-cnf=".my.cnf" &

? 【redis】

? nohup ./redis_exporter --redis.addr? redis://127.0.0.1:6379 --redis.password irbouh92 &

? 【node_exporter】

? nohup ./node_exporter &


? 4.grafana模板

? redis模板

? https://grafana.com/api/dashboards/763/revisions/1/download

? nginx 模板

? https://grafana.com//api/dashboards/2292/revisions/5/download

? mysql MySQL Overview

? https://github.com/percona/grafana-dashboards

? Elasticsearch Nginx Logs

? https://grafana.com//api/dashboards/2292/revisions/5/download

? Node Exporter Server Metrics

? https://grafana.com/api/dashboards/405/revisions/8/download



? 5.nginx日志收集

? 配置NGINX

? ? ? ? ? log_format main? '{"@timestamp":"$time_iso8601",'

? ? ? ? ? ? ? ? ? ? ? ? '"@source":"$server_addr",'

? ? ? ? ? ? ? ? ? ? ? ? '"hostname":"$hostname",'

? ? ? ? ? ? ? ? ? ? ? ? '"ip":"$http_x_forwarded_for",'

? ? ? ? ? ? ? ? ? ? ? ? '"client":"$remote_addr",'

? ? ? ? ? ? ? ? ? ? ? ? '"request_method":"$request_method",'

? ? ? ? ? ? ? ? ? ? ? ? '"scheme":"$scheme",'

? ? ? ? ? ? ? ? ? ? ? ? '"domain":"$server_name",'

? ? ? ? ? ? ? ? ? ? ? ? '"referer":"$http_referer",'

? ? ? ? ? ? ? ? ? ? ? ? '"request":"$request_uri",'

? ? ? ? ? ? ? ? ? ? ? ? '"args":"$args",'

? ? ? ? ? ? ? ? ? ? ? ? '"size":$body_bytes_sent,'

? ? ? ? ? ? ? ? ? ? ? ? '"status": $status,'

? ? ? ? ? ? ? ? ? ? ? ? '"responsetime":$request_time,'

? ? ? ? ? ? ? ? ? ? ? ? '"upstreamtime":"$upstream_response_time",'

? ? ? ? ? ? ? ? ? ? ? ? '"upstreamaddr":"$upstream_addr",'

? ? ? ? ? ? ? ? ? ? ? ? '"http_user_agent":"$http_user_agent",'

? ? ? ? ? ? ? ? ? ? ? ? '"https":"$https"'

? ? ? ? ? ? ? ? ? ? ? ? '}';

? 安裝elasticsearch

? wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.11.tar.gz

? 配置elasticsearch.yml


http.port: 9200

network.host: 0.0.0.0

啟動(dòng)

?nohup bin/elasticsearch &


? 安裝logstash

? wget https://artifacts.elastic.co/downloads/logstash/logstash-6.5.0.tar.gz

? 添加配置 nginx_log.conf

input {

? ? file {

? ? ? ? #這里根據(jù)自己日志命名使用正則匹配所有域名訪問(wèn)日志

? ? ? ? path => [ "/var/log/nginx/*.log" ]

? ? ? ? ignore_older => 0

? ? codec => json

? ? }

}

filter {

? ? mutate {

? ? ? convert => [ "status","integer" ]

? ? ? convert => [ "size","integer" ]

? ? ? convert => [ "upstreatime","float" ]

? ? ? remove_field => "message"

? ? }

? ? geoip {

? ? ? ? source => "ip"

? ? }

}

output {

? ? elasticsearch {

? ? ? ? hosts => "127.0.0.1:9200"

? ? ? ? index => "logstash-nginx-access-%{+YYYY.MM.dd}"

? ? }

#? ? stdout {codec => rubydebug}

}

啟動(dòng)?

./bin/logstash -f config/nginx_log.conf? --path.data=/root/

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末坪稽,一起剝皮案震驚了整個(gè)濱河市渐尿,隨后出現(xiàn)的幾起案子娜谊,更是在濱河造成了極大的恐慌,老刑警劉巖畜疾,帶你破解...
    沈念sama閱讀 217,542評(píng)論 6 504
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)舌涨,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,822評(píng)論 3 394
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)扔字,“玉大人囊嘉,你說(shuō)我怎么就攤上這事「镂” “怎么了扭粱?”我有些...
    開封第一講書人閱讀 163,912評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)震檩。 經(jīng)常有香客問(wèn)我琢蛤,道長(zhǎng),這世上最難降的妖魔是什么抛虏? 我笑而不...
    開封第一講書人閱讀 58,449評(píng)論 1 293
  • 正文 為了忘掉前任博其,我火速辦了婚禮,結(jié)果婚禮上迂猴,老公的妹妹穿的比我還像新娘慕淡。我一直安慰自己,他們只是感情好沸毁,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,500評(píng)論 6 392
  • 文/花漫 我一把揭開白布峰髓。 她就那樣靜靜地躺著,像睡著了一般息尺。 火紅的嫁衣襯著肌膚如雪携兵。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,370評(píng)論 1 302
  • 那天掷倔,我揣著相機(jī)與錄音眉孩,去河邊找鬼。 笑死勒葱,一個(gè)胖子當(dāng)著我的面吹牛浪汪,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播凛虽,決...
    沈念sama閱讀 40,193評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼死遭,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了凯旋?” 一聲冷哼從身側(cè)響起呀潭,我...
    開封第一講書人閱讀 39,074評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤钉迷,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后钠署,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體糠聪,經(jīng)...
    沈念sama閱讀 45,505評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,722評(píng)論 3 335
  • 正文 我和宋清朗相戀三年谐鼎,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了舰蟆。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,841評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡狸棍,死狀恐怖身害,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情草戈,我是刑警寧澤塌鸯,帶...
    沈念sama閱讀 35,569評(píng)論 5 345
  • 正文 年R本政府宣布,位于F島的核電站唐片,受9級(jí)特大地震影響丙猬,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜牵触,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,168評(píng)論 3 328
  • 文/蒙蒙 一淮悼、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧揽思,春花似錦袜腥、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,783評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至损痰,卻和暖如春福侈,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背卢未。 一陣腳步聲響...
    開封第一講書人閱讀 32,918評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工肪凛, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人辽社。 一個(gè)月前我還...
    沈念sama閱讀 47,962評(píng)論 2 370
  • 正文 我出身青樓伟墙,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親滴铅。 傳聞我的和親對(duì)象是個(gè)殘疾皇子戳葵,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,781評(píng)論 2 354

推薦閱讀更多精彩內(nèi)容

  • 主機(jī)數(shù)據(jù)收集 主機(jī)數(shù)據(jù)的采集是集群監(jiān)控的基礎(chǔ);外部模塊收集各個(gè)主機(jī)采集到的數(shù)據(jù)分析就能對(duì)整個(gè)集群完成監(jiān)控和告警等功...
    梅_梅閱讀 6,686評(píng)論 0 7
  • 前面文章提到一個(gè)React工程中包含很多Component汉匙,可以通過(guò)向組件中傳遞參數(shù)拱烁,及props生蚁,使得組件更靈活...
    SamDing閱讀 550評(píng)論 0 0
  • 今天晚上參加中美喜劇中心每周三的即興戲劇,第二次來(lái)戏自,比第一次放開了不少邦投。第一次時(shí)真的好緊張,雖然很投入擅笔,但不知道怎...
    佳慧阿閱讀 142評(píng)論 0 0
  • 奇跡-妖媽感恩日記打卡1/365: 1. 早上起床尼摹,小嘟嘟說(shuō)要送香香姐姐去幼兒園,在去幼兒園的小區(qū)路上剂娄,兩個(gè)小天使...
    行動(dòng)派小金姐閱讀 113評(píng)論 0 0