Skip to content

Commit 83ce794

Browse files
authored
Merge pull request #65 from rchicoli/development
new release: elasticsearch bulk
2 parents 4b3b996 + 7ba98ff commit 83ce794

File tree

20 files changed

+535
-194
lines changed

20 files changed

+535
-194
lines changed

.travis.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ matrix:
5757
if: type IN (pull_request)
5858

5959
- stage: release
60+
# env: MAJOR_RELEASE=true
61+
# it would be nice to map github labels instead
62+
env: RELEASE_TAG=0.3.0
6063
if: type IN (push)
6164
script:
6265
- ./scripts/git-release.sh

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.9.2-alpine as builder
1+
FROM golang:1.10-alpine as builder
22

33
ARG GOOS=linux
44
ARG GOARCH=amd64

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,8 @@ acceptance_tests:
137137
bats $(TESTS_DIR)/acceptance-tests/$(BATS_TESTFILE)
138138

139139
integration_tests:
140-
bats $(TESTS_DIR)/integration-tests/$(BATS_TESTFILE)
140+
bats $(TESTS_DIR)/integration-tests/$(BATS_TESTFILE)
141+
142+
create_environment: deploy_elasticsearch deploy_webapper
143+
144+
delete_environment: undeploy_elasticsearch undeploy_webapper

README.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Docker Log Elasticsearch
22

3-
[![GoDoc][1]][2] [![License: Apache 2.0][3]][4] [![Release][5]][6] [![Travis Status][7]][8] [![Coveralls Coverage][9]][10] [![Go Report Card][13]][14] [![Downloads][15]][16]
3+
[![GoDoc][1]][2] [![License: Apache 2.0][3]][4] [![Release][5]][6] [![Travis Status][7]][8] [![Coveralls Coverage][9]][10] [![Go Report Card][11]][12]
44

55
[1]: https://godoc.org/github.com/rchicoli/docker-log-elasticsearch?status.svg
66
[2]: https://godoc.org/github.com/rchicoli/docker-log-elasticsearch
@@ -12,14 +12,9 @@
1212
[8]: https://travis-ci.org/rchicoli/docker-log-elasticsearch
1313
[9]: https://coveralls.io/repos/rchicoli/docker-log-elasticsearch/badge.svg?branch=master&service=github
1414
[10]: https://coveralls.io/github/rchicoli/docker-log-elasticsearch?branch=master
15-
[11]: https://codecov.io/github/rchicoli/docker-log-elasticsearch/coverage.svg?branch=master
16-
[12]: https://codecov.io/github/rchicoli/docker-log-elasticsearch?branch=master
17-
[13]: https://goreportcard.com/badge/github.com/rchicoli/docker-log-elasticsearch
18-
[14]: https://goreportcard.com/report/github.com/rchicoli/docker-log-elasticsearch
19-
[15]: https://img.shields.io/github/downloads/rchicoli/docker-log-elasticsearch/total.svg?maxAge=1800
20-
[16]: https://github.com/rchicoli/docker-log-elasticsearch/releases
21-
[17]: https://img.shields.io/github/stars/rchicoli/docker-log-elasticsearch.svg
22-
[18]: https://github.com/rchicoli/docker-log-elasticsearch/stargazers
15+
[11]: https://goreportcard.com/badge/github.com/rchicoli/docker-log-elasticsearch
16+
[12]: https://goreportcard.com/report/github.com/rchicoli/docker-log-elasticsearch
17+
2318

2419
`docker-log-elasticsearch` forwards container logs to Elasticsearch service.
2520

@@ -69,6 +64,10 @@ Before creating a docker container, a healthy instance of Elasticsearch service
6964
| elasticsearch-username | no | no | |
7065
| elasticsearch-url | no | yes |
7166
| elasticsearch-version | 5 | no |
67+
| elasticsearch-bulk-actions | 100 | no |
68+
| elasticsearch-bulk-size | 5242880 | no |
69+
| elasticsearch-bulk-flush-interval | 5s | no |
70+
| elasticsearch-bulk-workers | 1 | no |
7271
| grok-named-capture | true | no |
7372
| grok-pattern | no | no |
7473
| grok-pattern-from | no | no |
@@ -119,6 +118,22 @@ Before creating a docker container, a healthy instance of Elasticsearch service
119118
- *version* of Elasticsearch cluster
120119
- *examples*: 1, 2, 5, 6
121120

