Filebeat+Logstash+Elasticsearch收集spark日志分析

数据流程图如下:

一、配置Filebeat

编辑filebeat.yml文件,内容如下:

# ====================== 输入 ===============================
filebeat.inputs:
- type: log
  enabled: true
  paths:
    - /data/log/hadoop-yarn/hadoop-cmf-yarn-NODEMANAGER*.out
    - /data/yarn/container-logs/application_*/container_*/std*

# ====================== 输出 ===============================
output.kafka:
  enabled: true
  hosts: ["ip01:9092", "ip02:9092"]
  topic: 'topic01'
  kerberos.enabled: true
  kerberos.auth_type: "keytab"
  kerberos.keytab: "xxx.keytab"
  kerberos.config_path: "/etc/krb5.conf"
  kerberos.realm: "xxx.COM"
  kerberos.service_name: "kafka"
  kerberos.username: "xxx"

启动Filebeat,执行命令 ./filebeat -e -c filebeat.yml

二、配置Logstash

编辑logstash.conf,内容如下:

# ***********************************************************************************
#                            logstash 执行规则配置
# ***********************************************************************************

# ============================= 输入 ===================================
input {
  kafka {
    id => "kafka-input-mot"
    bootstrap_servers => "ip01:9092,ip02:9092"
    group_id => "logstash-group-1"
    topics => ["mot","test"]
    jaas_path => "/opt/logstash-7.9.3/jaas.conf"
    kerberos_config => "/etc/krb5.conf"
    security_protocol => "SASL_PLAINTEXT"
    sasl_kerberos_service_name => "kafka"
    add_field => {"piplinetype" => "mot"}
  }
  kafka {
    id => "kafka-input-bigdatalog"
    bootstrap_servers => "ip01:9092,ip02:9092"
    group_id => "logstash-group-2"
    topics => ["topic01"]
    jaas_path => "/opt/logstash-7.9.3/jaas.conf"
    kerberos_config => "/etc/krb5.conf"
    security_protocol => "SASL_PLAINTEXT"
    sasl_kerberos_service_name => "kafka"
    add_field => {"piplinetype" => "topic01"}
  }
}

# ============================= 过滤 ====================================
filter {
  json {source => "message"}
  if [piplinetype] == "mot" {
    mutate {
        remove_field => [ "message" ]
    }
  }
}

# ============================= 输出 ====================================

# -----------------------------------------------------------------------
output {
        if [piplinetype] == "mot" {  # mot数据输出到es
                 elasticsearch{
                    hosts=>["ip01:9200","ip02:9200"]
                   index => "mot"
                 }
        }else if [piplinetype] == "bigdatalog"  {  # yarn日志输出到es
                  if [log][file][path] =~ "/data/log/hadoop-yarn/hadoop-cmf-yarn-NODEMANAGER.*\.out" {
                   elasticsearch{
                         hosts=>["ip01:9200","ip02:9200"]
                         index => "bigdatalog-yarn-nm"
                   }
                  }else if [log][file][path] =~ "/data/yarn/container-logs/application_.*/container_.*/stdout" {
                   elasticsearch{
                         hosts=>["ip01:9200","ip02:9200"]
                         index => "bigdatalog-yarn-application-out"
                   }
                  }else if [log][file][path] =~ "/data/yarn/container-logs/application_.*/container_.*/stderr" {
                   elasticsearch{
                         hosts=>["ip01:9200","ip02:9200"]
                         index => "bigdatalog-yarn-application-err"
                   }
                  }
        }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

头顶榴莲树

你的鼓励是我最大的动力~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值