Skip to content
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

Update journalctl filter to use UID instead of SYSLOG_IDENTIFIER #24

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions imageroot/bin/expand-configuration
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,11 @@ jenv = Environment(
keep_trailing_newline=True,
)

rdb = agent.redis_connect()
modules=[]

# we list all modules, then we search in which node they run and
# we filter only relevant module on the node
for kenv in rdb.scan_iter(match='module/*/environment'):
if rdb.hget(kenv, "NODE_ID") == node_id:
modules.append(kenv.removeprefix("module/").removesuffix("/environment"))

properties = {
"modules" : modules
}
# acquis.yaml is a static file but the first start remove it

template = jenv.get_template('acquis.yaml')
output = template.render(properties)
with open("crowdsec_config/acquis.yaml","w") as f:
f.write(output)
f.write(template.render())

# The first start crowdsec expects other configuration files
# if these files are not present then the service fails to start
Expand Down
12 changes: 8 additions & 4 deletions imageroot/templates/acquis.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
---
source: journalctl
journalctl_filter:
- "_SYSTEMD_UNIT=sshd.service"
- "_TRANSPORT=journal"
labels:
type: syslog
---
{% for tag in modules %}
source: journalctl
journalctl_filter:
- "SYSLOG_IDENTIFIER={{tag}}"
- "_TRANSPORT=syslog"
labels:
type: syslog
---
{% endfor %}
source: journalctl
journalctl_filter:
- "_TRANSPORT=stdout"
labels:
type: syslog
---
Loading
Loading