Skip to content

Commit 3a0c5ce

Browse files
committed
repetitions
1 parent 8c91f71 commit 3a0c5ce

File tree

1 file changed

+48
-30
lines changed
  • crowdsec-docs/docs/log_processor/service-discovery-setup

1 file changed

+48
-30
lines changed

crowdsec-docs/docs/log_processor/service-discovery-setup/intro.md

Lines changed: 48 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
id: intro
3-
title: Service Discovery & Setup
3+
title: Service Discovery
44
sidebar_position: 1
55
---
66

@@ -10,40 +10,43 @@ sidebar_position: 1
1010

1111
The main way to use the service discovery is with `cscli setup interactive` or `cscli setup unattended`.
1212

13-
By default, it will use the detection file provided by crowdsec stored in `/etc/crowdsec/detect.yaml`.
13+
By default, it will use the detection file provided by crowdsec stored in `/var/lib/crowdsec/data/detect.yaml`.
1414

1515
In interactive mode, `cscli` will ask you to choose which service to configure based on those that were detected, and will require confirmation before any operation (installing hub items, generating acquisition config, ...).
1616

17-
If an `acquis.yaml` file exists, `cscli` will ask for confirmation before proceeding to avoid reading the same files multiple times.
17+
It is your responsibility to check the compatibility of the generated acquisitions with the ones you add later or were already on the system.
1818

19-
It is your responsability to check the generated configuration to make sure each log file is only read once by crowdsec.
19+
:::warning
2020

21-
As such, you should avoid putting your acquisition configuration in `/etc/crowdsec/acquis.yaml`, but instead create dedicated files in `/etc/crowdsec/acquis.d`.
21+
While `cscli setup` validates the generated configuration files for syntax errors or invalid configuration, it does *not* check for duplicate acquisition.
2222

23-
When ran in unattended mode, `cscli` will automatically any hub item, but will refuse to run if:
24-
- `acquis.yaml` exists and is not empty
25-
- An automatically generated acquisition file in `/etc/crowdsec/acquis.d` has been modified
23+
If using a custom `detect.yaml`, make sure no logs are read multiple times (with the same `type` label), as this could lead to false positives.
2624

27-
Linux packages (deb or rpm) will automatically call `cscli setup unattended` during installation.
25+
:::
2826

29-
:::warning
3027

31-
While `cscli setup` will check the generated configuration files for syntax errors or invalid configuration, it does *not* check for duplicate acquisition.
28+
`cscli` will ask for confirmation before proceeding if:
3229

33-
If using a custom `detect.yaml`, make sure no files are read multiple times (with the same `type` label), as this could lead to false positives.
30+
- there is an `acquis.yaml`
31+
- there is any non-generated file in `acquis.d`
32+
- you modified the generated files in `acquis.d` (there is a checksum to detect modifications). Proceeding could overwrite them.
3433

35-
:::
34+
Files composed by comments only are ignored.
3635

37-
### Generated acquisition files & coexistence with your own files
36+
Linux packages (deb or rpm) will automatically call `cscli setup unattended` during installation. In the case above, instead of asking for confirmation, unattended mode will just skip the service detection.
3837

39-
When you generated the acquisition configuration with `cscli setup`, `cscli` writes one file per service as `setup.<name>.yaml` in the acquisition directory (typically `/etc/crowdsec/acquis.d`). The content is **prefixed with a header** that includes a truncated `cscli-checksum` and a comment stating it was generated by `cscli setup`.
4038

41-
- Files carrying a valid `cscli-checksum` are considered **generated** and may be overwritten by future runs.
42-
- Files **without** a valid checksum are treated as **manually edited**; in interactive flows, `cscli` shows a colorized diff and asks before overwriting. In unattended flows, the command refuses to proceed if manual files are detected.
39+
### Generated acquisition files & coexistence with your own files
40+
41+
When you generated the acquisition configuration with `cscli setup`, `cscli` writes one file per service as `setup.<name>.yaml` in the acquisition directory (typically `/etc/crowdsec/acquis.d`). The content is prefixed with a header that includes a checksum and a comment stating it was generated by `cscli setup`.
42+
43+
- Files carrying a valid checksum are considered generated and may be overwritten by future runs.
44+
- Files without a valid checksum are treated as manually edited; in interactive mode, `cscli` shows a colorized diff and asks before overwriting. In unattended flows, the command refuses to proceed if manual files are detected.
4345
- Either way, the safest practice is: **don’t edit generated files**. If you need changes, delete the generated `setup.<name>.yaml` and create your own hand‑managed file instead or use a custom `detect.yaml` to generate the proper configuration automatically.
4446

