• Stars
    star
    180
  • Rank 213,097 (Top 5 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created about 10 years ago
  • Updated over 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

(Not Maintained) Something acting like fluentd rewritten in Go.

gofluent

wercker status

This program is something acting like fluentd rewritten in Go.

Table of Contents

Introduction

Fluentd is originally written in CRuby, which has too many dependecies.

I hope fluentd to be simpler and cleaner, as its main feature is simplicity and rubostness.

Architecture

    +---------+     +---------+     +---------+     +---------+
    | server1 |     | server2 |     | server3 |     | serverN |
    |---------|     |---------|     |---------|     |---------|
    |         |     |         |     |         |     |         |
    |---------|     |---------|     |---------|     |---------|
    |gofluent |     |gofluent |     |gofluent |     |gofluent |
    +---------+     +---------+     +---------+     +---------+
        |               |               |               |
         -----------------------------------------------
                                |
                                | HTTP POST
                                V
                        +-----------------+
                        |                 |
                        |      Httpmq     |
                        |                 | 
                        +-----------------+
                                |
                                | HTTP GET
                                V 
                        +-----------------+                 +-----------------+
                        |                 |                 |                 |
                        |   Preprocessor  | --------------> |     Storage     |
                        |                 |                 |                 | 
                        +-----------------+                 +-----------------+

Implementation

Overview

Input -> Router -> Output

Data flow

                        -------<-------- 
                        |               |
                        V               | generate pool
       InputRunner.inputRecycleChan     | recycling
            |           |               |     ^   
            |            ------->-------       \ 
            |               ^           ^       \
    InputRunner.inChan      |           |        \
            |               |           |         \
            |               |           |          \
    consume |               |           |           \
            V               |           |            \
          Input(Router.inChan) ---->  Router ----> (Router.outChan)Output.inChan

Plugins

Tail Input Plugin

The in_tail input plugin allows gofluent to read events from the tail of text files. Its behavior is similar to the tail -F command.

Example Configuration

in_tail is included in gofluent’s core. No additional installation process is required.

<source>
  type tail
  path /var/log/httpd-access.log
  pos_file /var/log/httpd-access.log.pos
  tag apache.access
  format /^(?P<host>[^ ]*) [^ ]* (?P<user>[^ ]*) \[(?P<time>[^\]]*)\] "(?P<method>\S+)(?: +(?P<path>[^ ]*) +\S*)?" (?P<code>[^ ]*) (?P<size>[^ ]*)(?: "(?P<referer>[^\"]*)" "(?P<agent>[^\"]*)")?$/
</source>

type (required) The value must be tail.

tag (required) The tag of the event.

path (required) The paths to read.

format (required) The format of the log. It is the name of a template or regexp surrounded by ‘/’. The regexp must have at least one named capture (?P<NAME>PATTERN).

The following templates are supported:

  • regexp
  • json One JSON map, per line. This is the most straight forward format :).
format json

pos_file (highly recommended) This parameter is highly recommended. gofluent will record the position it last read into this file.

pos_file /var/log/access.log.pos

sync_interval The sync interval of pos file, default is 2s.

Httpsqs Output Plugin

The out_httpsqs output plugin allows gofluent to send data to httpsqs mq.

Example Configuration

out_httpsqs is included in gofluent’s core. No additional installation process is required.

<match httpsqs.**>
  type httpsqs
  host localhost
  port 1218
  flush_interval 10
</match>

type (required) The value must be httpsqs.

host (required) The output target host ip.

port (required) The output target host port.

auth (highly recommended) The auth password for httpsqs.

flush_interval The flush interval for sending data to httpsqs.

gzip The gzip switch, default is on.

Forward Output Plugin

The out_forward output plugin allows gofluent to forward events to another gofluent.

Example Configuration

out_forward is included in gofluent’s core. No additional installation process is required.

<match forward.**>
  type forward
  host localhost
  port 1218
  flush_interval 10
</match>

type (required) The value must be forward.

host (required) The output target host ip.

port (required) The output target host port.

