Giter Site home page Giter Site logo

yingzhuo / logback-flume-appender Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 38 KB

logback appender for apache-flume

License: Apache License 2.0

Makefile 2.49% Java 97.51%
apache-hadoop apache-flume apache-hive logback logback-appender slf4j logback-flume-appender flume

logback-flume-appender's Introduction

License JDK Build Maven Central

logback-flume-appender

这个东西不是我原创的。我只找到了如下这个jar包用于将logback产生的业务日志发送到flume,最终传递到hdfs/hive。

<dependency>
    <groupId>com.teambytes.logback</groupId>
    <artifactId>logback-flume-appender_2.11</artifactId>
    <version>0.0.9</version>
</dependency>

由于兼容性等原因,我做了一些工作:

  • 原作者的scala语言的部分,我用java改写了。
  • 升级flume-ng-sdk到1.9.0版本。
  • JDK的最低要求调整到1.8

对于原作者,得罪了。

改写后的jar包坐标:

<!-- logback-appender-for-flume -->
<dependency>
    <groupId>com.github.yingzhuo</groupId>
    <artifactId>logback-flume-appender</artifactId>
    <version>1.0.0</version>
</dependency>

用法

  1. flume agent配置
myagent.sources = mysource
myagent.channels = mychannel
myagent.sinks = mysink

# sources
myagent.sources.mysource.type = avro
myagent.sources.mysource.bind = 0.0.0.0
myagent.sources.mysource.port = 4141

# channel selector
myagent.sources.mysource.selector.type = replicating

# channels
myagent.channels.mychannel.type = org.apache.flume.channel.kafka.KafkaChannel
myagent.channels.mychannel.kafka.bootstrap.servers = 192.168.99.127:9092,192.168.99.128:9092,192.168.99.129:9092
myagent.channels.mychannel.kafka.topic = flume-channel
myagent.channels.mychannel.kafka.group.id = flume

# sinks
myagent.sinks.mysink.type = hdfs
myagent.sinks.mysink.hdfs.path = hdfs://192.168.99.130:8020/%{application}/log/%{type}/%Y-%m-%d
myagent.sinks.mysink.hdfs.useLocalTimeStamp = true
myagent.sinks.mysink.hdfs.fileType = CompressedStream
myagent.sinks.mysink.hdfs.codeC = lzop
myagent.sinks.mysink.hdfs.fileSuffix = .lzo
myagent.sinks.mysink.hdfs.writeFormat = Text
myagent.sinks.mysink.hdfs.round = true
myagent.sinks.mysink.hdfs.rollInterval = 600
myagent.sinks.mysink.hdfs.rollSize = 268435456
myagent.sinks.mysink.hdfs.rollCount = 0
myagent.sinks.mysink.hdfs.timeZone = Asia/Shanghai

# 集成
myagent.sources.mysource.channels = mychannel
myagent.sinks.mysink.channel = mychannel
  1. logback配置 (片段)
<appender name="FLUME" class="com.github.yingzhuo.logback.flume.FlumeAvroAppender">
    <flumeAgents>
        10.211.55.3:4141,
        10.211.55.4:4141,
        10.211.55.5:4141,
    </flumeAgents>
    <flumeProperties>
        connect-timeout=4000;
        request-timeout=8000
    </flumeProperties>
    <batchSize>100</batchSize>
    <reportingWindow>1000</reportingWindow>
    <headers>
        <application>my application</application>
        <tier>my tier</tier>
        <type>my log type</type>
        <tag>my tag</tag>
    </headers>
    <additionalHeaders>
        key1 = value1;
        key2 = value2
    </additionalHeaders>
    <layout class="ch.qos.logback.classic.PatternLayout">
        <pattern>%message%n%ex</pattern>
    </layout>
    <description>
        说明
    </description>
</appender>

注意: 配置复数个Agents时,每条日志只会发送到其中一个Agent。

许可证

Apache License

logback-flume-appender's People

Contributors

yingzhuo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.