4547
> Tips
46-
> - The actual on‑disk path is computed as `acquis.d/setup.<filename>` where `<filename>` comes from `acquisition_spec.filename`.
48+
49+
> - The actual on‑disk path is computed as `acquis.d/setup.<filename>.yaml` where `<filename>` comes from `acquisition_spec.filename`.
4750
> - Use `--acquis-dir` to target a different directory.
4851
> - `--dry-run` prints what would be created without writing files.
4952
@@ -63,17 +66,18 @@ CROWDSEC_SETUP_DETECT_CONFIG=/path/to/detect.yaml cscli setup detect
6366
```
6467

6568
Helpful flags:
69+
6670
- `--yaml` – render the setup plan as YAML (easy to review/edit); default output is JSON.
6771
- `--force <svc>` – pretend detection matched for `<svc>` (repeatable).
6872
- `--ignore <svc>` – drop `<svc>` from the plan even if matched (repeatable).
69-
- `--skip-systemd` – disable systemd‐based detection (useful in containers/chroots).
73+
- `--skip-systemd` – disable systemd‐based detection (default if systemctl can't be run).
7074
- `--list-supported-services` – print the service keys present in your file and exit.
7175

7276
You can see a list of all the available expr helpers in the [dedicated documentation](/log_processor/service-discovery-setup/expr.md).
7377

74-
For example, if you have configured nginx to log in a non-standard location, you can use a custom `detect.yaml` to automatically generate the configuration.
78+
For example, if you have configured nginx to log in a non-standard location, you can use a custom `detect.yaml` to override it.
7579

76-
This example will generate an acquisition config for the file datasource with the pattern `/srv/logs/nginx/*.log` if the nginx service is installed OR if any file matches the glob pattern `/srv/logs/nginx/*.log`:
80+
This example will generate an acquisition with the pattern `/srv/logs/nginx/*.log` if the nginx service is installed OR if any file matches the glob pattern `/srv/logs/nginx/*.log`:
7781

7882
```yaml
7983
# detect.yaml
@@ -90,9 +94,9 @@ detect:
9094
datasource:
9195
source: file
9296
filenames:
93-
- /srv/logs/nginx/*.log # <- your path here
97+
- /srv/logs/nginx/*.log
9498
labels:
95-
type: nginx
99+
type: nginx
96100
```
97101
98102
:::warning
@@ -109,28 +113,41 @@ detect:
109113
hub_spec:
110114
collections:
111115
- crowdsecurity/linux
116+
acquisition_spec:
117+
filename: linux.yaml
118+
datasource:
119+
source: file
120+
labels:
121+
type: syslog
122+
filenames:
123+
- /var/log/messages
124+
- /var/log/syslog
125+
- /var/log/kern.log
112126
```
127+
113128
:::
114129
115130
### Unattended installs with a custom detect file
116131
117132
Linux packages (deb or rpm) will automatically call `cscli setup unattended` during installation.
118133

119-
You can specify a custom detection file to use by setting the `CROWDSEC_SETUP_DETECT_CONFIG` environment variable.
134+
You can specify a custom detection file to use by setting `CROWDSEC_SETUP_DETECT_CONFIG` before installing the package with `apt` or `dnf`.
120135

121-
Alternatively, if you want to skip the automatic detection (because you deploy the configuration with Ansible for example), you can set the env var `CROWDSEC_SETUP_UNATTENDED_DISABLE` to any value.
136+
Alternatively, if you want to skip the automatic detection completely, you can set the env var `CROWDSEC_SETUP_UNATTENDED_DISABLE` to any value.
122137

123138
### End-to-end workflow
124139

125140
Behind the scenes, `cscli setup` use multiple steps to configure crowdsec:
126-
- Generate a setup files that contains the detected services, their associated hub items and acquisition configuration
127-
- Validate this file
128-
- Install the hub items
129-
- Write the acquisition config to disk
141+
142+
- Generate a YAML plan that contains the detected services, their associated hub items and acquisition configuration
143+
- Validate this file
144+
- Install the hub items
145+
- Write the acquisition config to disk
130146

131147
If you wish, you can manually invoke any of those steps (if you only want to install the hub items for example).
132148

133149
`cscli setup detect` can be used to generate the setup file:
150+
134151
```bash
135152
cscli setup detect --detect-config ./detect.yaml --yaml > setup.yaml
136153
```
@@ -148,6 +165,7 @@ cscli setup install-hub ./setup.yaml
148165
```
149166

150167
And finally, write the acquisition config:
168+
151169
```bash
152170
cscli setup install-acquisition ./setup.yaml --acquis-dir /etc/crowdsec/acquis.d
153-
```
171+
```

0 commit comments

Comments
 (0)