ElasticSearch-beats

下載

https://www.elastic.co/downloads/beats/

1、metricbeat

支持的服務列表

Apache麸祷、HAProxy赠群、MongoDB离咐、MySQL、Nginx帮匾、PostgreSQL啄骇、Redis、System瘟斜、Zookeeper

上傳并解壓縮metricbeat-5.4.0-linux-x86_64.tar.gz

tar -zxvf metricbeat-5.4.0-linux-x86_64.tar.gz

配置metricbeat缸夹,可以參考metricbeat.full.yml中的配置。

vim /usr/local/metricbeat-5.4.0-linux-x86_64/metricbeat.yml

output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["192.168.1.101:9200","192.168.1.102:9200","192.168.1.103:9200"]

  # Optional protocol and basic auth credentials.
  #protocol: "https"
  username: "elastic"
  password: "123456"

name:"metricbeat-1-103"
tags: ["service-X", "web-tier"]
fields:
  env: dev                                                             

檢查配置是否正確

cd /usr/local/metricbeat-5.4.0-linux-x86_64/
./metricbeat -c metricbeat.yml -configtest

創(chuàng)建mapping模板螺句,因為metricbeat第一次啟動時候虽惭,會把mapping自動建立在es上,所以不用手工創(chuàng)建了蛇尚。如果直接輸出到logstash芽唇,需要手工創(chuàng)建

curl -H 'Content-Type: application/json' -XPUT 'http://192.168.1.101:9200/_template/metricbeat' -d@/usr/local/metricbeat-5.4.0-linux-x86_64/metricbeat.template.json

啟動

sudo /usr/local/metricbeat-5.4.0-linux-x86_64/metricbeat start

報錯處理,必須文件所屬于root

metricbeat2017/05/31 02:21:09.305375 beat.go:339: CRIT Exiting: error loading config file: config file ("metricbeat.yml") must be owned by the beat user (uid=0) or root
Exiting: error loading config file: config file ("metricbeat.yml") must be owned by the beat user (uid=0) or root 

chown -R root /usr/local/metricbeat-5.4.0-linux-x86_64

導入kibana dashboard

cd /usr/local/metricbeat-5.4.0-linux-x86_64/

在線安裝

./scripts/import_dashboards -es http://192.168.1.101:9200 -user elastic -pass 123456

離線安裝

./scripts/import_dashboards -file beats-dashboards-5.4.0.zip -es http://192.168.1.101:9200 -user elastic -pass 123456

2取劫、heartbeat

支持的協(xié)議

ICMP (v4 and v6) 匆笤、TCP研侣、HTTP

上傳并解壓縮heartbeat-5.4.0-linux-x86_64.tar.gz

tar -zxvf heartbeat-5.4.0-linux-x86_64.tar.gz

配置metricbeat,可以參考heartbeat.full.yml中的配置疚膊。

vim /usr/local/heartbeat-5.4.0-linux-x86_64/heartbeat.yml

###################### Heartbeat #######################

# Configure monitors
heartbeat.monitors:
- type: http

  # List or urls to query
  urls: ["http://192.168.1.101"]

  # Configure task schedule
  schedule: '@every 10s'
  # 與java的 quartz cron表達式一致:秒 分 時 日 月 周 年
  #schedule: '*/10 * * * * * *'

  # Total test connection and data exchange timeout
  #timeout: 16s

#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["192.168.1.101:9200","192.168.1.102:9200","192.168.1.103:9200"]

  # Optional protocol and basic auth credentials.
  #protocol: "https"
  username: "elastic"
  password: "123456"

檢查配置是否正確

cd /usr/local/heartbeat-5.4.0-linux-x86_64/
./heartbeat -c heartbeat.yml -configtest

啟動

/usr/local/heartbeat-5.4.0-linux-x86_64/heartbeat start

導入kibana dashboard

cd /usr/local/heartbeat-5.4.0-linux-x86_64/

在線安裝

./scripts/import_dashboards -es http://192.168.1.101:9200 -user elastic -pass 123456

離線安裝

