Skip to content

Commit 858ac18

Browse files
enhance: revert and do what I said last commit (#871)
1 parent f90148c commit 858ac18

File tree

2 files changed

+228
-54
lines changed
  • crowdsec-docs
    • docs/log_processor/data_sources
    • versioned_docs/version-v1.7/log_processor/data_sources

2 files changed

+228
-54
lines changed

crowdsec-docs/docs/log_processor/data_sources/docker.md

Lines changed: 114 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ This module allows the `Security Engine` to acquire logs from running containers
77

88
## Configuration example
99

10+
### Container
11+
1012
To monitor a given container name or ID:
1113

1214
```yaml
@@ -31,71 +33,115 @@ labels:
3133
type: log_type
3234
```
3335
36+
### Swarm
37+
38+
To monitor a given Swarm service name or ID:
39+
40+
```yaml
41+
source: docker
42+
service_name:
43+
- my_service_name
44+
service_id:
45+
- abcdef123456
46+
labels:
47+
type: log_type
48+
```
49+
50+
To monitor Swarm services name or ID matching a regex:
51+
52+
```yaml
53+
source: docker
54+
service_name_regexp:
55+
- web_*
56+
service_id_regexp:
57+
- svc-*
58+
labels:
59+
type: log_type
60+
```
61+
3462
Look at the `configuration parameters` to view all supported options.
3563

64+
3665
## Parameters
3766

67+
:::warning
68+
you should not mix `container` options and `swarm` options as it may lead to duplicate logs being read. if you plan to use `swarm` options solely use these options.
69+
:::
70+
71+
### Container
3872

39-
### `container_name`
73+
#### `container_name`
4074

4175
List of containers names to monitor.
4276

43-
### `container_id`
77+
#### `container_id`
4478

4579
List of containers IDs to monitor.
4680

47-
### `container_name_regexp`
81+
#### `container_name_regexp`
4882

4983
List of regexp matching containers names to monitor.
5084

51-
### `container_id_regexp`
85+
#### `container_id_regexp`
5286

5387
List of regexp matching containers ID to monitor.
5488

55-
### `docker_host`
89+
#### `use_container_labels`
5690

57-
Docker host.
91+
Forces the use of container labels to get the log type. Meaning you can define a single docker datasource and let the labels of the container define the log type.
5892

59-
Default: `unix:///var/run/docker.sock`
93+
```yaml
94+
source: docker
95+
use_container_labels: true
96+
```
6097

61-
### `until`
98+
Currently here is the list of reserved labels for the container:
6299

63-
Read logs until timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes).
100+
`crowdsec.enable` : Enable crowdsec acquisition for this container the value must be set to `crowdsec.enable=true` for the container to be adopted.
64101

65-
### `since`
102+
`crowdsec.labels` : Top level key that will parse into the labels struct for the acquisition, for example `crowdsec.labels.type=nginx` will be parsed to the following:
66103

67-
Read logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes).
104+
```yaml
105+
labels:
106+
type: nginx
107+
```
68108

69-
### `check_interval`
109+
Here is an example of running a nginx container with the labels:
70110

71-
Relative interval (e.g. 5s for 5 seconds) to check for new containers matching the configuration.
111+
```bash
112+
docker run -d --label crowdsec.enable=true --label crowdsec.labels.type=nginx nginx:alpine
113+
```
72114

73-
Default: `1s`
115+
### Swarm
74116

75-
### `follow_stdout`
117+
#### `service_name`
76118

77-
Follow `stdout` containers logs.
119+
List of service names to monitor.
78120

79-
Default: `true`
121+
#### `service_id`
80122

81-
### `follow_stderr`
123+
List of service IDs to monitor.
82124

83-
Follow `stderr` container logs.
125+
#### `service_name_regexp`
84126

85-
Default: `true`
127+
List of regexp matching service names to monitor.
86128

87-
### `use_container_labels`
129+
#### `service_id_regexp`
88130

89-
Forces the use of container labels to get the log type. Meaning you can define a single docker datasource and let the labels of the container define the log type.
131+
List of regexp matching service ID to monitor
132+
133+
#### `use_service_labels`
134+
135+
Forces the use of service labels to get the log type. Meaning you can define a single docker datasource and let the labels of the service define the log type.
90136

91137
```yaml
92138
source: docker
93-
use_container_labels: true
139+
use_service_labels: true
94140
```
95141

96-
Currently here is the list of reserved labels for the container:
142+
Currently here is the list of reserved labels for the service:
97143

98-
`crowdsec.enable` : Enable crowdsec acquisition for this container the value must be set to `crowdsec.enable=true` for the container to be adopted.
144+
`crowdsec.enable` : Enable crowdsec acquisition for this service the value must be set to `crowdsec.enable=true` for the service to be adopted.
99145

100146
`crowdsec.labels` : Top level key that will parse into the labels struct for the acquisition, for example `crowdsec.labels.type=nginx` will be parsed to the following:
101147

@@ -104,15 +150,56 @@ labels:
104150
type: nginx
105151
```
106152

107-
Here is an example of running a nginx container with the labels:
153+
Here is an example of running a service using nginx with the labels:
108154

109155
```bash
110-
docker run -d --label crowdsec.enable=true --label crowdsec.labels.type=nginx nginx:alpine
156+
docker service create \
157+
--name test-nginx \
158+
--label crowdsec.enable=true \
159+
--label crowdsec.labels.type=nginx \
160+
--replicas 2 \
161+
nginx:latest
111162
```
112163

164+
### `docker_host`
165+
166+
Docker host.
167+
168+
Default: `unix:///var/run/docker.sock`
169+
170+
### `until`
171+
172+
Read logs until timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes).
173+
174+
### `since`
175+
176+
Read logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes).
177+
178+
### `check_interval`
179+
180+
Relative interval (e.g. 5s for 5 seconds) to check for new containers matching the configuration.
181+
182+
Default: `1s`
183+
184+
### `follow_stdout`
185+
186+
Follow `stdout` containers logs.
187+
188+
Default: `true`
189+
190+
### `follow_stderr`
191+
192+
Follow `stderr` container logs.
193+
194+
Default: `true`
195+
113196

114197
## DSN and command-line
115198

199+
:::info
200+
DSN does not support reading from Swarm services
201+
:::
202+
116203
docker datasource implements a very approximative DSN, as follows : `docker://<docker_name_or_id>?[args]`
117204

118205
Supported args are :

0 commit comments

Comments
 (0)