Commit graph

383 commits

Author SHA1 Message Date
David Glasser
917050c572 Fix stderr logging for journald and syslog
logger.PutMessage, added in #28762 (v17.04.0-ce), clears msg.Source. So journald
and syslog were treating stderr messages as if they were stdout.

Signed-off-by: David Glasser <glasser@davidglasser.net>
2017-06-26 14:37:43 -07:00
Deng Guangxing
0042f992d8 fd leak and error handling
Signed-off-by: Deng Guangxing <dengguangxing@huawei.com>
2017-06-23 15:38:35 +08:00
Royce Remer
b3add005d5 * standardize timeouts for log reads and writes for logger adapter tests
* use an assertion framework in logger adapter tests

Signed-off-by: Royce Remer <royceremer@gmail.com>
2017-06-18 18:47:45 -07:00
Peter Bücker
e908e1a357 Logging driver should receive same file in start/stop request
Signed-off-by: Peter Bücker <peter.buecker@gmail.com>
2017-06-08 10:05:52 +02:00
Victor Vieux
2445e6b99d move multireader out of /pkg
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
2017-06-01 16:22:00 -07:00
Sebastiaan van Stijn
07b51ed300 Don't log error if file is already closed
When closing the log-file, and the file is already
closed, there's no need to log an error.

This patch adds a `closed` boolean to check if the
file was closed, and if so, skip closing the file.
This prevents errors like this being logged:

    level=error msg="Error closing logger: invalid argument"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-05-29 17:42:37 +02:00
YAMASAKI Masahide
524f306340 Improved poor memory efficiency of awslogs
Signed-off-by: YAMASAKI Masahide <masahide.y@gmail.com>
2017-05-18 23:30:00 +09:00
gkze
d42c268fc3 GCP Logs: send log line as jsonPayload.message instead of jsonPayload.data
Signed-off-by: gkze <george@bugsnag.com>
2017-05-15 16:35:53 -07:00
Justin Menga
dc87490b63 Update comments describing new behaviour
Signed-off-by: Justin Menga <justin.menga@gmail.com>
2017-05-15 11:08:16 +12:00
Justin Menga
3a4cf2b076 Code review changes
Signed-off-by: Justin Menga <justin.menga@gmail.com>
2017-05-15 10:28:18 +12:00
Justin Menga
bf1c377f60 Add missing month in datetime map
Signed-off-by: Justin Menga <justin.menga@gmail.com>
2017-05-13 22:10:51 +12:00
Justin Menga
4374f16667 Append new line to multiline events
Signed-off-by: Justin Menga <justin.menga@gmail.com>
2017-05-13 17:54:04 +12:00
Justin Menga
8ef9c19ecd Code review changes
Signed-off-by: Justin Menga <justin.menga@gmail.com>
2017-05-13 17:54:04 +12:00
Tibor Vass
f775005a17 awslogs: use github.com/pkg/errors to wrap an error
Signed-off-by: Tibor Vass <tibor@docker.com>
2017-05-13 17:54:04 +12:00
Justin Menga
6f073e3522 Formatting
Signed-off-by: Justin Menga <justin.menga@gmail.com>
2017-05-13 17:54:04 +12:00
Justin Menga
84b03660da Add awslogs benchmarks
Signed-off-by: Justin Menga <justin.menga@gmail.com>
2017-05-13 17:54:04 +12:00
Justin Menga
ab74038df9 Add awslogs multiline support
Signed-off-by: Justin Menga <justin.menga@gmail.com>
2017-05-13 17:54:04 +12:00
Grzegorz Jaśkiewicz
d925e50470 gcplogging driver MRPB set
Signed-off-by: Grzegorz Jaśkiewicz <gj.jaskiewicz@gmail.com>
2017-05-09 14:24:43 +02:00
Tõnis Tiigi
5eca7f7c5d Merge pull request #31856 from jim-minter/more_races
Resolve a set of race conditions in logging and attaching code
2017-04-26 16:04:02 -07:00
Jim Minter
4fdb17c777 Prevent ContainerLogs from hanging if container doesn't run for long
Signed-off-by: Jim Minter <jminter@redhat.com>
2017-04-20 12:27:51 +01:00
Brian Goff
17abacb894 Add logdrivers to /info
This is required for swarmkit to be able to filter based on log driver.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-04-11 18:07:15 -04:00
Brian Goff
27bd6842f8 Implement plugins for logging drivers
Logging plugins use the same HTTP interface as other plugins for basic
command operations meanwhile actual logging operations are handled (on
Unix) via a fifo.

The plugin interface looks like so:

```go
type loggingPlugin interface {
  StartLogging(fifoPath string, loggingContext Context) error
  StopLogging(fifoPath)
```

This means a plugin must implement `LoggingDriver.StartLogging` and
`LoggingDriver.StopLogging` endpoints and be able to consume the passed
in fifo.

Logs are sent via stream encoder to the fifo encoded with protobuf.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-04-10 13:17:20 -04:00
Drew Erny
1044093bb0 refactor logs and support service logs /w tty
Refactor container logs system to make communicating log messages
internally much simpler. Move responsibility for marshalling log
messages into the REST server. Support TTY logs. Pave the way for fixing
the ambiguous bytestream format. Pave the way for fixing details.

Signed-off-by: Drew Erny <drew.erny@docker.com>
2017-04-06 17:54:11 -07:00
Brian Goff
1325f667ee Merge pull request #27565 from rothrock/env-by-regex
[splunk] Use a regex to match environment variables
2017-03-31 10:46:48 -04:00
Sebastiaan van Stijn
57fd478169 Merge pull request #31083 from xulike666/fight-for-readability
fix some typos from module contrib to man
2017-03-03 15:13:01 +01:00
Akihiro Suda
a6576b8a2b Merge pull request #31212 from fate-grand-order/fixed
use t.Fatal() to output the err message and fix typo
2017-02-27 12:26:35 +09:00
fate-grand-order
2a8d6368d4 use t.Fatal() to output the err message where the values used for formatting
text does not appear to contain a placeholder

