-
Notifications
You must be signed in to change notification settings - Fork 85
document "Service Discovery & Setup" #860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
54eaee1
document post-install behavior of "cscli setup unattended"
mmetc b2e2def
moved content
mmetc 6f3d358
formatting, title
mmetc c059a3e
typos
mmetc c6204a3
unit
mmetc 609c3af
Merge branch 'main' into cscli-setup
mmetc 0e24c8f
typo
mmetc c3dfda2
wip
mmetc cc2dc07
wip
mmetc 912c3c5
up
blotus 0ac9117
lint
blotus 5a29140
lint
blotus 8c91f71
lint
blotus 3a0c5ce
repetitions
mmetc 2dd95b4
add PlatformVersion
mmetc 94d2228
lint
mmetc 6277114
up
blotus a4c795a
fix datasources links
blotus 9a82b92
up
blotus 0b6cc9b
up
blotus 6fd4482
up
mmetc 8c1993f
up
blotus 59d5e42
fix name
blotus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
139 changes: 139 additions & 0 deletions
139
crowdsec-docs/docs/log_processor/service-discovery-setup/detect-yaml.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
--- | ||
id: detect-yaml | ||
title: Syntax | ||
sidebar_position: 1 | ||
--- | ||
|
||
# Syntax | ||
|
||
A minimal detection file is a YAML map with a top‐level `detect:` key. | ||
|
||
Under it, each entry describes one service plan: | ||
|
||
```yaml | ||
# detect.yaml | ||
--- | ||
detect: | ||
apache2-file-apache2: | ||
when: | ||
- Systemd.UnitInstalled("apache2.service") or len(Path.Glob("/var/log/apache2/*.log")) > 0 | ||
hub_spec: | ||
collections: | ||
- crowdsecurity/apache2 | ||
acquisition_spec: | ||
filename: apache2.yaml | ||
datasource: | ||
source: file | ||
filenames: | ||
- /var/log/apache2/*.log | ||
labels: | ||
type: apache2 | ||
``` | ||
|
||
## Fields | ||
|
||
### `when` | ||
|
||
A list of expression that must return a boolean. | ||
|
||
If multiple expressions are provided, they must all return `true` for the service to be included. | ||
|
||
```yaml | ||
when: | ||
- Host.OS == "linux" | ||
- Systemd.UnitInstalled("<unit>") | ||
``` | ||
|
||
You can use any of the helper referenced [here](/log_processor/service-discovery-setup/expr.md). | ||
|
||
### `hub_spec` | ||
|
||
A map of hub items to install. | ||
|
||
Specifying an invalid item type or item will log an error but will not prevent the detection to continue. | ||
|
||
```yaml | ||
hub_spec: | ||
collections: | ||
- crowdsecurity/linux | ||
parsers: | ||
- crowdsecurity/nginx-logs | ||
scenarios: | ||
- crowdsecurity/http-bf | ||
``` | ||
|
||
### `acquisition_spec` | ||
|
||
This item defines the acquisition that will be written to disk | ||
|
||
```yaml | ||
acquisition_spec: | ||
filename: foobar.yaml | ||
datasource: | ||
source: docker | ||
container_name: foo | ||
labels: | ||
type: bar | ||
``` | ||
|
||
The `filename` attribute will be used to generate the name of file in the form of `acquis.d/setup.<filename>.yaml`. | ||
|
||
The content of `datasource` will be validated (syntax, required fields depending on the datasource configured) and be written as-is to the file. | ||
|
||
## Examples | ||
|
||
Basic OS / Hub only: | ||
|
||
```yaml | ||
detect: | ||
linux: | ||
when: | ||
- Host.OS == "linux" | ||
hub_spec: | ||
collections: | ||
- crowdsecurity/linux | ||
``` | ||
|
||
`journalctl` source with a filter: | ||
|
||
```yaml | ||
detect: | ||
caddy-journal: | ||
when: | ||
- Systemd.UnitInstalled("caddy.service") | ||
- len(Path.Glob("/var/log/caddy/*.log")) == 0 | ||
hub_spec: | ||
collections: | ||
- crowdsecurity/caddy | ||
acquisition_spec: | ||
filename: caddy.yaml | ||
datasource: | ||
source: journalctl | ||
labels: | ||
type: caddy | ||
journalctl_filter: | ||
- "_SYSTEMD_UNIT=caddy.service" | ||
``` | ||
|
||
Windows event log: | ||
|
||
```yaml | ||
detect: | ||
windows_auth: | ||
when: | ||
- Host.OS == "windows" | ||
hub_spec: | ||
collections: | ||
- crowdsecurity/windows | ||
acquisition_spec: | ||
filename: windows_auth.yaml | ||
datasource: | ||
source: wineventlog | ||
event_channel: Security | ||
event_ids: | ||
- 4625 | ||
- 4623 | ||
event_level: information | ||
labels: | ||
type: eventlog | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mention that this should be unique?