./scripts/import_dashboards -file beats-dashboards-5.4.0.zip -es http://192.168.1.101:9200 -user elastic -pass 123456

進入kibana查看:

http://192.168.1.102:5601/

其他配置模塊

heartbeat.monitors:
- type: icmp
  schedule: '*/5 * * * * * *'
  hosts: ["myhost"]
- type: tcp
  schedule: '@every 5s'
  hosts: ["myhost:7"]  # default TCP Echo Protocol
  check.send: "Check"
  check.receive: "Check"
- type: http
  schedule: '@every 5s'
  urls: ["http://localhost:80/service/status"]
  check.response.status: 200
heartbeat.scheduler:
  limit: 10

3义辕、packetbeat

支持協(xié)議列表

ICMP (v4 and v6)、DNS寓盗、HTTP灌砖、AMQP 0.9.1、Cassandra傀蚌、Mysql基显、PostgreSQL、Redis善炫、Thrift-RPC撩幽、MongoDB、Memcache

上傳并解壓縮packetbeat-5.4.0-linux-x86_64.tar.gz

tar -zxvf packetbeat-5.4.0-linux-x86_64.tar.gz

配置packetbeat箩艺,可以參考packetbeat.full.yml中的配置窜醉。

vim /usr/local/packetbeat-5.4.0-linux-x86_64/packetbeat.yml

packetbeat.interfaces.device: any
packetbeat.protocols.http:
  # Configure the ports where to listen for HTTP traffic. You can disable
  # the HTTP protocol by commenting out the list of ports.
  ports: [80, 8080, 8000, 5000, 8002, 9100l]

#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["192.168.1.101:9200","192.168.1.102:9200","192.168.1.103:9200"]

  # Optional protocol and basic auth credentials.
  #protocol: "https"
  username: "elastic"
  password: "123456"

檢查配置是否正確

cd /usr/local/packetbeat-5.4.0-linux-x86_64/
chown -R root *
./packetbeat -c packetbeat.yml -configtest

啟動

sudo /usr/local/packetbeat-5.4.0-linux-x86_64/packetbeat start

導入kibana dashboard

cd /usr/local/packetbeat-5.4.0-linux-x86_64/

在線安裝

./scripts/import_dashboards -es http://192.168.1.101:9200 -user elastic -pass 123456

離線安裝

./scripts/import_dashboards -file beats-dashboards-5.4.0.zip -es http://192.168.1.101:9200 -user elastic -pass 123456

4、filebeat

上傳并解壓縮filebeat-5.4.0-linux-x86_64.tar.gz

tar -zxvf filebeat-5.4.0-linux-x86_64.tar.gz

配置filebeat艺谆,可以參考filebeat.full.yml中的配置榨惰。

vim /usr/local/filebeat-5.4.0-linux-x86_64/filebeat.yml

#=========================== Filebeat prospectors =============================

filebeat.prospectors:

# Each - is a prospector. Most options can be set at the prospector level, so
# you can use different prospectors for various configurations.
# Below are the prospector specific configurations.

- input_type: log

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
    #- /var/log/*.log
    - /usr/local/heartbeat-5.4.0-linux-x86_64/logs/heartbeat
    #- c:\programdata\elasticsearch\logs\*

  # Exclude lines. A list of regular expressions to match. It drops the lines that are
  # matching any regular expression from the list.
  #exclude_lines: ["^DBG"]

  # Include lines. A list of regular expressions to match. It exports the lines that are
  # matching any regular expression from the list.
  #include_lines: ["^ERR", "^WARN"]

  # Exclude files. A list of regular expressions to match. Filebeat drops the files that
  # are matching any regular expression from the list. By default, no files are dropped.
  #exclude_files: [".gz$"]

  # Optional additional fields. These field can be freely picked
  # to add additional information to the crawled log files for filtering
  #fields:
  #  level: debug
  #  review: 1

  ### Multiline options

  # Mutiline can be used for log messages spanning multiple lines. This is common
  # for Java Stack Traces or C-Line Continuation

  # The regexp Pattern that has to be matched. The example pattern matches all lines starting with [
  #multiline.pattern: ^\[

  # Defines if the pattern set under pattern should be negated or not. Default is false.
  //如果下一行沒有匹配上,則屬于前一行
  #multiline.negate: true

  # Match can be set to "after" or "before". It is used to define if lines should be append to a pattern
  # that was (not) matched before or after or as long as a pattern is not matched based on negate.
  # Note: After is the equivalent to previous and before is the equivalent to to next in Logstash
  #multiline.match: after  

