Skip to content

Commit 73c8ec4

Browse files
authored
Merge pull request #91 from rchicoli/rewrite-bulk
reuse bulk processor, but leave custom too
2 parents 15336c3 + 0106a4c commit 73c8ec4

File tree

20 files changed

+1645
-129
lines changed

20 files changed

+1645
-129
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ matrix:
5858
- stage: release
5959
# env: MAJOR_RELEASE=true
6060
# it would be nice to map github labels instead
61-
# env: RELEASE_TAG=0.4.0
61+
env: RELEASE_TAG=0.5.0
6262
if: type IN (push)
6363
script:
6464
- ./scripts/git-release.sh

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@ SCRIPTS_DIR ?= $(BASE_DIR)/scripts
99
TESTS_DIR ?= $(BASE_DIR)/tests
1010

1111
CLIENT_VERSION ?= 5
12+
DEBUG_LEVEL ?= debug
13+
TZ ?= Europe/Berlin
1214

1315
SHELL := /bin/bash
1416
SYSCTL := $(shell which sysctl)
1517
DOCKER_COMPOSE := $(shell which docker-compose)
1618

1719
.PHONY: all
1820

19-
all: clean docker_build plugin_create plugin_enable clean
21+
all: clean docker_build plugin_create plugin_set plugin_enable clean
2022

2123
local: clean build unit_tests plugin_create plugin_set plugin_enable clean
2224

@@ -62,7 +64,7 @@ plugin_push:
6264

6365
plugin_set:
6466
@echo ""
65-
docker plugin set $(PLUGIN_NAME):$(PLUGIN_TAG) LOG_LEVEL=debug
67+
docker plugin set $(PLUGIN_NAME):$(PLUGIN_TAG) LOG_LEVEL=$(DEBUG_LEVEL) TZ=$(TZ)
6668

6769
push: plugin_push
6870

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Before creating a docker container, a healthy instance of Elasticsearch service
6363
| elasticsearch-insecure | false | no |
6464
| elasticsearch-password | no | no | |
6565
| elasticsearch-sniff | yes | no | |
66-
| elasticsearch-timeout | 1 | no |
66+
| elasticsearch-timeout | 10s | no |
6767
| elasticsearch-type | log | no |
6868
| elasticsearch-username | no | no | |
6969
| elasticsearch-url | no | yes |
@@ -119,7 +119,7 @@ Interpreted sequences are:
119119

120120
###### elasticsearch-timeout ######
121121
- *timeout* maximum time in seconds that a connection is allowed to take
122-
- *example*: 10
122+
- *examples*: 300ms, 1s, 2h45m
123123

124124
###### elasticsearch-fields ######
125125
- *fields* to log to Elasticsearch Cluster
@@ -185,14 +185,13 @@ $ docker run --rm -ti \
185185
--log-opt elasticsearch-sniff=false \
186186
--log-opt elasticsearch-index=docker-%F \
187187
--log-opt elasticsearch-type=log \
188-
--log-opt elasticsearch-timeout=10 \
188+
--log-opt elasticsearch-timeout=60s \
189189
--log-opt elasticsearch-version=5 \
190190
--log-opt elasticsearch-fields=containerID,containerName,containerImageID,containerImageName,containerCreated \
191191
--log-opt elasticsearch-bulk-workers=1 \
192192
--log-opt elasticsearch-bulk-actions=1000 \
193193
--log-opt elasticsearch-bulk-size=1024 \
194194
--log-opt elasticsearch-bulk-flush-interval=1s \
195-
--log-opt elasticsearch-bulk-stats=false \
196195
alpine echo -n "this is a test logging message"
197196
```
198197

pkg/docker/config.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type Configuration struct {
1616
index string
1717
tzpe string
1818
url string
19-
timeout int
19+
timeout time.Duration
2020
fields string
2121
version string
2222
username string
@@ -35,7 +35,7 @@ type Bulk struct {
3535
actions int
3636
size int
3737
flushInterval time.Duration
38-
stats bool
38+
// stats bool
3939
}
4040

4141
// Grok filter
@@ -51,7 +51,7 @@ func newConfiguration() Configuration {
5151
return Configuration{
5252
index: "docker-%Y.%m.%d",
5353
tzpe: "log",
54-
timeout: 1,
54+
timeout: 10 * time.Second,
5555
fields: "containerID,containerName,containerImageName,containerCreated",
5656
version: "5",
5757
sniff: true,
@@ -60,9 +60,9 @@ func newConfiguration() Configuration {
6060
Bulk: Bulk{
6161
workers: 1,
6262
actions: 100,
63-
size: 5 << 20,
63+
size: 5 << 20, // 5 MB = 0101 0000 0000 0000 0000 0000 = 5242880
6464
flushInterval: 5 * time.Second,
65-
stats: false,
65+
// stats: false,
6666
},
6767

6868
Grok: Grok{
@@ -153,7 +153,7 @@ func (c *Configuration) validateLogOpt(cfg map[string]string) error {
153153
return fmt.Errorf("error: elasticsearch-version not supported: %s", v)
154154
}
155155
case "elasticsearch-timeout":
156-
timeout, err := strconv.Atoi(v)
156+
timeout, err := time.ParseDuration(v)
157157
if err != nil {
158158
return fmt.Errorf("error: parsing elasticsearch-timeout: %q", err)
159159
}
@@ -183,12 +183,12 @@ func (c *Configuration) validateLogOpt(cfg map[string]string) error {
183183
return fmt.Errorf("error: parsing elasticsearch-bulk-flush-interval: %q", err)
184184
}
185185
c.Bulk.flushInterval = flushInterval
186-
case "elasticsearch-bulk-stats":
187-
stats, err := strconv.ParseBool(v)
188-
if err != nil {
189-
return fmt.Errorf("error: parsing elasticsearch-bulk-stats: %q", err)
190-
}
191-
c.Bulk.stats = stats
186+
// case "elasticsearch-bulk-stats":
187+
// stats, err := strconv.ParseBool(v)
188+
// if err != nil {
189+
// return fmt.Errorf("error: parsing elasticsearch-bulk-stats: %q", err)
190+
// }
191+
// c.Bulk.stats = stats
192192

193193
case "grok-pattern":
194194
c.grokPattern = v

0 commit comments

Comments
 (0)