Signed-off-by: Helen Xie <chenjg@harmonycloud.cn>
2017-02-23 10:16:22 +08:00
Alexander Morozov
b3e7f70137 Merge pull request #31263 from nalind/journal-doublefree
Synchronize the cursor returned by followJournal
2017-02-22 17:45:49 -08:00
Nalin Dahyabhai
d57c330617 Synchronize the cursor returned by followJournal
Make sure that the cursor value returned by followJournal() is the last
of the values returned by its goroutine's calls to drainJournal() by
waiting for it, rather than returning a value that may be superceded by
another if we're singalling the goroutine that it should exit by closing
a pipe.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2017-02-22 16:22:00 -05:00
Kenfe-Mickael Laventure
81630df854 Prevent freeing a possible invalid pointer from journald
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-02-22 07:54:10 -08:00
Aaron.L.Xu
e0577d5fe8 fix some typos from module contrib to man
Signed-off-by: Aaron.L.Xu <likexu@harmonycloud.cn>
2017-02-18 10:08:55 +08:00
Brian Goff
7a179972ff Fix cpu spin waiting for log write events
This loop is not ever going to return since it's never actually setting
the `err` var except on the first iteration.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-02-15 21:41:32 -05:00
Vincent Demeester
14790e4008 Merge pull request #30694 from godefroi/26937-fix-rfc5424-log-format-1
Add NILVALUE for STRUCTURED-DATA in RFC5424 logs
2017-02-07 23:22:39 +01:00
Alexander Morozov
d38753303a Merge pull request #30136 from tg123/master
Windows: return err instead of panic when convert string to utf16
2017-02-06 14:00:00 -08:00
Mark Parker
b7d802bbcc Add NILVALUE for STRUCTURED-DATA in RFC5424 logs
RFC 5424 (https://tools.ietf.org/html/rfc5424#section-6.2) requires that
STRUCTURED-DATA be present, either as NILVALUE (-) or as one or more
SD-ELEMENT items. Because Docker doesn't ever create any SD-ELEMENT items,
the format should output the NILVALUE instead. This resolves parsing issues
in various RFC 5424-compliant syslog servers.

Signed-off-by: Mark Parker <godefroi@gmail.com>
2017-02-02 15:16:14 -07:00
Brian Goff
3f4fccb65f Use sync.Pool for logger Messages
This reduces allocs and bytes used per log entry significantly as well
as some improvement to time per log operation.

Each log driver, however, must put messages back in the pool once they
are finished with the message.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-02-01 13:52:37 -05:00
Brian Goff
054abff3b6 Implement optional ring buffer for container logs
This allows the user to set a logging mode to "blocking" (default), or
"non-blocking", which uses the ring buffer as a proxy to the real log
driver.

This allows a container to never be blocked on stdio at the cost of
dropping log messages.

Introduces 2 new log-opts that works for all drivers, `log-mode` and
`log-size`. `log-mode` takes a  value of "blocking", or "non-blocking"
I chose not to implement this as a bool since it is difficult to
determine if the mode was set to false vs just not set... especially
difficult when merging the default daemon config with the container config.
`log-size` takes a size string, e.g. `2MB`, which sets the max size
of the ring buffer. When the max size is reached, it will start
dropping log messages.

```
BenchmarkRingLoggerThroughputNoReceiver-8           	2000000000	        36.2 ns/op	 856.35 MB/s	       0 B/op	       0 allocs/op
BenchmarkRingLoggerThroughputWithReceiverDelay0-8   	300000000	       156 ns/op	 198.48 MB/s	      32 B/op	       0 allocs/op
BenchmarkRingLoggerThroughputConsumeDelay1-8        	2000000000	        36.1 ns/op	 857.80 MB/s	       0 B/op	       0 allocs/op
BenchmarkRingLoggerThroughputConsumeDelay10-8       	1000000000	        36.2 ns/op	 856.53 MB/s	       0 B/op	       0 allocs/op
BenchmarkRingLoggerThroughputConsumeDelay50-8       	2000000000	        34.7 ns/op	 894.65 MB/s	       0 B/op	       0 allocs/op
BenchmarkRingLoggerThroughputConsumeDelay100-8      	2000000000	        35.1 ns/op	 883.91 MB/s	       0 B/op	       0 allocs/op
BenchmarkRingLoggerThroughputConsumeDelay300-8      	1000000000	        35.9 ns/op	 863.90 MB/s	       0 B/op	       0 allocs/op
BenchmarkRingLoggerThroughputConsumeDelay500-8      	2000000000	        35.8 ns/op	 866.88 MB/s	       0 B/op	       0 allocs/op
```

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2017-02-01 13:52:37 -05:00
Alexander Morozov
dc78b3a1d4 Merge pull request #29863 from ncdc/journald-logdriver-drain-one-more-time-after-follow-ends
journald logs: drain 1 more time at container exit
2017-02-01 10:30:14 -08:00
Yong Tang
864b0c2e47 Support of CreateLogGroup for awslogs
This fix tries to address the issue raised in 29344 where it was
not possible to create log group for awslogs (CloudWatch) on-demand.
Log group has to be created explicitly before container is running.

This behavior is inconsistent with AWS logs agent where log groups
are always created as needed.

There were several concerns previously (See comments in 19617 and 29344):
1. There is a limit of 500 log groups/account/region so resource might
be exhausted if there is any typo or incorrect region.
2. Logs are generated for every container so CreateLogGroup (or equally,
DescribeLogGroups) might be called every time, which is redundant and
potentially surprising.
3. CreateLogStream and CreateLogGroup have different IAM policies.

This fix addresses the issue by add `--log-opt awslogs-create-group`
which by default is `false`. It requires user to explicitly request
that log groups be created as needed.

Related unit test has been updated. And tests have also been done
manually in AWS.

This fix fixes 29334.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-01-27 11:15:17 -08:00
Andy Goldstein
76f58d7294 journald logs: drain 1 more time at container exit
In the journald log driver, attempt to drain the journal 1 more time
after being told to stop following the log. Due to a possible race
condition, sometimes data is written to the journal at almost the same
time the log watch is closed, and depending on the order of operations,
sometimes you miss the last journal entry.

Signed-off-by: Andy Goldstein <agoldste@redhat.com>
2017-01-25 09:29:21 -05:00
Joseph Rothrock
9758a2a724 Use a regex to match environment variables #27565
Signed-off-by: Joseph Rothrock <rothrock@rothrock.org>
2017-01-19 15:30:11 -08:00
Kenfe-Mickael Laventure
fb2bb3653e Close logwatcher on context cancellation
This commit addresses 2 issues:

  1. in `tailfile()` if somehow the `logWatcher.Msg` were to become full and the watcher closed before space was made into it, we were getting stuck there forever since we were not checking for the watcher getting closed
  2. when servicing `docker logs`, if the command was cancelled we were not closing the watcher (and hence notifying it to stop copying data)

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2017-01-17 14:36:13 -08:00
Boshi Lian
1c770c6d8c return err instead of panic when convert string to utf16
Signed-off-by: Boshi Lian <farmer1992@gmail.com>
2017-01-14 02:21:22 +08:00
yupengzte
230b7c2e4c fix syscall.GUID composite literal uses unkeyed fields
Signed-off-by: yupengzte <yu.peng36@zte.com.cn>
2017-01-03 17:12:15 +08:00
Sebastiaan van Stijn
a331056268 Merge pull request #28852 from miaoyq/rename-log-context
Rename 'context' to 'loginfo' in the logger module
2016-12-30 01:13:49 +01:00
Yanqiang Miao
17ec911da7 Rename 'context' to 'loginfo' in the logger module
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

gofmt

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

update

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

remove 'api/types/container/config.go' from this PR

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

change 'LogInfo' to 'Info'

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

update

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
2016-12-29 19:13:44 +08:00
Akihiro Suda
b86e3bee5a gcplogs: forcibly set HOME on static UNIX binary
Fix #29344

If HOME is not set, the gcplogs logging driver will call os/user.Current() via oauth2/google.
However, in static binary, os/user.Current() leads to segfault due to a glibc issue that won't be fixed
in a short term. (golang/go#13470, https://sourceware.org/bugzilla/show_bug.cgi?id=19341)
So we forcibly set HOME so as to avoid call to os/user/Current().

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2016-12-29 03:17:26 +00:00
Brian Goff
b0aab6e83e Merge pull request #29475 from AkihiroSuda/vendor-oauth2-3
Vendor gcplogs deps
2016-12-28 11:55:03 -05:00
Sebastiaan van Stijn
b9ee31ae02 Merge pull request #29314 from vdemeester/no-more-utils
Remove the utils package
2016-12-22 15:21:05 +01:00
Sebastiaan van Stijn
05dc9846e1
remove client-side for supported logging drivers
The `docker logs` command performed a
client-side check if the container's
logging driver was supported.

Now that we allow the client to connect
to both "older" and "newer" daemon versions,
this check is best done daemon-side.

This patch remove the check on the client
side, and leaves validation to the daemon,
which should be the source of truth.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2016-12-19 14:30:01 +01:00
Akihiro Suda
ff2f875574 vendor: google.golang.org/cloud -> cloud.google.com/go
Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2016-12-16 08:36:18 +00:00
unclejack
3a42518042 daemon: return directly without ifs where possible
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
2016-12-14 22:36:58 +02:00
Vincent Demeester
04f7a03359
Move templates to pkg/templates
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2016-12-12 09:34:03 +01:00
Alexander Morozov
6151ad19ad Merge pull request #28797 from miaoyq/fix-a-err-of-logger
Fix a error of the function 'CopyMessage' in 'daemon/logger/logger.go'
2016-11-30 13:27:40 -08:00
Antonio Murdaca
022c13271b Merge pull request #28829 from lixiaobing10051267/masterDaemon
check typos and fix in daemon directory
2016-11-26 14:33:09 +01:00
lixiaobing10051267
cf4f5b4771 check typos and fix in daemon directory
Signed-off-by: lixiaobing10051267 <li.xiaobing1@zte.com.cn>

Signed-off-by: lixiaobing10051267 <li.xiaobing1@zte.com.cn>
2016-11-26 17:23:21 +08:00
Yanqiang Miao
3b82eac65f Fix a error of the function 'CopyMessage' in 'daemon/logger/logger.go'
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

add a test for 'CopyMessage'

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

update

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
2016-11-24 20:08:54 +08:00
Yanqiang Miao
52fd6e4664 Optimize the function 'Context.Name()' and replace 'Context.ContainerName' that need to remove slash with 'Context.Name()'.
Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

update

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>

update

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
2016-11-24 09:24:29 +08:00
Darren Stahl
22c83c567f Swap usage of LazyDLL and LoadDLL to LazySystemDLL.
Signed-off-by: Darren Stahl <darst@microsoft.com>
2016-11-22 14:57:11 -08:00
lixiaobing10051267
320c93824b function TestCreateSuccess uses a wrong variable LogGroupName
Signed-off-by: lixiaobing10051267 <li.xiaobing1@zte.com.cn>
2016-11-16 16:48:36 +08:00
Sebastiaan van Stijn
806f09bf32 Merge pull request #26088 from akirakoyasu/patch-fluent-unixsocket
Proposal: unix-sockets support in Fluentd logging driver
2016-11-09 12:49:06 +01:00
Silvan Jegen
d359daaa48 Clean up journald logger
We clean up the journald logger with these four changes.

1. Make field array static
2. Make function name more appropriate
3. Initialize the file descriptors only once
4. Avoid copying the journald cursor

Point 4 is the most significant change: instead of treating the journald
cursor like a Go string we use it as a raw C.char pointer. That way we
avoid the copying by the C.CString and C.GoString functions.

Signed-off-by: Silvan Jegen <s.jegen@gmail.com>
2016-11-08 19:09:59 +01:00
Vincent Demeester
9f7cc7d032 Merge pull request #28035 from thaJeztah/add-test-for-long-loglines
add tests for long log-lines and trailing lines
2016-11-04 07:59:20 +01:00
Alexander Morozov
c072347078 Merge pull request #27912 from LK4D4/vndr
project: use vndr for vendoring
2016-11-03 18:30:19 -07:00
Alexander Morozov
f2614f2107 project: use vndr for vendoring
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-11-03 15:31:46 -07:00
French Ben
3661510f7f Updated AWS logstream to understand tags
Signed-off-by: French Ben <frenchben@docker.com>
2016-11-03 13:49:40 -07:00
Sebastiaan van Stijn
ee34dd9f8a
add tests for long log-lines and trailing lines
this adds new tests to test logging of long log-lines
(without newlines), and trailing log-lines.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2016-11-03 10:01:00 -07:00
milindchawre
3463bbcc71 Fixes #21803 : Removing unused configuration in daemon/logger/fluentd
Signed-off-by: milindchawre <milindchawre@gmail.com>
2016-11-02 11:11:02 +00:00
Tom Booth
a69a59ffc7 Decouple removing the fileWatcher from reading
Fixes #27779

Currently `followLogs` can get into a deadlock if we receive an inotify
IN_MODIFY event while we are trying to close the `fileWatcher`. This is
due to the fact that closing the `fileWatcher` happens in the same block
as consumes events from the `fileWatcher`. We are trying to run
`fileWatcher.Close`, which is waiting for an IN_IGNORE event to come in
over inotify to confirm the watch was been removed. But, because an
IN_MODIFY event has appeared after `Close` was entered but before the
IN_IGNORE, the broadcast never comes. The IN_MODIFY cannot be consumed
as the events channel is unbuffered and the only `select` that reads
from it is busy waiting for the IN_IGNORE event.

In order to try and fix this race condition I've moved the removal of
the `fileWatcher` out to a separate go block that waits for a signal to
close, removes the watcher and then signals to the previous selects on
the close signal.

This has introduced a `fileWatcher.Remove` in the final case, but if we
try and remove a watcher that does not exist it will just return an
error saying so. We are not doing any checking on the return of `Remove`
so this shouldn't cause any side-effects.

Signed-off-by: Tom Booth <tombooth@gmail.com>
2016-10-28 10:53:38 +01:00
Tom Booth
6314bec641 Do not directly cast io.ReadSeeker to io.Reader
`golint` had the following issue when linting this file:

```
daemon/logger/jsonfilelog/read.go:116:10: should omit type io.Reader
from declaration of var rdr; it will be inferred from the right-hand
side
```

In order to keep it happy changing it to an indirect assignment will
still maintain the same functionality.

Signed-off-by: Tom Booth <tombooth@gmail.com>
2016-10-26 17:37:48 +01:00
Akira Koyasu
cb176c848e add scheme to fluentd-address
Signed-off-by: Akira Koyasu <mail@akirakoyasu.net>

- add scheme to fluentd-address
- define a new type `location`
- use `errors.Wrapf`
2016-10-26 03:36:51 +09:00
Sebastiaan van Stijn
24582e8153 Merge pull request #27471 from caarlos0/logentries
Added Logentries Driver
2016-10-18 01:33:28 -07:00
Elena Morozova
64238fef8c all: replace loop with single append
Signed-off-by: Elena Morozova <lelenanam@gmail.com>
2016-10-13 13:31:52 -07:00
Carlos Alexandro Becker
2764d67c3a
added logentries driver
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2016-10-06 22:48:53 -03:00
Michael Crosby
efe4e914ef Merge pull request #26207 from splunk/splunk-logging-driver-performance-improvements
Splunk Logging Driver performance improvements
2016-09-16 10:22:09 -07:00
Denis Gladkikh
4907cc7793 Splunk Logging Driver performance improvements
New driver options:

- `splunk-gzip` - gzip compress all requests to Splunk HEC
(enabled by default)
- `splunk-gzip-level` - change compression level.

Messages are sent in batches by 1000, with frequency of 5 seconds.
Maximum buffer is 10,000 events. If HEC will not be available, Splunk
Logging Driver will keep retrying while it can hold messages in buffer.

Added unit tests for driver.

Signed-off-by: Denis Gladkikh <denis@gladkikh.email>
2016-09-12 09:00:16 -07:00
Sven Dowideit
5be6ccc433 Merge pull request #24586 from farcaller/gcplogs
Added optional flags to init gcp logger metadata
2016-09-08 13:47:48 +10:00
Brian Goff
2c91c5fdad Merge pull request #25736 from mwieczorek/25689-enable-syslog-driver-on-windows
Enable syslog driver for windows
2016-08-29 17:46:12 -04:00
Aaron Lehmann
cbd4e4d48a Merge pull request #24514 from cpuguy83/fix_log_follow_rotate
Fix issues with tailing rotated jsonlog file
2016-08-26 09:47:40 -07:00
Brian Goff
15f3d060ac Merge pull request #24153 from frodenas/syslog-fix
Syslog Driver: RFC 5425 Message Framing should be used only when protocol is TCP+TLS
2016-08-25 12:15:06 -04:00
Denis Gladkikh
9407322972 Splunk Logging Driver: PR feedback
Signed-off-by: Denis Gladkikh <denis@gladkikh.email>
2016-08-18 09:17:06 -07:00
Michal Wieczorek
eac70703e3 Enable syslog driver for windows
Signed-off-by: Michal Wieczorek <wieczorek-michal@wp.pl>
2016-08-17 22:26:24 +02:00
Denis Gladkikh
603fd08315 Splunk Logging Driver: formats and verifyconnection
`--log-opt splunk-format=inline|json|raw` allows to change how logging
driver sends data to Splunk, where

`inline` - default value, format used before, message is injected as a
line in JSON payload
`json` - driver will try to parse each line as a JSON object and embed it
inside of the JSON payload
`raw` - driver will send Raw payload instead of JSON, tag and attributes
will be prefixed before the message

`--log-opt splunk-verify-connection=true|false` - allows to skip
verification for Splunk Url

Signed-off-by: Denis Gladkikh <denis@gladkikh.email>
2016-08-16 21:45:16 -07:00
Brian Goff
84e60a7e10 Fix issues with tailing rotated jsonlog file
Fixes a race where the log reader would get events for both an actual
rotation as we from fsnotify (`fsnotify.Rename`).
This issue becomes extremely apparent when rotations are fast, for
example:

```
$ docker run -d --name test --log-opt max-size=1 --log-opt max-file=2
busybox sh -c 'while true; do echo hello; usleep 100000; done'
```

With this change the log reader for jsonlogs can handle rotations that
happen as above.

Instead of listening for both fs events AND rotation events
simultaneously, potentially meaning we see 2 rotations for only a single
rotation due to channel buffering, only listen for fs events (like
`Rename`) and then wait to be notified about rotation by the logger.
This makes sure that we don't see 2 rotations for 1, and that we don't
start trying to read until the logger is actually ready for us to.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-08-15 13:57:28 -04:00
Brian Goff
c6e3818dd1 Merge pull request #24814 from samuelkarp/awslogs
awslogs: Record log line insert order for sorting
2016-08-12 15:51:06 -04:00
allencloud
0ead624473 add defer file.Close to avoid potential fd leak
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-08-10 08:36:09 +08:00
Yong Tang
9528ea930c Sanitize docker labels when used as journald field names
This fix tries to address the issue raised in #23528 where
docker labels caused journald log error because journald
has special requirements on field names.

This fix addresses this issue by sanitize the labels per
requirements of journald.

Additional unit tests have been added to cover the changes.

This fix fixes #23528.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-08-05 15:20:47 -07:00
Samuel Karp
443f251cf5 awslogs: Record log line insert order for sorting
Fixes https://github.com/docker/docker/issues/24775

Signed-off-by: Samuel Karp <skarp@amazon.com>
2016-08-03 10:04:20 -07:00
Samuel Karp
5ba6cab0a9 awslogs: Add unit test to ensure log line order
Signed-off-by: Samuel Karp <skarp@amazon.com>
2016-08-03 10:01:12 -07:00
Sebastiaan van Stijn
48569e0a35 Merge pull request #22911 from vdemeester/20033-default-logging-tag-value
Standardize default logging tag value
2016-07-29 02:18:57 +02:00
Alexander Morozov
e43033bc23 Merge pull request #22982 from nalind/log-newlines
Improve logging of long log lines
2016-07-28 16:41:01 -07:00
Vladimir Pouzanov
71f2999764 Added optional flags to init gcp logger metadata
Signed-off-by: Vladimir Pouzanov <farcaller@google.com>
2016-07-13 13:56:18 +01:00
Ferran Rodenas
4039bfc917 Syslog Driver: RFC 5425 Framing should be used only when protocol is TCP+TLS
Signed-off-by: Ferran Rodenas <frodenas@gmail.com>
2016-06-29 15:41:10 -07:00
Alexander Morozov
378f0657f9 daemon/logger: fix races in channel close
it's actually not okay to do such trick from multiple goroutines

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-06-27 14:14:23 -07:00
Stefan J. Wernli
54f11b84d2 Fixing file handle leak for "docker logs"
If "docker logs" was used on an offline container, the logger is leaked, leaving it up to the finalizer to close the file handle, which could block removal of the container.  Further, the json file logger could leak an open handle if the logs are read without follow due to an early return without a close.  This change addresses both cases.

Signed-off-by: Stefan J. Wernli <swernli@microsoft.com>
2016-06-21 18:40:30 -07:00
Nalin Dahyabhai
513ec73831 Improve logging of long log lines
This change updates how we handle long lines of output from the
container.  The previous logic used a bufio reader to read entire lines
of output from the container through an intermediate BytesPipe, and that
allowed the container to cause dockerd to consume an unconstrained
amount of memory as it attempted to collect a whole line of output, by
outputting data without newlines.

To avoid that, we replace the bufio reader with our own buffering scheme
that handles log lines up to 16k in length, breaking up anything longer
than that into multiple chunks.  If we can dispense with noting this
detail properly at the end of output, we can switch from using
ReadBytes() to using ReadLine() instead.  We add a field ("Partial") to
the log message structure to flag when we pass data to the log driver
that did not end with a newline.

The Line member of Message structures that we pass to log drivers is now
a slice into data which can be overwritten between calls to the log
driver's Log() method, so drivers which batch up Messages before
processing them need to take additional care: we add a function
(logger.CopyMessage()) that can be used to create a deep copy of a
Message structure, and modify the awslogs driver to use it.

We update the jsonfile log driver to append a "\n" to the data that it
logs to disk only when the Partial flag is false (it previously did so
unconditionally), to make its "logs" output correctly reproduce the data
as we received it.

Likewise, we modify the journald log driver to add a data field with
value CONTAINER_PARTIAL_MESSAGE=true to entries when the Partial flag is
true, and update its "logs" reader to refrain from appending a "\n" to
the data that it retrieves if it does not see this field/value pair (it
also previously did this unconditionally).

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> (github: nalind)
2016-06-14 14:11:47 -04:00
Nalin Dahyabhai
af439c7a8d Add a benchmark for logger.Copier
Add a benchmark for measuring how the logger.Copier implementation
handles logged lines of sizes ranging up from 64 bytes to 256KB.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2016-06-09 09:47:13 -04:00
Brian Goff
3f970819bb Merge pull request #23063 from yongtang/22961-aws-sdk-go
Update aws-sdk-go to v1.1.30
2016-06-05 16:01:52 -04:00
Vincent Demeester
f900e1cf47
Standardize default logging tag value
Use the same default tag value for all loggers that support tags.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2016-06-04 12:38:12 +02:00
Sven Dowideit
98c245c9e6 Merge pull request #23193 from allencloud/fix-typos
use grep to find all a/an typos
2016-06-02 18:45:08 -07:00
Nalin Dahyabhai
0da0a8f9da Add support for reading journal extras and in UTC
When told to read additional attributes from logs that we've sent to the
journal, pull out all of the non-trusted, non-user fields that we didn't
hard-code ourselves.  More of PR#20726 and PR#21889.

When reading entries in the journald log reader, set the time zone on
timestamps that we read to UTC, so that we send UTC values to the client
instead of values that are local to whatever timezone dockerd happens to
be running in.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> (github: nalind)
2016-06-02 10:17:07 -04:00
allencloud
c1be45fa38 fix typos
Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-06-02 17:17:22 +08:00
Akihiro Suda
518709a87e Fix the comment for daemon/logger.Copier
Now daemon/logger.Copier does not use ContainerID

Addendum to #23141

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2016-06-02 13:10:51 +09:00
Nalin Dahyabhai
7772d270c0 Remove the logger.Message ContainerID field
Log drivers are instantiated on a per-container basis, and passed the
container ID (along with other information) when they're initialized.
Drivers that care about that value are caching the value that they're
passed when they're initialized and using it in favor of the value
contained in Message structures that are passed to them, so the field in
Messages is unused, so we remove it.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2016-05-31 16:41:29 -04:00
Sebastiaan van Stijn
f3a7abee81 Merge pull request #22384 from yongtang/22358-log-tag-prefix
Remove `docker/` prefix from log messages tag.
2016-05-30 14:48:31 +02:00
Yong Tang
46ea8ff75d Fix build errors caused by update aws-sdk-go to v1.1.30
This fix tries to fix build errors caused by updating
aws-sdk-go to v1.1.30.

This fix fixes #22961.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-05-28 18:49:17 -07:00
Samuel Karp
c1ad02ccc8 awslogs: Fix a race in mockcwlogsclient
Signed-off-by: Samuel Karp <skarp@amazon.com>
2016-05-25 11:50:22 -07:00
Akihiro Suda
ab533f0651 Fix a race in daemon/logger.TestCopier
Update #22963

Signed-off-by: Akihiro Suda <suda.akihiro@lab.ntt.co.jp>
2016-05-25 05:07:24 +00:00
Yong Tang
38c49d9987 Remove docker/ prefix from log messages tag.
This fix tries to address the issue raised in #22358 where syslog's
message tag always starts with `docker/` and can not be removed
by changing the log tag templates.

The issue is that syslog driver hardcodes `path.Base(os.Args[0])`
as the prefix, which is the binary file name of the daemon (`dockerd`).
This could be an issue for certain situations (e.g., #22358) where
user may prefer not to have a dedicated prefix in syslog messages.
There is no way to override this behavior in the current verison of
the docker.

This fix tries to address this issue without making changes in the
default behavior of the syslog driver. An additional
`{{.DaemonName}}` has been introduced in the syslog tag. This is
assigned as the `docker` when daemon starts. The default log tag
template has also been changed from
`path.Base(os.Args[0]) + "/{{.ID}}"` to `{{.DaemonName}}/{{.ID}}`.
Therefore, there is no behavior changes when log-tag is not provided.

In order to be consistent, the default log tag for fluentd has been
changed from `docker.{{.ID}}` to `{{DaemonName}}.{{.ID}}` as well.

The documentation for log-tag has been updated to reflect this change.

Additional test cases have been added to cover changes in this fix.

This fix fixes #22358.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-05-12 22:29:30 -07:00
Yong Tang
a20b02b915 Remove deprecated driver specific log tags
Since 1.9, driver specific log tag options
`syslog-tag`
`gelf-tag`
`fluentd-tag`
have been deprecated in favor of the generic tag
option which is standard across different logging
drivers.

This fix removed the deprecated driver specific
log tag options of `syslog-tag`, `gelf-tag`,
`fluentd-tag` for 1.12 and updated the docs.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-05-10 07:43:44 -07:00
Brian Goff
bd9d14a07b Add support for reading logs extra attrs
The jsonlog logger currently allows specifying envs and labels that
should be propagated to the log message, however there has been no way
to read that back.

This adds a new API option to enable inserting these attrs back to the
log reader.

With timestamps, this looks like so:
```
92016-04-08T15:28:09.835913720Z foo=bar,hello=world hello
```

The extra attrs are comma separated before the log message but after
timestamps.

Without timestaps it looks like so:
```
foo=bar,hello=world hello
```

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-05-06 20:42:20 -04:00
Shijiang Wei
1790980ec6 inherit the daemon log options when creating containers
Signed-off-by: Shijiang Wei <mountkin@gmail.com>
2016-05-02 23:04:04 +08:00
Brian Goff
dbee44c9e0 Merge pull request #21613 from wzyboy/support-unixgram-syslog-address
Support unixgram syslog address
2016-04-28 11:06:17 -04:00
Zhuoyun Wei
57fad95e43
Support unixgram syslog address
- Consider unixgram:// as a valid URL prefix
- Parse unixgram:// addresses
- Update docs

Signed-off-by: Zhuoyun Wei <wzyboy@wzyboy.org>
2016-04-28 11:04:50 +08:00
Alan Scherger
f67b711277 enable syslog logger to have access to env and labels
Signed-off-by: Alan Scherger <flyinprogrammer@gmail.com>
2016-04-08 19:50:18 -05:00
Yong Tang
7581cf96fb Additional syslog-format option to allow microsecond resolution in syslog timestamp.
This fix tries to add an additional syslog-format of `rfc5424micro` which follows
the same as rfc5424 except that it use microsecond resolution for timestamp. The
purpose is to solve the issue raised in #21793 where log events might lose its
ordering if happens on the same second.

The timestamp field in rfc5424 is derived from rfc3339, though the maximium
resolution is limited to "TIME-SECFRAC" which is 6 (microsecond resolution).

The appropriate documentation (`docs/admin/logging/overview.md`) has been updated
to reflect the change in this fix.

This fix adds a unit test to cover the newly introduced format.

This fix fixes #21793.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2016-04-08 05:00:11 +00:00
Alexander Morozov
b9966f3a81 daemon: remove some unused code
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-03-31 11:24:12 -07:00
Vincent Demeester
e6f2429e01 Merge pull request #21607 from allencloud/change-validateNoSchema-to-validateNoScheme
change validateNoSchema to validateNoScheme
2016-03-31 10:14:23 +02:00
allencloud
28d3c22e55 1.change validateNoSchema into validateNoScheme
2.change schema into scheme in docs and some annotations.

Signed-off-by: allencloud <allen.sun@daocloud.io>
2016-03-31 12:29:15 +08:00
Nalin Dahyabhai
ab62ecf393 Open the journald following descriptor earlier
Following a journal log almost always requires a descriptor to be
allocated.  In cases where we're running out of descriptors, this means
we might get stuck while attempting to start following the journal, at a
point where it's too late to report it to the client and clean up
easily.  The journal reading context will cache the value once it's
allocated, so here we move the check earlier, so that we can detect a
problem when we can still report it cleanly.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2016-03-24 10:12:51 -04:00
Nalin Dahyabhai
8d597d25a8 Improve error reporting when following journals
When we set up to start following a journal, if we get error results
from sd_journal_get_fd() or sd_journal_get_events() that prevent us from
following the journal, report the error instead of just mysteriously
failing.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> (github: nalind)
2016-03-24 10:12:15 -04:00
Alexander Morozov
11b4c89087 Merge pull request #21301 from cpuguy83/cleaner_file_log
Fixes some issues with jsonfile write/read
2016-03-21 14:03:36 -07:00
Brian Goff
1ae9dcf97d Fixes some issues with jsonfile write/read
This cleans up some of the use of the filepoller which makes reading
significantly more robust and gives fewer changes to fallback to the
polling based watcher.
In a lot of cases, if the file was being rotated while we were adding it
to the watcher, it would return an error that the file doesn't exist and
would fallback.
In some cases this fallback could be triggered multiple times even if we
were already on the fallback/poll-based watcher.

It also fixes an open file leak caused by not closing files properly on
rotate, as well as not closing files that were read via the `tail`
function until after the log reader is completed.

Prior to the above changes, it was relatively simple to cause the log
reader to error out by having quick rotations, for example:
```
$ docker run --name test --log-opt max-size=10b --log-opt max-files=10
-d busybox sh -c 'while true; do usleep 500000; echo hello; done'
$ docker logs -f test
```
After these changes I can run this forever without error.

Another fix removes 2 `os.Stat` calls when rotating files. The stat
calls are not needed since we are just calling `os.Rename` anyway, which
will in turn also just produce the same error that `Stat` would.
These `Stat` calls were also quite expensive.
Removing these stat calls also seemed to resolve an issue causing slow
memory growth on the daemon.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-03-21 11:05:58 -04:00
Pierre Carrier
13086f387b fluentd logger: support all options besides Unix sockets
Mostly useful for docker/docker#19438.

Signed-off-by: Pierre Carrier <pierre@meteor.com>
2016-03-21 10:03:21 +00:00
Pierre Carrier
d89dae6e4b Revert "Added flag to ignore fluentd connect error on container start"
This reverts commit 3cf82ff1ab.

Signed-off-by: Pierre Carrier <pierre@meteor.com>
2016-03-20 16:22:19 +00:00
Nalin Dahyabhai
52c0f36f7b Fix a race in cleaning up after journald followers
When following a journal-based log, it was possible for the worker
goroutine, which reads the journal using the journal context and sends
entry data down the message channel, to be scheduled after the function
which started it had returned.  This could create problems, since the
invoking function was closing the journal context object and message
channel before it returned, which could trigger use-after-free segfaults
and write-to-closed-channel panics in the worker goroutine.

Make the cleanup in the invoking function conditional so that it's only
done when we're not following the logs, and if we are, that it's left to
the worker goroutine to close them.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> (github: nalind)
2016-03-17 18:36:21 -04:00
Nalin Dahyabhai
4d200cd693 Fix a race in maintaining the journald reader list
The journald log reader keeps a map of following readers so that it can
close them properly when the journald reader object itself is closed,
but it was possible for its worker goroutine to be scheduled so that the
worker attempted to remove a reader from the map before the reader had
been added to the map.  This patch adds the item to the map before
starting the goroutine which is expected to eventually remove it.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> (github: nalind)
2016-03-17 18:36:21 -04:00
Michael Crosby
2b9ceea896 Merge pull request #21293 from cpuguy83/wtf_gcp
Do not call out to Google on init
2016-03-17 10:32:21 -07:00
Alexander Morozov
04c7d94c71 Merge pull request #21273 from jfrazelle/remove-dead-code
remove dead code
2016-03-17 09:16:02 -07:00
Brian Goff
24710fd3e2 Do not call out to Google on init
The GCP logging driver is calling out to GCP cloud service on package
init.
This is regardless if you are using GCP logging or not.

This change makes this happen on the first invocation of a new GCP
logging driver instance instead.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-03-17 11:06:21 -04:00
Jessica Frazelle
8dd88afb5b
remove dead code
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
2016-03-16 19:15:14 -07:00
Antonio Murdaca
f0d83c4cdb *: fix response body leaks
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-03-16 17:15:42 +01:00
Antonio Murdaca
0f59b0b12c Merge pull request #19831 from cloudflare/optimize-gelf
GELF logger: Add gelf-compression-type and gelf-compression-level
2016-03-15 22:35:46 +01:00
Daniel Dao
bd94baa353 add gelf option to customize compression type and level
this allows user to choose the compression type (i.e. gzip/zlib/none) using
--log-opt=gelf-compression-type=none or the compression level (-1..9) using
--log-opt=gelf-compression-level=0 for gelf driver.

Signed-off-by: Daniel Dao <dqminh@cloudflare.com>
2016-03-15 11:06:06 +00:00
Brian Goff
f500951598 Merge pull request #20121 from solganik/master
syslog format
2016-03-14 20:09:15 -04:00
David Calavera
8514880997 Provide basic string manupilation functions for template executions.
This change centralizes the template manipulation in a single package
and adds basic string functions to their execution.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-03-09 19:37:12 -05:00
Solganik Alexander
1a40dd535f Fixes #18712. Add rfc5424 log format for syslog.
Previously docker used obsolete rfc3164 syslog format for syslog. rfc3164 explicitly
uses semicolon as a separator between 'TAG' and 'Content' section of the log message.
Docker uses semicolon as a separator between image name and version tag.
When {{.ImageName}} was used as a tag expression and contained ":" syslog parser mistreated
"tag" part of the image name as syslog message body, which resulted in incorrect "syslogtag" been reported by syslog
daemon.
Use of rfc5424 log format partually fixes the issue as it does not use semicolon as a separator.
However using default rfc5424 syslog format itroduces backward incompatability because rsyslog template keyword  %syslogtag%
is parsed differently. In rfc3164 it uses the "TAG" part reported before the "pid" part. In rfc5424 it uses "appname" part reported
before the pid part, while tag part is introduced by %msgid% part.
For more information on rsyslog configuration properties see: http://www.rsyslog.com/doc/master/configuration/properties.html

Added two options to specify logging in either rfc5424, rfc3164 format or unix format omitting hostname in order to keep backwards compatability with
previous versions.

Signed-off-by: Solganik Alexander <solganik@gmail.com>
2016-03-09 22:31:11 +02:00
Sebastiaan van Stijn
3c4d093bab Merge pull request #18766 from mikedanese/gcplogs
Add logging driver for Google Cloud Logging
2016-03-02 02:09:44 +01:00
Arnaud Porterie
106793dcbe Merge pull request #20825 from LK4D4/unused
Remove some unused structs and fields
2016-03-01 12:58:35 -08:00
Tibor Vass
36401f20ce Merge pull request #20617 from nalind/journald-pkgconfig
Try to handle changing names for journal packages
2016-03-01 15:38:03 -05:00
Alexander Morozov
0a352e1a90 Remove some unused structs and fields
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2016-03-01 09:59:29 -08:00
Mike Danese
ed1b9fa07a daemon/logger: Add logging driver for Google Cloud Logging
Signed-off-by: Mike Danese <mikedanese@google.com>
2016-03-01 08:06:10 -08:00
David Calavera
ba5a282a83 Merge pull request #20605 from mountkin/optimize-json-log-writer
make the json log writer much faster
2016-02-29 10:47:46 -08:00
Brian Goff
f9524a4d24 add file poller panic fix from 1.10.2
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-02-24 10:17:29 -05:00
Brian Goff
91fdfdd537 Revert "use pubsub instead of filenotify to follow json logs"
This reverts commit b1594c59f5.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-02-23 21:43:52 -05:00
Nalin Dahyabhai
6cdc4ba6cd Try to handle changing names for journal packages
When checking if we have the development files for libsystemd's journal
APIs, check for either 'libsystemd >= 209' and 'libsystemd-journal'.  If
we find 'libsystemd', define the 'journald' tag, which defaults to using
the 'libsystemd.pc' file.  If we find the older 'libsystemd-journal',
define both the 'journald' and 'journald_compat' tags, which causes the
'libsystemd-journal.pc' file to be consulted instead.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> (github: nalind)
2016-02-23 12:24:27 -05:00
Shijiang Wei
d7af031114 make the json log writer much faster
Signed-off-by: Shijiang Wei <mountkin@gmail.com>
2016-02-23 19:28:06 +08:00
David Calavera
c795d0bab9 Merge pull request #19689 from cednation/etwlogs
Windows: Add ETW logging driver plug-in
2016-02-16 15:01:17 -08:00
Cedric Davies
3fe60bbf95 Windows: Add ETW logging driver plug-in
Signed-off-by: Cedric Davies <cedricda@microsoft.com>
2016-02-16 13:24:49 -08:00
Shijiang Wei
b1594c59f5 use pubsub instead of filenotify to follow json logs
inotify event is trigged immediately there's data written to disk.
But at the time that the inotify event is received, the json line might
not fully saved to disk. If the json decoder tries to decode in such
case, an io.UnexpectedEOF will be trigged.
We used to retry for several times to mitigate the io.UnexpectedEOF error.
But there are still flaky tests caused by the partial log entries.

The daemon knows exactly when there are new log entries emitted. We can
use the pubsub package to notify all the log readers instead of inotify.

Signed-off-by: Shijiang Wei <mountkin@gmail.com>

try to fix broken test. will squash once tests pass

Signed-off-by: Shijiang Wei <mountkin@gmail.com>
2016-02-15 19:25:16 +08:00
David Calavera
7a016578db Merge pull request #18041 from jnummelin/feature/fluent-logger-ignore-connect-error-flag
Added flag to ignore fluentd connect error on container start
2016-01-27 14:25:24 -08:00
Ivan Babrou
5a3351883b Add tag support to journald logging driver, closes #19556
Signed-off-by: Ivan Babrou <ibobrik@gmail.com>
2016-01-27 10:52:19 +00:00
Jussi Nummelin
3cf82ff1ab Added flag to ignore fluentd connect error on container start
Signed-off-by: Jussi Nummelin <jussi.nummelin@gmail.com>

Changed buffer size to 1M and removed unnecessary fmt call

Signed-off-by: Jussi Nummelin <jussi.nummelin@gmail.com>

Updated docs for the new fluentd opts

Signed-off-by: Jussi Nummelin <jussi.nummelin@gmail.com>
2016-01-27 09:05:44 +02:00
Daniel Dao
84e14754e1 only close LogDriver after LogCopier is done
this prevents the copier from sending messages in the buffer to the closed
driver. If the copied took longer than the timeout to drain the buffer, this
aborts the copier read loop and return back so we can cleanup resources
properly.

Signed-off-by: Daniel Dao <dqminh@cloudflare.com>
2016-01-18 17:47:57 +00:00
David Calavera
4b98193bea Add support for syslog over TLS.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2016-01-11 12:25:34 -05:00
Ingo Gottwald
f8c5420080 Fix race condition in JSONFileLogger.Log
Signed-off-by: Ingo Gottwald <in.gottwald@gmail.com>
2016-01-03 22:45:56 +01:00
Doug Davis
6bf8844f11 Merge pull request #18759 from mikedanese/doc-fix
daemon/logger: fix typo in godoc
2015-12-17 19:26:41 -05:00
Mike Danese
881a30c707 daemon/logger: fix typo in godoc
Signed-off-by: Mike Danese <mikedanese@google.com>
2015-12-17 15:52:33 -08:00
David Calavera
4fef42ba20 Replace pkg/units with docker/go-units.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-12-16 12:26:49 -05:00
David Calavera
27220ecc6b Move timeutils functions to the only places where they are used.
- Move time json marshaling to the jsonlog package: this is a docker
  internal hack that we should not promote as a library.
- Move Timestamp encoding/decoding functions to the API types: This is
  only used there. It could be a standalone library but I don't this
it's worth having a separated repo for this. It could introduce more
complexity than it solves.

Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-12-15 14:56:14 -05:00
Justas Brazauskas
927b334ebf Fix typos found across repository
Signed-off-by: Justas Brazauskas <brazauskasjustas@gmail.com>
2015-12-13 18:04:12 +02:00
Marius Sturm
a31435c8a2 dont trim gelf log message
Signed-off-by: Marius Sturm <marius@graylog.com>
2015-12-11 10:28:24 +01:00
Nalin Dahyabhai
0ca6d77e6e Revert "prevent journald from being built on ARM"
This reverts commit 6f6f10a75f, so that we
can apply a different workaround.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> (github: nalind)
2015-12-02 10:30:13 -05:00
Stefan Scherer
6f6f10a75f prevent journald from being built on ARM
Signed-off-by: Govinda Fichtner <govinda.fichtner@googlemail.com>
2015-11-21 15:17:31 +01:00
Alexander Morozov
adce1981f4 Merge pull request #17593 from daehyeok/refactoring_json_log
Refactoring json log driver
2015-11-17 15:38:52 -08:00
Alexander Morozov
a3065fa48f Merge pull request #17891 from splunk/splunk-logger-support-for-tag-env-labels
Allow configurable metadata for Splunk log driver
2015-11-16 10:11:27 -08:00
daehyeok mun
086c0b4a66 Extract rotate file writer from json log driver
Signed-off-by: Daehyeok Mun <daehyeok@gmail.com>
2015-11-14 16:15:44 -07:00
Alexander Morozov
42fa8e3128 Merge pull request #17417 from cpuguy83/15815_add_log_file_poller
Fallback to file polling for jsonlog reader on err
2015-11-13 11:49:54 -08:00
Denis Gladkikh
26855c7801 Allow configurable metadata for Splunk log driver
Add support of `tag`, `env` and `labels` for Splunk logging driver.
Removed from message `containerId` as it is the same as `tag`.

Signed-off-by: Denis Gladkikh <denis@gladkikh.email>
2015-11-12 06:36:51 -08:00
Vincent Demeester
8054a30387 dockerversion placeholder for library import
- Add a *version* file placeholder.
- Update autogen and builds to use it and an autogen build flag

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2015-11-09 19:32:46 +01:00
Brian Goff
c136a33c5b Fallback to file polling for jsonlog reader on err
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2015-11-05 10:05:05 -05:00
Shijiang Wei
a82f9ac819 increase the maxJSONDecodeRetry in json log reader
Signed-off-by: Shijiang Wei <mountkin@gmail.com>
2015-11-02 17:51:22 +08:00
Alexander Morozov
8d584da96e Merge pull request #17568 from Microsoft/10662-journald
Windows: Fix journald compile error
2015-10-31 09:35:39 -07:00
John Howard
5452954d89 Windows: Fix journald compile error
Signed-off-by: John Howard <jhoward@microsoft.com>
2015-10-31 08:31:25 -07:00
Alexander Morozov
ed6e3cf704 Merge pull request #17537 from mountkin/fix-logger-race
fix a race in json logger reader
2015-10-30 23:00:17 -07:00
Shijiang Wei
e41eae8b42 fix a race in json logger reader
The json decoder starts to decode immediately an inotify event is
received.
But at the time the inotify event is trigged, the json log
entry might haven't been fully written to the disk.
In this case the decoder will return an "io.UnexpectedEOF" error, but
there is still data remaining in the decoder's buffer. And the data
should be passed to the decoder when the next inotify event is
triggered.

Signed-off-by: Shijiang Wei <mountkin@gmail.com>
2015-10-31 02:28:23 +08:00
John Howard
2716e3964d Windows build broken on master (awslogs)
Signed-off-by: John Howard <jhoward@microsoft.com>
2015-10-30 10:02:32 -07:00
Samuel Karp
8a6dfb26f3 [awslogs] Auto-detect region on EC2 instances
Signed-off-by: Samuel Karp <skarp@amazon.com>
2015-10-27 23:47:28 +00:00
Samuel Karp
480c9c0178 [awslogs] Set User-Agent for Amazon CloudWatch Logs
Signed-off-by: Samuel Karp <skarp@amazon.com>
2015-10-27 23:47:19 +00:00
Samuel Karp
70083e6fc3 Update vendored aws-sdk-go
Signed-off-by: Samuel Karp <skarp@amazon.com>
2015-10-27 23:43:51 +00:00
Denis Gladkikh
1f1dbf312d Add Splunk logging driver #16207
Allow to send Splunk logs using Http Event Collector

Signed-off-by: Denis Gladkikh <denis@gladkikh.email>
2015-10-23 13:37:53 -07:00
Daniel Dao
0083f6e984 add labels/env log option for jsonfile
this allows jsonfile logger to collect extra metadata from containers with
`--log-opt labels=label1,label2 --log-opt env=env1,env2`.

Extra attributes are saved into `attrs` attributes for each log data.

Signed-off-by: Daniel Dao <dqminh@cloudflare.com>
2015-10-12 21:12:46 +02:00
Daniel Dao
11a24f19c2 add labels/env log option for journald
this allows journald logger to collect extra metadata from containers with
`--log-opt labels=label1,label2 --log-opt env=env1,env2`

Signed-off-by: Daniel Dao <dqminh@cloudflare.com>
2015-10-12 21:12:46 +02:00
Daniel Dao
4cc8490283 add labels/env log option for fluentd
this allows fluentd logger to collect extra metadata from containers with
`--log-opt labels=label1,label2 --log-opt env=env1,env2`

Signed-off-by: Daniel Dao <dqminh@cloudflare.com>
2015-10-12 21:12:46 +02:00
Daniel Dao
5794a0190d add labels/env log option for gelf
this allows gelf logger to collect extra metadata from containers with
`--log-opt labels=label1,label2 --log-opt env=env1,env2`

Additional log field will be prefixed with `_` as per gelf protocol
https://www.graylog.org/resources/gelf/

Signed-off-by: Daniel Dao <dqminh@cloudflare.com>
2015-10-12 21:12:46 +02:00
Daniel Dao
656cdbb0e9 add env and labels to log context
Signed-off-by: Daniel Dao <dqminh@cloudflare.com>
2015-10-12 21:12:46 +02:00
Antonio Murdaca
e3c472426f daemon: logger: error out on daemon start if invalid logger address
If an invalid logger address is provided on daemon start it will
silently fail. As syslog driver is doing, this check should be done on
daemon start and prevent it from starting even in other drivers.
This patch also adds integration tests for this behavior.

Signed-off-by: Antonio Murdaca <runcom@linux.com>
2015-09-20 16:20:25 +02:00
Philip Monroe
3be7146e14 log driver - add ability to interpolate container context into the log tag field
Signed-off-by: Philip Monroe <phil@philmonroe.com>
2015-09-16 15:19:28 -07:00
Nalin Dahyabhai
11fda783f8 Remove unnecessary check for nil CString
@noxiouz points out that we don't need to check for a nil result from
C.CString(), since an out-of-memory condition causes a runtime panic
instead.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> (github: nalind)
2015-09-14 14:16:48 -04:00
Nalin Dahyabhai
e611a189cb Add log reading to the journald log driver
If a logdriver doesn't register a callback function to validate log
options, it won't be usable.  Fix the journald driver by adding a dummy
validator.

Teach the client and the daemon's "logs" logic that the server can also
supply "logs" data via the "journald" driver.  Update documentation and
tests that depend on error messages.

Add support for reading log data from the systemd journal to the
journald log driver.  The internal logic uses a goroutine to scan the
journal for matching entries after any specified cutoff time, formats
the messages from those entries as JSONLog messages, and stuffs the
results down a pipe whose reading end we hand back to the caller.

If we are missing any of the 'linux', 'cgo', or 'journald' build tags,
however, we don't implement a reader, so the 'logs' endpoint will still
return an error.

Make the necessary changes to the build setup to ensure that support for
reading container logs from the systemd journal is built.

Rename the Jmap member of the journald logdriver's struct to "vars" to
make it non-public, and to make it easier to tell that it's just there
to hold additional variable values that we want journald to record along
with log data that we're sending to it.

In the client, don't assume that we know which logdrivers the server
implements, and remove the check that looks at the server.  It's
redundant because the server already knows, and the check also makes
using older clients with newer servers (which may have new logdrivers in
them) unnecessarily hard.

When we try to "logs" and have to report that the container's logdriver
doesn't support reading, send the error message through the
might-be-a-multiplexer so that clients which are expecting multiplexed
data will be able to properly display the error, instead of tripping
over the data and printing a less helpful "Unrecognized input header"
error.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com> (github: nalind)
2015-09-11 16:50:03 -04:00
Alexander Morozov
32964def83 awslogs: fix logrus import
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-09-11 11:05:06 -07:00
Samuel Karp
3effe484e6 Add awslogs driver for Amazon CloudWatch Logs
Signed-off-by: Samuel Karp <skarp@amazon.com>
2015-09-09 13:52:40 -07:00
David Calavera
8aa520b8c0 Merge pull request #15649 from LK4D4/syslog_validation
Syslog validation
2015-08-18 11:14:31 -07:00
Alexander Morozov
cde607108b Fix error message in max-file validation
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-08-17 15:34:39 -07:00
Alexander Morozov
960791ba60 Check syslog config on daemon start
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-08-17 14:29:45 -07:00
Alexander Morozov
b7a6d14bdc Do not allow corrupted syslog-address
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
2015-08-17 14:19:06 -07:00
David Calavera
f1412f2942 Remove doc that doesn't apply to Journald.
Signed-off-by: David Calavera <david.calavera@gmail.com>
2015-08-09 22:12:42 -05:00
Lei Jitang
5220f3b535 Enable golint in pkg/jsonlog and pkg/jsonmessage.
Signed-off-by: Lei Jitang <leijitang@huawei.com>
2015-08-08 11:28:22 +08:00
Qiang Huang
f5557f4f43 Remove unused variable
Introduced by #15209 unintentionally.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
2015-08-03 09:14:52 +08:00
Brian Goff
c57faa91e2 Ensure reader position is at the end after tailing
After tailing a file, if the number of lines requested is > the number
of lines in the file, this would cause a json unmarshalling error to
occur when we later try to go follow the file.
So brute force set it to the end if any tailing occurred.

There is potential that there could be some missing log messages if logs
are being written very quickly, however I was not able to make this
happen even with `while true; do echo hello; done`, so this is probably
acceptable.

While testing this I also found a panic in LogWatcher.Close can be
called twice due to a race. Fix channel close to only close when there
has been no signal to the channel.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2015-08-01 08:00:28 -04:00