檢查配置是否正確

cd /usr/local/filebeat-5.4.0-linux-x86_64/filebeat -c filebeat.yml -configtest

啟動

/usr/local/filebeat-5.4.0-linux-x86_64/filebeat start

導入kibana dashboard

cd /usr/local/filebeat-5.4.0-linux-x86_64

在線安裝

./scripts/import_dashboards -es http://192.168.1.101:9200 -user elastic -pass 123456

離線安裝

./scripts/import_dashboards -file beats-dashboards-5.4.0.zip -es http://192.168.1.101:9200 -user elastic -pass 123456

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末静汤,一起剝皮案震驚了整個濱河市琅催,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌虫给,老刑警劉巖藤抡,帶你破解...
    沈念sama閱讀 212,816評論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異抹估,居然都是意外死亡缠黍,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,729評論 3 385
  • 文/潘曉璐 我一進店門药蜻,熙熙樓的掌柜王于貴愁眉苦臉地迎上來瓷式,“玉大人,你說我怎么就攤上這事谷暮≥锿” “怎么了盛垦?”我有些...
    開封第一講書人閱讀 158,300評論 0 348
  • 文/不壞的土叔 我叫張陵湿弦,是天一觀的道長。 經(jīng)常有香客問我腾夯,道長颊埃,這世上最難降的妖魔是什么蔬充? 我笑而不...
    開封第一講書人閱讀 56,780評論 1 285
  • 正文 為了忘掉前任,我火速辦了婚禮班利,結(jié)果婚禮上饥漫,老公的妹妹穿的比我還像新娘。我一直安慰自己罗标,他們只是感情好庸队,可當我...
    茶點故事閱讀 65,890評論 6 385
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著闯割,像睡著了一般彻消。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上宙拉,一...
    開封第一講書人閱讀 50,084評論 1 291
  • 那天宾尚,我揣著相機與錄音,去河邊找鬼谢澈。 笑死煌贴,一個胖子當著我的面吹牛,可吹牛的內(nèi)容都是我干的锥忿。 我是一名探鬼主播牛郑,決...
    沈念sama閱讀 39,151評論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼缎谷!你這毒婦竟也來了井濒?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 37,912評論 0 268
  • 序言:老撾萬榮一對情侶失蹤列林,失蹤者是張志新(化名)和其女友劉穎瑞你,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體希痴,經(jīng)...
    沈念sama閱讀 44,355評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡者甲,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,666評論 2 327
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了砌创。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片虏缸。...
    茶點故事閱讀 38,809評論 1 341
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖嫩实,靈堂內(nèi)的尸體忽然破棺而出刽辙,到底是詐尸還是另有隱情,我是刑警寧澤甲献,帶...
    沈念sama閱讀 34,504評論 4 334
  • 正文 年R本政府宣布宰缤,位于F島的核電站,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏慨灭。R本人自食惡果不足惜朦乏,卻給世界環(huán)境...
    茶點故事閱讀 40,150評論 3 317
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望氧骤。 院中可真熱鬧呻疹,春花似錦、人聲如沸筹陵。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,882評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽朦佩。三九已至姑蓝,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間吕粗,已是汗流浹背纺荧。 一陣腳步聲響...
    開封第一講書人閱讀 32,121評論 1 267
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留颅筋,地道東北人宙暇。 一個月前我還...
    沈念sama閱讀 46,628評論 2 362
  • 正文 我出身青樓,卻偏偏與公主長得像议泵,于是被迫代替她去往敵國和親占贫。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 43,724評論 2 351

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