flush_interval The flush interval for sending data to httpsqs.

connect_timeout The connect timeout value.

sync_interval The sync interval of metadata file, default is 2s.

buffer_path(required) The disk buffer path for output plugin, default is /tmp/test.

buffer_queue_limit The queue limit of disk buffer, default is 64M.

buffer_chunk_limit The chunk limit of disk buffer to forward, default is 8M.

Stdout Output Plugin

The out_stdout output plugin allows gofluent to print events to stdout.

Example Configuration

out_stdout is included in gofluent’s core. No additional installation process is required.

<match stdout.**>
  type stdout
</match>

type (required) The value must be stdout.

Mongodb Output Plugin

The out_mongodb output plugin allows gofluent to send message to mongodb.

Example Configuration

out_mongodb is included in gofluent's core. No additional installation process is required.

<match mongodb.**>
  type mongodb
  host localhost
  port 27017
  capped on
  capped_size 1024
  database test
  collection test
  user test
  password test
</match>

type(required) The value must be mongodb.

host (required) The output target host ip.

port (required) The output target host port.

capped (highly recommended) To create a capped collection.

capped_size Specify the actual size(MB) of the capped collection.

database(required) The name of the database to be created or used.

collection(required) The name of the collection to be created or used.

user(highly recommended) The user name to login the database.

password(highly recommended) The password to login the database.

More Repositories

1

nginx-vts-exporter

Simple server that scrapes Nginx vts stats and exports them via HTTP for Prometheus consumption
Go
638
star
2

httpmq

A simple HTTP message queue written in Go with goleveldb, just like httpsqs written in C with Tokyo Cabinet.
Go
308
star
3

doggy

Lightweight, idiomatic and stable for building Go 1.7+ HTTP services
Go
283
star
4

nginx-prometheus-metrics

A production demo to collect prometheus metrics for nginx with lua embedded.
Lua
95
star
5

gobreak

Latency and fault tolerance library like Netflix's Hystrix with prometheus and gobreaker.
Go
44
star
6

go-loadbalance

A well designed loadbalance API with dozens of implementations for go-grpc loadbalance.
Go
38
star
7

goroutine-pool

A simple goroutine pool which can create and release goroutine dynamically, inspired by fasthttp.
Go
32
star
8

nginx_upstream_check_module

(Not maintained) This module can be used in pure nginx-1.4.7 and nginx-1.6.2 to check upstream servers, with several patches applied.
C
17
star
9

status-nginx-module

A http status module for pure nginx, which is in production already.
C
14
star
10

graphql-grpc-gateway

Go
10
star
11

zrpc

A lightweight distributed RPC framework powered by pure C language and based on ZeroMQ and pbc.
C
9
star
12

struct2interface

Development helper program that generates a Golang interface by inspecting the structure methods of an existing .go file.
Go
7
star
13

rsa

RAS crypto algorithm for Decrypt with Public Key and Encrypt with Private Key.
Go
6
star
14

httpmq-rs

A simple HTTP message queue written in Rust with rocksdb, just like httpmq written in Go with leveldb.
Rust
3
star
15

lua-resty-fluent

A simple fluent client based on openresty.
Lua
3
star
16

practice-to-intergrate-k8s

A practice to integrate golang, microservice and so on... with k8s
Go
2
star
17

data_struct

Common data structures
C
1
star
18

srt2fcpxml

Go
1
star
19

architecture-best-practice

Best practice from the ground up.
1
star
20

github-trending

A toy to play with weixin mp and github.
Go
1
star
21

proto

Simplify developing HTTP API through Protobuf way.
Go
1
star
22

High-Performance-Browser-Networking-cn

中文翻译
1
star
23

awesome-nginx

A collection of awsome resources around nginx.
1
star
24

ratelimitx

A simple ratelimit for golang, implemented with memcache and gobreak, aims on high availability.
Go
1
star
25

enhanced-limit-conn-nginx-module

An enhanced limit conn nginx module.
C
1
star
26

jumpcutter

An auto jump cutter, implemented with opencv and silence detect.
Python
1
star