Skip to content

Commit

Permalink
Fluentd haproxy parser through log files
Browse files Browse the repository at this point in the history
  • Loading branch information
slk244 committed Jul 23, 2019
1 parent 60f67be commit 195b2c6
Show file tree
Hide file tree
Showing 8 changed files with 1,089 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source "https://rubygems.org"

gemspec
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

39 changes: 37 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
# fluentd-logfile-haproxy-parser
A fluentd haproxy parser for logs from a log file
# fluentd-syslog-haproxy-plugin
An logfile haproxy http log parser

## Usage

This plugins works with default http log format from HAProxy:

```
log-format "%ci:%cp [%tr] %ft %b/%s %TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r"
```

## Installing steps

```
gem build fluentd-logfile-haproxy-parser.gemspec
fluent-gem install fluentd-logfile-haproxy-parser-0.0.1.gem
```

## Full fluentd configuration

```
<source>
@type tail
path <path>/haproxy.log
pos_file <path>/pos/haproxy.pos
read_from_head true
<parse>
@type haproxy_logfile
</parse>
tag haproxy
</source>
<match **>
@type stdout
</match>
```
14 changes: 14 additions & 0 deletions fluent.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<source>
@type tail
path <path>/haproxy.log
pos_file <path>/pos/haproxy.pos
read_from_head true
<parse>
@type haproxy_logfile
</parse>
tag haproxy
</source>

<match **>
@type stdout
</match>
Binary file added fluentd-logfile-haproxy-parser-0.0.1.gem
Binary file not shown.
20 changes: 20 additions & 0 deletions fluentd-logfile-haproxy-parser.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

Gem::Specification.new do |spec|
spec.name = "fluentd-logfile-haproxy-parser"
spec.version = "0.0.1"
spec.authors = ["slk"]
spec.email = ["[email protected]"]

spec.summary = "An haproxy log file parser"
spec.description = "An haproxy log file parser"
spec.homepage = "https://github.com/slk244/fluentd-logfile-haproxy-parser"
spec.license = "AGPL-3.0"

spec.files = ["./lib/fluent/plugin/parser_haproxy_logfile.rb"]
spec.executables = []
spec.require_paths = ["lib"]

spec.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
end
301 changes: 301 additions & 0 deletions haproxy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,301 @@
{
"template" : "haproxy*",
"version" : 50001,
"settings" : {
"index.refresh_interval" : "5s"
},
"mappings" : {
"_default_" : {
"properties" : {
"@timestamp" : {
"type" : "date"
},
"actconn" : {
"type" : "short"
},
"auth_type" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"b_end" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"b_server" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"backend_queue" : {
"type" : "short"
},
"beconn" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"bytes" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"c_ip" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"c_port" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"f_end" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"feconn" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"hatime" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"http_version" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"message" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"method" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"path" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"pid" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"ps" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"query_string" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"referer" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"req_cookie" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"res_cookie" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"res_headers" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"retries" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"srv_conn" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"srv_queue" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"status_code" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"t_state" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"tc" : {
"type" : "integer"
},
"time" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"tq" : {
"type" : "integer"
},
"tr" : {
"type" : "integer"
},
"tt" : {
"type" : "integer"
},
"tw" : {
"type" : "integer"
},
"user" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"user_agent" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"worker" : {
"type" : "long"
}
}
}
}
}
Loading

0 comments on commit 195b2c6

Please sign in to comment.