Skip to content

Commit 024592c

Browse files
author
chris7444
committed
update README.md for swarm deployments PR #329
1 parent 717c442 commit 024592c

File tree

1 file changed

+41
-3
lines changed

1 file changed

+41
-3
lines changed

README.md

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ You can tell logspout to only include certain containers by setting filter param
5959
--volume=/var/run/docker.sock:/var/run/docker.sock \
6060
gliderlabs/logspout \
6161
raw://192.168.10.10:5000?filter.name=*_db
62-
62+
6363
$ docker run \
6464
--volume=/var/run/docker.sock:/var/run/docker.sock \
6565
gliderlabs/logspout \
6666
raw://192.168.10.10:5000?filter.id=3b6ba57db54a
67-
67+
6868
$ docker run \
6969
--volume=/var/run/docker.sock:/var/run/docker.sock \
7070
gliderlabs/logspout \
7171
raw://192.168.10.10:5000?filter.sources=stdout%2Cstderr
72-
72+
7373
# Forward logs from containers with both label 'a' starting with 'x', and label 'b' ending in 'y'.
7474
$ docker run \
7575
--volume=/var/run/docker.sock:/var/run/docker.sock \
@@ -156,6 +156,44 @@ Logspout relies on the Docker API to retrieve container logs. A failure in the A
156156
* `SYSLOG_TAG` - datum for tag field (default `{{.ContainerName}}+route.Options["append_tag"]`)
157157
* `SYSLOG_TIMESTAMP` - datum for timestamp field (default `{{.Timestamp}}`)
158158

159+
#### Using Logspout in a swarm
160+
161+
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
162+
163+
```
164+
version: "3"
165+
networks:
166+
logging:
167+
services:
168+
logspout:
169+
image: gliderlabs/logspout:latest
170+
networks:
171+
- logging
172+
volumes:
173+
- /etc/hostname:/etc/host_hostname:ro
174+
- /var/run/docker.sock:/var/run/docker.sock
175+
command:
176+
syslog://svt2-logger.am2.cloudra.local:514
177+
deploy:
178+
mode: global
179+
resources:
180+
limits:
181+
cpus: '0.20'
182+
memory: 256M
183+
reservations:
184+
cpus: '0.10'
185+
memory: 128M
186+
```
187+
188+
logspout can then be deployed as a global service in the swam with the following command
189+
190+
```bash
191+
docker stack deploy --compose-file <name of your compose file>
192+
```
193+
194+
More information about services and their mode of deployment can be found here:
195+
https://docs.docker.com/engine/swarm/how-swarm-mode-works/services/
196+
159197
## Modules
160198

161199
The standard distribution of logspout comes with all modules defined in this repository. You can remove or add new modules with custom builds of logspout. In the `custom` dir, edit the `modules.go` file and do a `docker build`.

0 commit comments

Comments
 (0)