121+
###### elasticsearch-bulk-actions ######
122+
- *bulk-actions* specifies when to flush based on the number of actions currently added
123+
- *examples*: 1000
124+
125+
###### elasticsearch-bulk-workers ######
126+
- *bulk-workers* is the number of concurrent workers allowed to be executed
127+
- *examples*: 2
128+
129+
###### elasticsearch-bulk-size ######
130+
- *bulk-size* specifies when to flush based on the size (in bytes) of the actions currently added. Defaults to 5 MB and can be set to -1 to be disabled.
131+
- *examples*: 1024, -1
132+
133+
###### elasticsearch-bulk-flush-interval ######
134+
- *bulk-flush-interval* specifies when to flush at the end of the given interval
135+
- *examples*: 300ms, 1s, 2h45m
136+
122137
###### grok-pattern ######
123138
- *pattern* add customer pattern
124139
- *examples*: CUSTOM_IP=(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)

ROADMAP.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ Goals:
2323
- [ ] Add the capability of multilines for Java Exceptions
2424
- [X] Add HTTPS Support and Skip Certificate Verify
2525
- [ ] Buffer logs into a file, if elasticsearch crashes. Add buffer size as well.
26-
- [ ] Implement bulk inserts
27-
- [ ] Implement queue size and batch size
2826
- [ ] if queue is full, then write to file
2927
- [ ] if file buffer is full, discard messages
28+
- [X] Implement bulk inserts
29+
- [X] Implement queue size and batch size
30+
- [X] if number of requests or batch size have been reached, send messages to elasticsearch
3031
- [ ] Implement Readlog capability
3132
- [X] Implement grok for parsing docker logs
3233
- [ ] Add CONTRIBUTING file

pkg/docker/config.go

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net/url"
77
"strconv"
88
"strings"
9+
"time"
910

1011
"github.com/docker/docker/daemon/logger"
1112
)
@@ -23,9 +24,20 @@ type LogOpt struct {
2324
sniff bool
2425
insecure bool
2526

27+
Bulk
28+
2629
Grok
2730
}
2831

32+
// Bulk configures the Bulk Processor Service
33+
type Bulk struct {
34+
workers int
35+
actions int
36+
size int
37+
flushInterval time.Duration
38+
stats bool
39+
}
40+
2941
// Grok ...
3042
type Grok struct {
3143
grokPattern string
@@ -46,6 +58,14 @@ func defaultLogOpt() *LogOpt {
4658
sniff: true,
4759
insecure: false,
4860

61+
Bulk: Bulk{
62+
workers: 1,
63+
actions: 100,
64+
size: 5 << 20,
65+
flushInterval: 5 * time.Second,
66+
stats: false,
67+
},
68+
4969
Grok: Grok{
5070
grokPatternSplitter: " and ",
5171
grokNamedCapture: true,
@@ -139,6 +159,38 @@ func (c *LogOpt) validateLogOpt(cfg map[string]string) error {
139159
return fmt.Errorf("error: parsing elasticsearch-timeout: %q", err)
140160
}
141161
c.timeout = timeout
162+
163+
case "elasticsearch-bulk-workers":
164+
workers, err := strconv.Atoi(v)
165+
if err != nil {
166+
return fmt.Errorf("error: parsing elasticsearch-bulk-workers: %q", err)
167+
}
168+
c.Bulk.workers = workers
169+
case "elasticsearch-bulk-actions":
170+
actions, err := strconv.Atoi(v)
171+
if err != nil {
172+
return fmt.Errorf("error: parsing elasticsearch-bulk-actions: %q", err)
173+
}
174+
c.Bulk.actions = actions
175+
case "elasticsearch-bulk-size":
176+
size, err := strconv.Atoi(v)
177+
if err != nil {
178+
return fmt.Errorf("error: parsing elasticsearch-bulk-size: %q", err)
179+
}
180+
c.Bulk.size = size
181+
case "elasticsearch-bulk-flush-interval":
182+
flushInterval, err := time.ParseDuration(v)
183+
if err != nil {
184+
return fmt.Errorf("error: parsing elasticsearch-bulk-flush-interval: %q", err)
185+
}
186+
c.Bulk.flushInterval = flushInterval
187+
case "elasticsearch-bulk-stats":
188+
stats, err := strconv.ParseBool(v)
189+
if err != nil {
190+
return fmt.Errorf("error: parsing elasticsearch-bulk-stats: %q", err)
191+
}
192+
c.Bulk.stats = stats
193+
142194
case "grok-pattern":
143195
c.grokPattern = v
144196
case "grok-pattern-from":
@@ -153,7 +205,8 @@ func (c *LogOpt) validateLogOpt(cfg map[string]string) error {
153205
return fmt.Errorf("error: parsing grok-named-capture: %q", err)
154206
}
155207
c.grokNamedCapture = s
156-
// case "tag":
208+
209+
// case "tag":
157210
// case "labels":
158211
// case "env":
159212
default:

0 commit comments

Comments
 (0)