Skip to content

Commit 80b0f24

Browse files
Merge pull request #480 from gliderlabs/master
release 3.2.11
2 parents 61a9913 + 301ffe1 commit 80b0f24

File tree

8 files changed

+315
-126
lines changed

8 files changed

+315
-126
lines changed

CHANGELOG.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ All notable changes to this project will be documented in this file.
1010

1111
### Changed
1212

13+
## [v3.2.11] - 2020-05-8
14+
### Added
15+
- @hhromic Add Syslog TCP framing documentation to README
16+
17+
### Changed
18+
- @hhromic syslog adapter refactor
19+
- @michaelshobbs use type assertion instead of reflection to determine connection type
20+
- @michaelshobbs use // + space for all human readable comments
21+
1322
## [v3.2.10] - 2020-05-1
1423
### Added
1524
- @jszwedko Add optional TCP framing to syslog adapter
@@ -234,7 +243,8 @@ All notable changes to this project will be documented in this file.
234243
- Base container is now Alpine
235244
- Moved to gliderlabs organization
236245

237-
[unreleased]: https://github.com/gliderlabs/logspout/compare/v3.2.10...HEAD
246+
[unreleased]: https://github.com/gliderlabs/logspout/compare/v3.2.11...HEAD
247+
[v3.2.11]: https://github.com/gliderlabs/logspout/compare/v3.2.10...v3.2.11
238248
[v3.2.10]: https://github.com/gliderlabs/logspout/compare/v3.2.9...v3.2.10
239249
[v3.2.9]: https://github.com/gliderlabs/logspout/compare/v3.2.8...v3.2.9
240250
[v3.2.8]: https://github.com/gliderlabs/logspout/compare/v3.2.7...v3.2.8

README.md

+17
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ If you use multiline logging with raw, it's recommended to json encode the Data
194194
* `SYSLOG_PRIORITY` - datum for priority field (default `{{.Priority}}`)
195195
* `SYSLOG_STRUCTURED_DATA` - datum for structured data field
196196
* `SYSLOG_TAG` - datum for tag field (default `{{.ContainerName}}+route.Options["append_tag"]`)
197+
* `SYSLOG_TCP_FRAMING` - for TCP or TLS transports, whether to use `octet-counted` framing in emitted messages or `traditional` LF framing (default `traditional`)
197198
* `SYSLOG_TIMESTAMP` - datum for timestamp field (default `{{.Timestamp}}`)
198199
* `MULTILINE_ENABLE_DEFAULT` - enable multiline logging for all containers when using the multiline adapter (default `true`)
199200
* `MULTILINE_MATCH` - determines which lines the pattern should match, one of first|last|nonfirst|nonlast, for details see: [MULTILINE_MATCH](#multiline_match) (default `nonfirst`)
@@ -250,6 +251,22 @@ Use examples:
250251

251252
```
252253

254+
#### Syslog TCP Framing
255+
256+
When using a TCP or TLS transport with the Syslog adapter, it is possible to add octet-counting to the emitted frames as described in [RFC6587 (Syslog over TCP) 3.4.1](https://tools.ietf.org/html/rfc6587#section-3.4.1) and [RFC5424 (Syslog over TLS)](https://tools.ietf.org/html/rfc5424).
257+
258+
This prefixes each message with the length of the message to allow consumers to easily determine where the message ends (rather than traditional LF framing). This also enables multiline Syslog messages without escaping.
259+
260+
To enable octet-counted framing for Syslog over TCP or TLS, use the `SYSLOG_TCP_FRAMING` environment variable:
261+
262+
$ docker run --name="logspout" \
263+
-e SYSLOG_TCP_FRAMING=octet-counted \
264+
--volume=/var/run/docker.sock:/var/run/docker.sock \
265+
gliderlabs/logspout \
266+
syslog+tcp://logs.papertrailapp.com:55555
267+
268+
> NOTE: The default is to use traditional LF framing for backwards compatibility though octet-counted framing is preferred when it is known the downstream consumer can handle it.
269+
253270
#### Using Logspout in a swarm
254271

255272
In a swarm, logspout is best deployed as a global service. When running logspout with 'docker run', you can change the value of the hostname field using the `SYSLOG_HOSTNAME` environment variable as explained above. However, this does not work in a compose file because the value for `SYSLOG_HOSTNAME` will be the same for all logspout "tasks", regardless of the docker host on which they run. To support this mode of deployment, the syslog adapter will look for the file `/etc/host_hostname` and, if the file exists and it is not empty, will configure the hostname field with the content of this file. You can then use a volume mount to map a file on the docker hosts with the file `/etc/host_hostname` in the container. The sample compose file below illustrates how this can be done

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v3.2.10
1+
v3.2.11

adapters/raw/raw.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"log"
88
"net"
99
"os"
10-
"reflect"
1110
"text/template"
1211

1312
"github.com/gliderlabs/logspout/router"
@@ -69,11 +68,10 @@ func (a *Adapter) Stream(logstream chan *router.Message) {
6968
log.Println("raw:", err)
7069
return
7170
}
72-
//log.Println("debug:", buf.String())
7371
_, err = a.conn.Write(buf.Bytes())
7472
if err != nil {
7573
log.Println("raw:", err)
76-
if reflect.TypeOf(a.conn).String() != "*net.UDPConn" {
74+
if _, ok := a.conn.(*net.UDPConn); !ok {
7775
return
7876
}
7977
}

0 commit comments

Comments
 (0)