前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >filebeat导入Hadoop日志到Elasticsearch中

filebeat导入Hadoop日志到Elasticsearch中

作者头像
克虏伯
发布2019-06-11 19:20:53
1.2K0
发布2019-06-11 19:20:53
举报

最近工作需要,用filebeat将Hadoop日志导入到Elasticsearch中,在kibana中展示,记录下。

    版本分别是elasticsearch:6.5.1、kibana:6.5.1、filebeat:6.4,版本要对应,开始我用的filebeat版本是7.0,导致在kibana中展示时有问题,后来用6.4版本就没有这个问题了。

    首先要启动elasticearch和kibana,我是在Docker中运行这俩个的,具体可以看我的elasticsearchkibana博客。浏览器打开localhost:5601可以看到kibana的界面。

    去filebeat官网下载6.4版本的压缩包,之后解压并进入目录,之后修改filebeat.yml:

List-1

代码语言:javascript
复制
#=========================== Filebeat inputs =============================

filebeat.inputs:

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

- type: log

  # Change to true to enable this input configuration.
  enabled: true

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
    #- /var/log/*.log
    - /opt/software/tool/hadoop/hadoop/logs/*.log
    #- c:\programdata\elasticsearch\logs\*

    修改filebeat的input:

  1. enabled的值改为true
  2. paths的值添加hadoop的日志目录

List-2

代码语言:javascript
复制
#============================== Kibana =====================================

# Starting with Beats version 6.0.0, the dashboards are loaded via the Kibana API.
# This requires a Kibana endpoint configuration.
setup.kibana:

  # Kibana Host
  # Scheme and port can be left out and will be set to the default (http and 5601)
  # In case you specify and additional path, the scheme is required: http://localhost:5601/path
  # IPv6 addresses should always be defined as: https://[2001:db8::1]:5601
  host: "localhost:5601"

    如上List-2中所示,修改Kibana模块,将'host: "localhost:5601"'之前的注释去掉。

List-3

代码语言:javascript
复制
#================================ Outputs =====================================

# Configure what output to use when sending the data collected by the beat.

#-------------------------- Elasticsearch output ------------------------------
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["localhost:9200"]

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

    如List-3所示,修改Outputs模块,将Elasticsearch output的hosts: "localhost:9200"的值改为我们自己elasticsearch的IP与端口。

    之后如List-4所示,没有报错就说明成功了。

List-4

代码语言:javascript
复制
./filebeat setup --dashboards
Loading dashboards (Kibana must be running and reachable)
Loaded dashboards

#启动filebeat
./filebeat -e -c filebeat.yml

      来看kibana的界面,如下图1中的Discover可以看到日志,图2中的logs可以看到随着hadoop的日志文件内容被修改,kibana中的日志会相应的滚动显示,图1和图2中的搜索框中可以输入值进行搜索。

                                                                                  图1

                                                                                 图2

代码语言:txt
复制
 (adsbygoogle = window.adsbygoogle || []).push({});
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
Elasticsearch Service
腾讯云 Elasticsearch Service(ES)是云端全托管海量数据检索分析服务,拥有高性能自研内核,集成X-Pack。ES 支持通过自治索引、存算分离、集群巡检等特性轻松管理集群,也支持免运维、自动弹性、按需使用的 Serverless 模式。使用 ES 您可以高效构建信息检索、日志分析、运维监控等服务,它独特的向量检索还可助您构建基于语义、图像的AI深度应用。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档