Hello everyone,
I am writing this post even though there are other similar posts, but unfortunately, they haven't been helpful to me.
I have created my own Python program that writes custom logs to a file at irregular intervals. Here's an example of a syslog-format log created by the application:
Aug 16 21:37:49 Extension extension_log[99999]: Extension with IP '127.0.0.1' and agent ID '001' attempted to access the host 'site.com'
It's important to specify that these logs, when created, should be visible in Kibana.
Here are the settings I added to the ossec.conf file (for convenience and testing, I created a dummy log file located at /tmp/test/test.log with 2 lines of logs similar to the example mentioned earlier):
[...] <global> <jsonout_output>yes</jsonout_output> <alerts_log>yes</alerts_log> <logall>yes</logall> <logall_json>yes</logall_json> [...] <alerts> <log_alert_level>3</log_alert_level> <email_alert_level>12</email_alert_level> </alerts> [...] <localfile> <log_format>syslog</log_format> <location>/tmp/test/test.log</location> <frequency>60</frequency> </localfile>
This is what I added to the /var/ossec/etc/decoders/local_decoder.xml file: <decoder name="extension_log"> <program_name>^extension_log</program_name> </decoder>
<decoder name="extension_log"> <parent>extension_log</parent> <regex>Extension with IP '(\d+.\d+.\d+.\d+)' and agent ID '(\d\d\d)' attempted to access the host '(\w+)'</regex> <order>srcip, data, user</order> </decoder>And this is what I added to /var/ossec/etc/rules/local_rules.xml: <group name="extension_log_rule"> <rule id="100010" level="14"> <program_name>extension_url_blocked</program_name> <description>Domain blocked by extension</description> </rule> </group>
When running the program /var/ossec/bin/wazuh-logtest to test the log, this is the output: root @ alex:/var/ossec/etc/rules# /var/ossec/bin/wazuh-logtest Starting wazuh-logtest v4.5.0 Type one log per line
Aug 16 21:37:49 Extension extension_log[99999]: Extension with IP '127.0.0.1' and agent ID '001' attempted to access the host 'site.com'
**Phase 1: Completed pre-decoding. full event: 'Aug 16 21:37:49 Extension extension_log[99999]: Extension with IP '127.0.0.1' and agent ID '001' attempted to access the host 'site.com'' timestamp: 'Aug 16 21:37:49' hostname: 'Extension' program_name: 'extension_log'
**Phase 2: Completed decoding. name: 'extension_log'
**Phase 3: Completed filtering (rules). id: '100010' level: '14' description: 'Domain blocked by extension' groups: '['extension_log_rule']' firedtimes: '1' mail: 'True' **Alert to be generated.
In Kibana, under the "Modules" > "Security Events" section, I don't see any logs with the ID 100010 or that reflect what is written in the log.
I would appreciate your help in understanding why I am not seeing the log and how I could resolve this issue.
Thank you very much!
Best regards, Alex