Hello Sardar,
I think there's an error in your ossec.conf, but first, I will explain a bit about that error. The logs collected by getawslog.py from CloudTrail are stored as JSON logs in a file, in this case, /var/log/amazon.log, so, your Wazuh manager will only read that logs if the log_format in the localfile section in your ossec.conf is json.
Also, check in https://documentation.wazuh.com/current/amazon/integration.html, the localfile for AWS integration has been updated as follows:
<ossec_config> <localfile> <log_format>json</log_format> <location>/path-with-write-permission/amazon.log</location> <label key="aws.integration">cloudtrail</label> </localfile> </ossec_config>
In addition, please check the line in your crontab file to check that this line is correct, this line should look similar to the following one:
*/5 * * * * root /usr/bin/flock -n /tmp/cron.lock -c "python path_to_script/getawslog.py -b s3bucketname -d -j -D -l /path-with-write-permission/amazon.log"
Hope it helps.
Best regards,
Braulio
Hi Sardar,
first of all, I'm sorry for the late response. The changes to the ossec.conf that I posted before is for Wazuh 3.0, I didn't know that you are using Wazuh 2.1 so you need to revert the changes and add again:
<localfile> <log_format>syslog</log_format> <location>/var/log/amazon.log</location> </localfile>
The json log format is a new feature in Wazuh 3.x, that is the reason that explains why your manager is not reading any log from your amazon.log and generating the alerts. After you have changed your ossec.conf, restart your wazuh-manager to apply the changes using:
# systemctl restart wazuh-manageror in case that you are using SysV Init, use:
# service wazuh-manager restartNow, your manager can read the logs stored in your amazon.log file and generate alerts, and then, you can see the alerts in Kibana. Those alerts will appear in the wazuh-alerts-* index, so you don't need to create a new index.
Hope it helps and happy new year Sardar.
Best regards,
Braulio.
Hi Sardar,
I was reviewing your ossec.conf and it looks right. Maybe, this problem could be caused by a problem in the ruleset. To check if this is true or not, you can use activate the logall option (which you have already activated). In /var/ossec/logs/archives/archives.json you can find all events received by the manager, so here, you can find an event from AWS.
Once you have located an AWS event, execute ossec-logtest. This will load all your rules and decoders and it will let you try your rules by introducing a log event, which in this case this log event is your AWS event from /var/ossec/logs/archives/archives.json.
# /var/ossec/bin/ossec-logtest
...
...
...
2018/01/04 22:48:26 ossec-testrule: INFO: Reading decoder file etc/decoders/local_decoder.xml.
2018/01/04 22:48:26 ossec-testrule: INFO: Reading the lists file: 'etc/lists/audit-keys'
2018/01/04 22:48:26 ossec-testrule: INFO: Reading the lists file: 'etc/lists/amazon/aws-sources'
2018/01/04 22:48:26 ossec-testrule: INFO: Reading the lists file: 'etc/lists/amazon/aws-eventnames'
2018/01/04 22:48:26 ossec-testrule: INFO: Started (pid: 9109).
ossec-testrule: Type one log per line.
Once you have introduced your event here, if everything is correct, it should complete the three phases: predecoding, decoding and filtering, and generate the alert.
If you can't find an AWS event or if you introduce the event and ossec-logtest can't generate an alert, please let me know.
Hope it helps.
Regards,
Braulio.
2018/01/04 22:48:26 ossec-testrule: INFO: Reading the lists file: 'etc/lists/amazon/aws-sources'
2018/01/04 22:48:26 ossec-testrule: INFO: Reading the lists file: 'etc/lists/amazon/aws-eventnames'Thanks and Regards,
Sardar
Hi Sardar,
thank you for your message. As you can see in logtest, the event can't match any decoder, so, your wazuh-manager can't trigger any alert. That is the reason of why you can't see any alerts in Kibana.
Why is this happening? The reason is that in Wazuh 2.1, the decoding process was more complex that it is in the current version, and it didn't check all possible cases. This may ends in errors like this one if the logs change a bit its format. This issue is solved in Wazuh 3.x, because the manager can digest directly JSON input from the logs, making the decoding process much easier and now, it is not needed a decoder to process JSON input data.
We highly recommend upgrading to the latest stable version of Wazuh following this guide: https://documentation.wazuh.com/current/installation-guide/upgrading/different_major.html and you will find this issue solved. In case that you can't perform an upgrade in your system, please check the Amazon decoders in your ruleset and adapt them to solve the issue. You can find the Amazon decoders in GitHub: https://github.com/wazuh/wazuh-ruleset/blob/2.1/decoders/0020-amazon_decoders.xml
Hope it helps.
Regards,
Braulio