Giter VIP home page Giter VIP logo

flume's Introduction

flume examples

netcat source

This configuration defines a single agent named a1. a1 has a netcat source that listens for data on port 44444, a channel that buffers event data in memory, and a sink that logs event data to the console.

$ cd apache-flume-1.7.0-bin
$ bin/flume-ng agent --conf conf --conf-file conf/netcat_source.conf --name a1 -Dflume.root.logger=INFO,console

On local mac

$ flume-ng agent -f ./netcat_source.conf  --name a1

From a separate terminal, we can then telnet port 44444 and send Flume an event:

$ telnet localhost 44444
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
hello
OK
world
OK

The original Flume terminal will output the event in a log message.

2017-01-13 10:59:19,955 (lifecycleSupervisor-1-0) [INFO - org.apache.flume.source.NetcatSource.start(NetcatSource.java:169)] Created serverSocket:sun.nio.ch.ServerSocketChannelImpl[/127.0.0.1:44444]
2017-01-13 10:59:57,913 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:95)] Event: { headers:{} body: 68 65 6C 6C 6F 0D                               hello. }
2017-01-13 11:00:00,483 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:95)] Event: { headers:{} body: 77 6F 72 6C 64 0D                               world. }

hive sink

In this example, we use a exec source to cat content of a csv file, then write the lines as events to a hive table, partitioned by date.

$ cd apache-flume-1.7.0-bin
$ bin/flume-ng agent --conf conf --conf-file conf/hive.conf --name agent1 -Dflume.root.logger=INFO,console

Next start a hive shell, then

create table test(id string, message string)
PARTITIONED BY (day int)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ','
LOCATION '/hive/mydb.db/test';

hive> ALTER TABLE test
    > ADD PARTITION (day = <today>);

put <today> like 20170113.

Then,

hive> select * from test;

You should see something like this:

1 AAAAAAA 20170113
2 BBBBBBB 20170113
3 CCCCCCCC  20170113
4 DDDDDD  20170113
5 EEEEEEE 20170113
6 FFFFFFFFFFF 20170113
7 GGGGGG  20170113
8 HHHHHHH 20170113
9 IIIIII  20170113
10  JJJJJJ  20170113
11  KKKKKK  20170113
12  LLLLLLLL  20170113
13  MMMMMMMMM 20170113
14  NNNNNNNNN 20170113
15  OOOOOOOO  20170113
16  PPPPPPPPPP  20170113
17  QQQQQQQ 20170113
18  RRRRRRR 20170113
19  SSSSSSSS  20170113

flume's People

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.