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

创建mapping模板,因为metricbeat第一次启动时候,会把mapping自动建立在es上,所以不用手工创建了。如果直接输出到logstash,需要手工创建

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

支持的协议

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

支持协议列表

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

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 157,924评论 4 360
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 66,902评论 1 290
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 107,716评论 0 239
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,783评论 0 203
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,166评论 3 286
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,510评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,784评论 2 311
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,476评论 0 196
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,196评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,459评论 2 243
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 31,978评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,321评论 2 252
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 32,964评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,046评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,803评论 0 193
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,530评论 2 271
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,420评论 2 265

推荐阅读更多精彩内容