• Stars
    star
    108
  • Rank 321,259 (Top 7 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 10 years ago
  • Updated 11 months ago

Reviews

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

Repository Details

A Fluentd log agent.

fluent-agent-hydra

A Fluentd log agent.

This agent is inspired by fluent-agent-lite.

Features

  • Tailing log files (like in_tail)
    • enable to handle multiple files in a single process.
    • parse JSON or LTSV format.
  • Forwarding messages to external fluentd (like out_forward)
    • multiple fluentd server can be used. When primary server is down, messages will sent to secondary server.
    • if config.ServerRoundRobin = true, select one server from all servers by round robin.
  • Receiving a fluentd's forward protocol messages via TCP (like in_forward)
    • includes simplified on-memory queue.
  • Stats monitor httpd server
    • serve an agent stats by JSON format.
  • Supports sub-second time
    • Supported by Fluentd 0.14 or later. When you use Fluentd <= 0.12 as forwarded servers, fluentd will not accept records including sub-second time.

Installation

Binary releases

or

go get github.com/fujiwara/fluent-agent-hydra/cmd/fluent-agent-hydra/

Usage

Using command line arguments

fluent-agent-hydra [options] TAG TARGET_FILE PRIMARY_SERVER SECONDARY_SERVER

Options

  • -f="message": fieldname of fluentd log message attribute (DEFAULT: message)
  • -monitor="127.0.0.1:24223": monitor httpd daemon address (DEFAULT: -)

Usage example

fluent-agent-hydra -f msg tagname /path/to/foo.log fluentd.example.com:24224 127.0.0.1:24224
  • Field name: "msg"
  • Filename: "/path/to/foo.log"
  • Primary server: "fluentd.example.com:24224"
  • Secondary server: "127.0.0.1:24224"

Using configuration file

fluent-agent-hydra -c /path/to/config.toml

A example of config.toml

# global settings
TagPrefix = "nginx"       # "nginx.access", "nginx.error"
FieldName = "message"     # default "message"
ReadBufferSize = 1048576  # default 64KB.
ServerRoundRobin = true   # default false
SubSecondTime = true      # default false. for Fluentd 0.14 or later only

# tailing log file (in_tail)
[[Logs]]
File = "/var/log/nginx/access.log"
Tag = "access"
# parse as ltsv format. (see http://ltsv.org/)
# Format = "None"(default) | "LTSV" | "JSON" | "Regexp"
Format = "LTSV"

# If Format is "Regexp", Regexp directive is required.
# Regexp = "(your regexp string)" | "apache" | "nginx" | "syslog"

# convert column data type
# 'column1_name:type,column2_name:type'
# type = "interger" | "float" | "bool" | otherwise as string
Types = "reqtime:float,size:integer,apptime:float,status:integer"

# parse a time string in log lines, and set it as record's timestamp
TimeParse = true      # default false
TimeKey = "timestamp" # default "time"

# TimeFormat is passed to Golang's time.Parse().
# http://golang.org/pkg/time/#Parse
# default time.RFC3339 == "2006-01-02T15:04:05Z07:00"
# "apache" | "nginx" | "syslog" | "unix" is also available
TimeFormat = "02/Jan/2006:15:04:05 Z0700"

[[Logs]]
File = "/var/log/nginx/error.log"
Tag = "error"

# forwarding fluentd server (out_forward)
[[Servers]]
Host = "fluentd.example.com"
Port = 24224

[[Servers]]
Host = "fluentd-backup.example.com"
Port = 24224

# receive fluentd forward protocol daemon (in_forward)
[Receiver]
Port = 24224

# stats monitor http daemon
[Monitor]
Host = "localhost"
Port = 24223

About special conversion behavior for numerical value

When the Format is JSON, fluent-agent-hydra treats a numerical value as float64 even if its type is integer. For treating a numerical value as integer, set a column data type integer with the Types.

Types = "column_name:integer"

Its type is converted to int64.

Stats monitor

For enabling stats monitor, specify command line option -m host:port or [Monitor] section in config file.

Hydra application stats

curl -s [Monitor.Host]:[Monitor.Port]/ | jq .

An example response.

{
  "receiver": {
    "buffered": 0,
    "disposed": 0,
    "messages": 123,
    "max_buffer_messages": 1048576,
    "current_connections": 1,
    "total_connections": 10,
    "address": "[::]:24224"
  },
  "servers": [
    {
      "error": "",
      "alive": true,
      "address": "fluentd.example.com:24224"
    },
    {
      "error": "[2014-08-18 18:25:28.965066394 +0900 JST] dial tcp 192.168.1.11:24224: connection refused",
      "alive": false,
      "address": "fluentd-backup.example.com:24224"
    }
  ],
  "files": {
    "/var/log/nginx/error.log": {
      "error": "",
      "position": 95039,
      "tag": "nginx.error"
    },
    "/var/log/nginx/access.log": {
      "error": "",
      "position": 112093,
      "tag": "nginx.access"
    }
  },
  "sent": {
    "nginx.error": {
      "bytes": 2578,
      "messages": 8
    },
    "nginx.access": {
      "bytes": 44996,
      "messages": 109
    }
  }
}

system stats

curl -s [Monitor.Host]:[Monitor.Port]/system | jq .

An example response.

{
  "time": 1417748153556699400,
  "go_version": "go1.3",
  "go_os": "darwin",
  "go_arch": "amd64",
  "cpu_num": 4,
  "goroutine_num": 17,
  "gomaxprocs": 1,
  "cgo_call_num": 48,
  "memory_alloc": 551840,
  "memory_total_alloc": 17886960,
  "memory_sys": 5310712,
  "memory_lookups": 321,
  "memory_mallocs": 4645,
  "memory_frees": 3622,
  "memory_stack": 131072,
  "heap_alloc": 551840,
  "heap_sys": 2097152,
  "heap_idle": 1253376,
  "heap_inuse": 843776,
  "heap_released": 0,
  "heap_objects": 1023,
  "gc_next": 1083088,
  "gc_last": 1417748153454501600,
  "gc_num": 34,
  "gc_per_second": 0.966939666110773,
  "gc_pause_per_second": 0.641048,
  "gc_pause": [
    0.2991,
    0.341948
  ]
}

Benchmark

See benchmark/README .

Thanks to

Author

Fujiwara Shunichiro [email protected]

Licence

Copyright 2014 Fujiwara Shunichiro. / KAYAC Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

lambroll

lambroll is a minimal deployment tool for AWS Lambda.
Go
330
star
2

stretcher

Deployment tool with consul/serf event notification.
Go
245
star
3

shapeio

Traffic shaper for Golang io.Reader and io.Writer
Go
126
star
4

awslim

A simplified alternative to the AWS CLI for limited use cases.
Go
114
star
5

tracer

ECS task event/log tracer CLI
Go
95
star
6

tfstate-lookup

Lookup resource attributes in tfstate.
Go
87
star
7

ecsta

ECS Task Assistant tool.
Go
59
star
8

ridge

AWS Lambda HTTP Proxy integration event bridge to Go net/http.
Go
55
star
9

ecrm

A command line tool for managing ECR repositories.
Go
54
star
10

consul-kv-dashboard

Consul KVS based dashboard web application.
Go
49
star
11

fluent-plugin-zabbix

fluentd out plugin to zabbix
Ruby
49
star
12

kinesis-tailf

tail -f command for Amazon Kinesis Stream
Go
38
star
13

go-zabbix-get

zabbix-get compatible command (Golang version)
Go
28
star
14

Rin

Rin is a Redshift data Importer by SQS messaging.
Go
26
star
15

chef-solo-with-capistrano

chef-solo by capistrano
Ruby
26
star
16

cfft

cfft is a testing tool for CloudFront Functions.
Go
26
star
17

nssh

Go
22
star
18

aswrap

AWS assume role credential wrapper
Perl
21
star
19

tfstate-merge

A tool to merge tfstate files.
Ruby
20
star
20

mysql-slave-healthcheck-agent

Go
17
star
21

tuggle

Distributed file mirroring proxy in Consul cluster
Go
16
star
22

zabbix-aggregate-agent

Data aggregator for multiple zabbix-agent
Go
15
star
23

fluent-plugin-suppress

fluentd plugin to suppress same messages.
Ruby
14
star
24

isucon11-f

Vue
13
star
25

raus

Raus: Ranged unique id supplier
Go
12
star
26

MHA-AWS

A support script for MySQL MasterHA which running on Amazon Web Service.
Perl
12
star
27

lamblocal

Go
12
star
28

go-redis-setlock

Like the setlock command using Redis.
Perl
11
star
29

sailtrim

A minimal deployment tool for Amazon Lightsail.
Go
11
star
30

ohai-plugin-consul

Ohai plugin for Consul API
Ruby
10
star
31

maprobe

Mackerel external probe agent
Go
9
star
32

perl-queue-q4pg-lite

simple message queue using PostgreSQL.
Perl
8
star
33

p5-Parallel-Benchmark

Perl
8
star
34

Urume

Perl
7
star
35

AWS-XRay

AWS X-Ray tracing library for Perl5
Perl
6
star
36

isucon11-q

Go
6
star
37

knockrd

HTTP knocker daemon
Go
6
star
38

riex

AWS RI expiration detector
Go
5
star
39

go-amzn-oidc

Validator for x-amzn-oidc-data header values.
Go
5
star
40

sardine

Mackerel plugin metrics aggregator with CloudWatch.
Go
4
star
41

maws-cli

A multiplexing wrapper for aws cli.
Go
4
star
42

isucon5q

C
4
star
43

mackerel-plugin-prometheus-query

Prometheus query plugin for Mackerel
Go
4
star
44

go-simple-kvs

simple and tiny key value store
Go
4
star
45

consul-lock

runs another program with a Consul session/kv locked.
Go
4
star
46

fluent-plugin-imkayac

Fluentd plugin to post im.kayac.com
Ruby
4
star
47

iam-policy-finder

iam-policy-finder is finder of AWS IAM Policies.
Go
4
star
48

rrdialer

round robin net dialer.
Go
3
star
49

sirbot

Slack IRC relay bot
Go
3
star
50

Redis-Setlock

Like the setlock command using Redis.
Perl
3
star
51

Acore

Perl
3
star
52

fluent-plugin-firelens-tag-filter

fluent plugin for AWS firelens
Ruby
3
star
53

s32cs

Amazon CloudSearch document uploader via S3 event notification.
Go
3
star
54

go-http-transport-firehose

Go HTTP Transport to dump a request to Firehose
Go
3
star
55

isucon7q

HTML
3
star
56

cfn-lookup

Lookup outputs and exports for CloudFormation stacks.
Go
3
star
57

cloudwatch-to-mackerel

Copy metrics from Amazon CloudWatch to Mackerel.
Go
2
star
58

go-jsqlite

SQL query runner for JSONL
Go
2
star
59

lamux

Lamux is a HTTP multiplexer for AWS Lambda Function aliases.
Go
2
star
60

ssm-lookup

Lookup values in AWS SSM Parameter store.
Go
2
star
61

norikra-listener-mackerel

Norikra listener plugin to post service metrics for Mackerel.
Ruby
2
star
62

Devel-KYTProf-Profiler-Redis-Fast

KYTProf profiler for Redis::Fast
Perl
1
star
63

isucon5

Perl
1
star
64

Plack-Middleware-XRay

Plack middleware for AWS X-Ray tracing
Perl
1
star
65

redisqs

redisqs is a delayed queue manager using Amazon SQS and Redis.
Go
1
star
66

Plack-Middleware-GTop-ProcMem

Plack middleware for mesuring process memory.
Perl
1
star
67

macaroni

macaroni is a reporter for Songmu/horenso.
Go
1
star
68

Plack-Middleware-SetLocalEnv

Set localized environment variables(Perl's %ENV) from the value of PSGI environment.
Perl
1
star
69

ktlog2memcached

KyotoTycoon's slave agent, replicate updates to memcached.
Perl
1
star
70

mkr2oncall-cloudflare-workers

A port of mackerel-to-grafana-oncall for Cloudflare Workers.
TypeScript
1
star
71

Test-UNIXSock

testing UNIX domain socket program
Perl
1
star
72

go-template

Go
1
star
73

distdin

Distribute stdin to multiple sub commands.
Go
1
star
74

mirage-ecs-example

Dockerfile
1
star
75

go-s3concat

Concat S3 objects
Go
1
star
76

lambroll_test

Makefile
1
star
77

p5-dbix-couchlike

Perl
1
star