From 92e5c79113b5bc20f8af14c8434a1d9b658c596e Mon Sep 17 00:00:00 2001 From: Matt Aitchison Date: Tue, 8 Mar 2016 11:29:38 -0600 Subject: [PATCH 01/14] Fix exposed ports in Dockerfile and readme. Remove references to /tmp/docker.sock from readme --- Dockerfile | 2 +- Dockerfile.dev | 2 +- README.md | 8 ++++---- VERSION | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index c4e25252..8f07f595 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM gliderlabs/alpine:3.1 ENTRYPOINT ["/bin/logspout"] VOLUME /mnt/routes -EXPOSE 8000 +EXPOSE 80 COPY . /src RUN cd /src && ./build.sh "$(cat VERSION)" diff --git a/Dockerfile.dev b/Dockerfile.dev index c6310812..063335eb 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,6 +1,6 @@ FROM gliderlabs/alpine:3.1 VOLUME /mnt/routes -EXPOSE 8000 +EXPOSE 80 ENV GOPATH /go RUN apk-install go git mercurial diff --git a/README.md b/README.md index 76a144f4..58d73fd5 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ You can also download and load a specific version: #### Route all container output to remote syslog -The simplest way to use logspout is to just take all logs and ship to a remote syslog. Just pass a syslog URI (or several comma separated URIs) as the command. Also, we always mount the Docker Unix socket with `-v` to `/tmp/docker.sock`: +The simplest way to use logspout is to just take all logs and ship to a remote syslog. Just pass a syslog URI (or several comma separated URIs) as the command. Also, we always mount the Docker Unix socket with `-v` to `/var/run/docker.sock`: $ docker run --name="logspout" \ - --volume=/var/run/docker.sock:/tmp/docker.sock \ + --volume=/var/run/docker.sock:/var/run/docker.sock \ gliderlabs/logspout \ syslog://logs.papertrailapp.com:55555 @@ -48,8 +48,8 @@ You can tell logspout to ignore specific containers by setting an environment va Using the [httpstream module](http://github.com/gliderlabs/logspout/blob/master/httpstream), you can connect with curl to see your local aggregated logs in realtime. You can do this without setting up a route URI. $ docker run -d --name="logspout" \ - --volume=/var/run/docker.sock:/tmp/docker.sock \ - --publish=127.0.0.1:8000:8000 \ + --volume=/var/run/docker.sock:/var/run/docker.sock \ + --publish=127.0.0.1:8000:80 \ gliderlabs/logspout $ curl http://127.0.0.1:8000/logs diff --git a/VERSION b/VERSION index 29ef827e..c78ee548 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3 +v3.1-dev From 3e2203d769e93053859a1807eebd9b564436ad4e Mon Sep 17 00:00:00 2001 From: Ryan Anguiano Date: Thu, 17 Mar 2016 05:21:36 -0400 Subject: [PATCH 02/14] Add community repo and use latest go version --- build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sh b/build.sh index e8a4644d..0393479d 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,6 @@ #!/bin/sh set -e +echo http://dl-4.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories apk add --update go git mercurial mkdir -p /go/src/github.com/gliderlabs cp -r /src /go/src/github.com/gliderlabs/logspout From 90302f046f740e3d77dda04f9a4387caed6f7f8d Mon Sep 17 00:00:00 2001 From: Michael Hobbs Date: Wed, 20 Apr 2016 19:46:57 -0700 Subject: [PATCH 03/14] update container name if we get a rename event. closes #144 (#180) * update container name if we get a rename event. closes #144 * revert to using event.ID --- Makefile | 8 +++++++- router/pump.go | 27 +++++++++++++++++++-------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 2bc996bb..73e3b162 100644 --- a/Makefile +++ b/Makefile @@ -30,4 +30,10 @@ ifneq ($(CIRCLE_BRANCH), release) echo build-$$CIRCLE_BUILD_NUM > VERSION endif -.PHONY: release +clean: + rm -rf build/ + docker rm $(shell docker ps -aq) || true + docker rmi $(NAME):dev $(NAME):$(VERSION) || true + docker rmi $(shell docker images -f 'dangling=true' -q) || true + +.PHONY: release clean diff --git a/router/pump.go b/router/pump.go index 2e6270a2..bad25c47 100644 --- a/router/pump.go +++ b/router/pump.go @@ -89,6 +89,15 @@ func (p *LogsPump) Setup() error { return nil } +func (p *LogsPump) rename(event *docker.APIEvents) { + p.mu.Lock() + defer p.mu.Unlock() + container, err := p.client.InspectContainer(event.ID) + assert(err, "pump") + pump, _ := p.pumps[normalID(event.ID)] + pump.container.Name = container.Name +} + func (p *LogsPump) Run() error { containers, err := p.client.ListContainers(docker.ListContainersOptions{}) if err != nil { @@ -106,10 +115,12 @@ func (p *LogsPump) Run() error { return err } for event := range events { - debug("pump: event:", normalID(event.ID), event.Status) + debug("pump.Run() event:", normalID(event.ID), event.Status) switch event.Status { case "start", "restart": go p.pumpLogs(event, true) + case "rename": + go p.rename(event) case "die": go p.update(event) } @@ -122,11 +133,11 @@ func (p *LogsPump) pumpLogs(event *docker.APIEvents, backlog bool) { container, err := p.client.InspectContainer(id) assert(err, "pump") if container.Config.Tty { - debug("pump:", id, "ignored: tty enabled") + debug("pump.pumpLogs():", id, "ignored: tty enabled") return } if ignoreContainer(container) { - debug("pump:", id, "ignored: environ ignore") + debug("pump.pumpLogs():", id, "ignored: environ ignore") return } var tail string @@ -141,7 +152,7 @@ func (p *LogsPump) pumpLogs(event *docker.APIEvents, backlog bool) { p.pumps[id] = newContainerPump(container, outrd, errrd) p.mu.Unlock() p.update(event) - debug("pump:", id, "started") + debug("pump.pumpLogs():", id, "started") go func() { err := p.client.Logs(docker.LogsOptions{ Container: id, @@ -153,7 +164,7 @@ func (p *LogsPump) pumpLogs(event *docker.APIEvents, backlog bool) { Tail: tail, }) if err != nil { - debug("pump:", id, "stopped:", err) + debug("pump.pumpLogs():", id, "stopped:", err) } outwr.Close() errwr.Close() @@ -172,7 +183,7 @@ func (p *LogsPump) update(event *docker.APIEvents) { select { case r <- &update{event, pump}: case <-time.After(time.Second * 1): - debug("pump: route timeout, dropping") + debug("pump.update(): route timeout, dropping") defer delete(p.routes, r) } } @@ -247,7 +258,7 @@ func newContainerPump(container *docker.Container, stdout, stderr io.Reader) *co line, err := buf.ReadString('\n') if err != nil { if err != io.EOF { - debug("pump:", normalID(container.ID), source+":", err) + debug("pump.newContainerPump():", normalID(container.ID), source+":", err) } return } @@ -274,7 +285,7 @@ func (cp *containerPump) send(msg *Message) { select { case logstream <- msg: case <-time.After(time.Second * 1): - debug("pump: send timeout, closing") + debug("pump.send(): send timeout, closing") // normal call to remove() triggered by // route.Closer() may not be able to grab // lock under heavy load, so we delete here From 67eaa0002ecd3ffccb51848053d0be9a89f6b409 Mon Sep 17 00:00:00 2001 From: Matt Aitchison Date: Wed, 11 May 2016 18:45:21 -0500 Subject: [PATCH 04/14] fix RouteManager.Name() --- router/routes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/router/routes.go b/router/routes.go index 0fe00a19..e14ba969 100644 --- a/router/routes.go +++ b/router/routes.go @@ -176,7 +176,7 @@ func (rm *RouteManager) Run() error { } func (rm *RouteManager) Name() string { - return "" + return "routes" } func (rm *RouteManager) Setup() error { From b6acebc6d5fda9d7ae1d925eb009952486d4ea76 Mon Sep 17 00:00:00 2001 From: Matt Aitchison Date: Thu, 12 May 2016 23:20:35 -0500 Subject: [PATCH 05/14] cleaned up setup method --- router/pump.go | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/router/pump.go b/router/pump.go index bad25c47..323caf40 100644 --- a/router/pump.go +++ b/router/pump.go @@ -80,22 +80,18 @@ func (p *LogsPump) Name() string { } func (p *LogsPump) Setup() error { - client, err := docker.NewClient( - getopt("DOCKER_HOST", "unix:///var/run/docker.sock")) - if err != nil { - return err - } - p.client = client - return nil + var err error + p.client, err = docker.NewClientFromEnv() + return err } func (p *LogsPump) rename(event *docker.APIEvents) { - p.mu.Lock() - defer p.mu.Unlock() - container, err := p.client.InspectContainer(event.ID) - assert(err, "pump") - pump, _ := p.pumps[normalID(event.ID)] - pump.container.Name = container.Name + p.mu.Lock() + defer p.mu.Unlock() + container, err := p.client.InspectContainer(event.ID) + assert(err, "pump") + pump, _ := p.pumps[normalID(event.ID)] + pump.container.Name = container.Name } func (p *LogsPump) Run() error { @@ -179,7 +175,7 @@ func (p *LogsPump) update(event *docker.APIEvents) { defer p.mu.Unlock() pump, pumping := p.pumps[normalID(event.ID)] if pumping { - for r, _ := range p.routes { + for r := range p.routes { select { case r <- &update{event, pump}: case <-time.After(time.Second * 1): From 1bfbc276767f3d2996c27cc0e84af6bf57a879e9 Mon Sep 17 00:00:00 2001 From: Matt Aitchison Date: Tue, 17 May 2016 15:07:47 -0500 Subject: [PATCH 06/14] Fixes issue #183 --- router/pump.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/router/pump.go b/router/pump.go index 323caf40..62f7e4b7 100644 --- a/router/pump.go +++ b/router/pump.go @@ -90,7 +90,11 @@ func (p *LogsPump) rename(event *docker.APIEvents) { defer p.mu.Unlock() container, err := p.client.InspectContainer(event.ID) assert(err, "pump") - pump, _ := p.pumps[normalID(event.ID)] + pump, ok := p.pumps[normalID(event.ID)] + if !ok { + debug("pump.rename(): ignore: pump not found, state:", container.State.StateString()) + return + } pump.container.Name = container.Name } From 8e54dea69a05bf4fea5048aa86f77bfa9f9c6e32 Mon Sep 17 00:00:00 2001 From: "R. Toma" Date: Tue, 17 May 2016 22:22:26 +0200 Subject: [PATCH 07/14] Now using Alpine Linux 3.3 and GO 1.5.3, removed the "edge" package repo for building the official Docker image (#174) Change-Id: I62a7960748906c1f9f7609dfc849f5ce0ce436fb --- Dockerfile | 2 +- Dockerfile.dev | 2 +- README.md | 2 +- build.sh | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8f07f595..03f9dd88 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM gliderlabs/alpine:3.1 +FROM gliderlabs/alpine:3.3 ENTRYPOINT ["/bin/logspout"] VOLUME /mnt/routes EXPOSE 80 diff --git a/Dockerfile.dev b/Dockerfile.dev index 063335eb..5b60b3eb 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM gliderlabs/alpine:3.1 +FROM gliderlabs/alpine:3.3 VOLUME /mnt/routes EXPOSE 80 diff --git a/README.md b/README.md index 58d73fd5..2c39806a 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ For now it only captures stdout and stderr, but a module to collect container sy ## Getting logspout -Logspout is a very small Docker container (14MB virtual, based on [Alpine](https://github.com/gliderlabs/docker-alpine)). Pull the latest release from the index: +Logspout is a very small Docker container (15.2MB virtual, based on [Alpine](https://github.com/gliderlabs/docker-alpine)). Pull the latest release from the index: $ docker pull gliderlabs/logspout:latest diff --git a/build.sh b/build.sh index 0393479d..e8a4644d 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,5 @@ #!/bin/sh set -e -echo http://dl-4.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories apk add --update go git mercurial mkdir -p /go/src/github.com/gliderlabs cp -r /src /go/src/github.com/gliderlabs/logspout From 0175188a799395b4ba7d686e30b1b10ac3fc9361 Mon Sep 17 00:00:00 2001 From: "R. Toma" Date: Tue, 17 May 2016 22:35:07 +0200 Subject: [PATCH 08/14] added link to the logspout-redis-logstash module (#172) Change-Id: I69df9d76f472e84116a8e1b5b9e0c3cb255fe663 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2c39806a..523f57b9 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ The standard distribution of logspout comes with all modules defined in this rep * logspout-kafka... * logspout-redis... * [logspout-logstash](https://github.com/looplab/logspout-logstash) + * [logspout-redis-logstash](https://github.com/rtoma/logspout-redis-logstash) ## Contributing From 457941d58e809f5ebbc44dbad956e51f587356b3 Mon Sep 17 00:00:00 2001 From: Tony Nuzzi Date: Tue, 17 May 2016 15:37:58 -0500 Subject: [PATCH 09/14] Add support text and command to stream logs to Loggly (#186) --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 523f57b9..b54d0415 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,17 @@ The standard distribution of logspout comes with all modules defined in this rep * [logspout-logstash](https://github.com/looplab/logspout-logstash) * [logspout-redis-logstash](https://github.com/rtoma/logspout-redis-logstash) +### Loggly support + +Use logspout to stream your docker logs to Loggly via the [Loggly syslog endpoint](https://www.loggly.com/docs/streaming-syslog-without-using-files/). +``` +$ docker run --name logspout -d --volume=/var/run/docker.sock:/var/run/docker.sock \ + -e SYSLOG_STRUCTURED_DATA="@41058 tag=\"some tag name\"" \ + gliderlabs/logspout \ + syslog+tcp://logs-01.loggly.com:514 +``` + + ## Contributing As usual, pull requests are welcome. You can also propose releases by opening a PR against the `release` branch from `master`. Please be sure to bump the version and update `CHANGELOG.md` and include your changelog text in the PR body. From 231ac0e4e8bccaea217ad00329dc7a0033cc2942 Mon Sep 17 00:00:00 2001 From: Dylan Meissner Date: Tue, 17 May 2016 13:41:02 -0700 Subject: [PATCH 10/14] Add logspout-kafka module to README (#77) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b54d0415..54c63527 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ The standard distribution of logspout comes with all modules defined in this rep ### Third-party modules - * logspout-kafka... + * [logspout-kafka](https://github.com/gettyimages/logspout-kafka) * logspout-redis... * [logspout-logstash](https://github.com/looplab/logspout-logstash) * [logspout-redis-logstash](https://github.com/rtoma/logspout-redis-logstash) From 23d3c9fee8ff470296226c7ae88332ab1ddde5ff Mon Sep 17 00:00:00 2001 From: Matt Aitchison Date: Thu, 19 May 2016 11:34:37 -0500 Subject: [PATCH 11/14] Quick fix for #185 --- router/routes.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/router/routes.go b/router/routes.go index e14ba969..12c3c6af 100644 --- a/router/routes.go +++ b/router/routes.go @@ -162,6 +162,7 @@ func (rm *RouteManager) RoutingFrom(containerID string) bool { func (rm *RouteManager) Run() error { rm.Lock() + defer rm.Unlock() for _, route := range rm.routes { rm.wg.Add(1) go func(route *Route) { @@ -170,8 +171,11 @@ func (rm *RouteManager) Run() error { }(route) } rm.routing = true - rm.Unlock() rm.wg.Wait() + // Temp fix to allow logspout to run without routes defined. + if len(rm.routes) == 0 { + select {} + } return nil } From a86151b1e86bfa597cb4501e03a65fa56cc22159 Mon Sep 17 00:00:00 2001 From: Matt Aitchison Date: Mon, 23 May 2016 16:21:24 -0500 Subject: [PATCH 12/14] Update chnagelog --- CHANGELOG.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c3cdfe5..d065cc41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,13 +3,17 @@ All notable changes to this project will be documented in this file. ## [Unreleased][unreleased] ### Fixed - +- Panic when renaming stopped container #183 +- won't start without route configuration #185 +- RouteManager.Name() didn't return name ### Added +- update container name if we get a rename event. closes #144 (#180) ### Removed ### Changed - +- Now using Alpine Linux 3.3 and GO 1.5.3, removed the "edge" package repo for building the official Docker image (#174) +- Fix exposed ports in Dockerfile and readme. Remove references to /tmp/docker.sock from readme ## [v3] - 2016-03-03 ### Fixed From 72dada29e584280c759f7619598fd213df6046ed Mon Sep 17 00:00:00 2001 From: Matt Aitchison Date: Mon, 23 May 2016 16:24:53 -0500 Subject: [PATCH 13/14] release prep --- CHANGELOG.md | 12 +++++++++++- VERSION | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d065cc41..2bb64d4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,15 @@ All notable changes to this project will be documented in this file. ## [Unreleased][unreleased] ### Fixed + +### Added + +### Removed + +### Changed + +## [3.1] - 2015-05-23 +### Fixed - Panic when renaming stopped container #183 - won't start without route configuration #185 - RouteManager.Name() didn't return name @@ -84,6 +93,7 @@ All notable changes to this project will be documented in this file. - Base container is now Alpine - Moved to gliderlabs organization -[unreleased]: https://github.com/gliderlabs/logspout/compare/v3...HEAD +[unreleased]: https://github.com/gliderlabs/logspout/compare/v3.1...HEAD +[v3.1]: https://github.com/gliderlabs/logspout/compare/v3...v3.1 [v3]: https://github.com/gliderlabs/logspout/compare/v2...v3 [v2]: https://github.com/gliderlabs/logspout/compare/v1...v2 diff --git a/VERSION b/VERSION index c78ee548..86166894 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v3.1-dev +v3.1 From 19fa188e87e5d3b2f00a871ba6598fef950f7dfd Mon Sep 17 00:00:00 2001 From: Matt Aitchison Date: Mon, 23 May 2016 16:26:22 -0500 Subject: [PATCH 14/14] fixed version and date... --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bb64d4f..41109c01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ All notable changes to this project will be documented in this file. ### Changed -## [3.1] - 2015-05-23 +## [v3.1] - 2016-05-23 ### Fixed - Panic when renaming stopped container #183 - won't start without route configuration #185