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

Is there a possibility to change to OUTPUT file to a custom /var/log destination #15

Open
avwsolutions opened this issue Oct 15, 2021 · 8 comments
Labels
enhancement New feature or request

Comments

@avwsolutions
Copy link

Is there a possibility to change to OUTPUT file to a custom /var/log destination ?

In some cases you want to use for example /var/log/sysmon instead of the standard syslog, since it will overload the syslog for Linux admins. Additionally we can ensure that logging tools easily can harvest different formats without running to much reg matches.

@juju4
Copy link

juju4 commented Oct 17, 2021

You can do with rsyslog. for example with
https://github.com/juju4/ansible-sysmon/blob/master/templates/rsyslog-sysmon.conf.j2
at least until a native option to directly log to file.

@hillu
Copy link
Contributor

hillu commented Oct 18, 2021

Adding that plain file backend is a good idea because having systemd-journald(8) handle possibly vast numbers of messages does incur quite some cost in CPU overhead.

@kesheldr
Copy link
Contributor

kesheldr commented Nov 3, 2021

Possibly; I will add it to the list of suggestions to debate. Would it be better to build log rotation into Sysmon or provide a method that logrotate could use to rotate for it?

@juju4
Copy link

juju4 commented Nov 6, 2021

IMHO better to use external logrotate for rotation with just ensuring a HUP signal forces reopening log file.

But that does not prevent to have option to log a file directly without passing by rsyslog. most SIEM connector/forwarder handles that without issue. avoid rsyslog/journald overhead. Amusingly enough, not the Microsoft Monitoring Agent or Azure Monitoring Agent for now, I believe.

@hillu
Copy link
Contributor

hillu commented Nov 6, 2021

A problem with relying on logrotate (the implementation, not the concept) is that it is usually not run very often. (The presence of a /etc/cron.daily/logrotate script hints at once per day). For high-volume telemetry that is going to be shipped off to another system to be processed there, this is not good enough.

@juju4
Copy link

juju4 commented Nov 6, 2021

agreed on rotation frequency.
you can likely change it from cron.daily to cron.hourly but may have side impacts.
or just add extra call like https://jira.atlassian.com/browse/HCPUB-546 (care if dateext is enabled as filename conflict)

@ssi0202
Copy link

ssi0202 commented Nov 19, 2021

@juju4 will the solution to mention result in the file being a pure xml formattet log data? the reason i ask is that im looking at how one can ship sysmon log data off the endpoint having a xml in json within syslog file presents a bit of a problem when the data then have to be ingested in xyz log managment platform. the data is there but getting it in a good workable datashema takes extra work (its doable no doubt) the datachema and thus fieldnames etc is a pre requsite to easily run sigma rules against the sysmon data

@juju4
Copy link

juju4 commented Nov 20, 2021

at this point, there is no solution implementation so it is still opened but unlikely, logs are written per event, most often line by line which means log file can't be a full valid json or xml which both have start/end marker.

Most SIEM/logging platforms have parse xml operators (same than json)
https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/parse-xmlfunction
https://docs.splunk.com/Documentation/SplunkCloud/latest/Search/Extractfieldswithsearchcommands (spath, xmlkv...)
https://help.sumologic.com/05Search/Search-Query-Language/01-Parse-Operators/07-Parse-XML-Formatted-Logs
https://www.elastic.co/guide/en/logstash/current/plugins-filters-xml.html

in cli, xmllint or sysmonLogView are the main option but sysmonLogView is not very customizable IMHO and xmllint requires a fully valid xml input so needs some commandline-fu for processing. example

head -1 /var/log/sysmon/sysmon.log | sed 's/^.* sysmon: //' | xmllint --xpath "concat(/Event/EventData/Data[@Name='CommandLine']/text(), '|', /Event/EventData/Data[@Name='ParentCommandLine'
]/text())" -

less straightforward than jq and json.

@MarioHewardt MarioHewardt added the enhancement New feature or request label Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants