I need to monitor a .log file that is formatted in xml.
Basically all i need is to detect the word "Failed". If i use this Item Key:
logrt["C:\temp\myfile.log",Failed,,,skip]
the results are unpredictable - for certain files i do see the "Failed" keyword in Monitoring - Latest Data, but sometimes there is nothing captured.
Therefore, i would like to capture the entire contents of the .log file and then do some preprocessing. The .log file is generated 2 times per day and its maximum size never exceeds 8KB, so i believe it won't cause any strain for the Zabbix server.
But i dont know how to do it - if i use this simple Key:
logrt["C:\temp\myfile.log"]
then there is nothing in Monitoring - Latest Data.
I also tried to capture entire xml content with regex (confirmed that it works ok in regex101.com):
logrt["C:\temp\myfile.log","(<log.*?<\/log>)",,,,\1]
but again - nothing in Monitoring - Latest Data.
So how do i get the entire contents then?
Here is a sample log entry for reference:
<log status="0" start="638385804099562112" end="638385804283916928" taskname="MyTask - Table from ABC to XYZ DB_09212023_0439PM"><messages><msg code="2" type="0">Start Time: Tuesday, December 19, 2023 1:00:27 PM</msg><msg code="1" type="0">Executing (Delete Rows): DeleteRows MyTask-XYZ</msg><msg code="2" type="0">Start Time: Tuesday, December 19, 2023 1:00:27 PM</msg><msg code="100" type="160083">ERROR 160083: Failed to delete relationships for object</msg><msg code="100" type="-2147467259">Failed to execute (Delete Rows).</msg><msg code="3" type="0">Failed at Tuesday, December 19, 2023 1:00:28 PM (Elapsed Time: 0.73 seconds)</msg><msg code="100" type="-2147467259">Failed to execute (MyTask).</msg><msg code="3" type="0">Failed at Tuesday, December 19, 2023 1:00:28 PM (Elapsed Time: 0.96 seconds)</msg></messages></log>
Basically all i need is to detect the word "Failed". If i use this Item Key:
logrt["C:\temp\myfile.log",Failed,,,skip]
the results are unpredictable - for certain files i do see the "Failed" keyword in Monitoring - Latest Data, but sometimes there is nothing captured.
Therefore, i would like to capture the entire contents of the .log file and then do some preprocessing. The .log file is generated 2 times per day and its maximum size never exceeds 8KB, so i believe it won't cause any strain for the Zabbix server.
But i dont know how to do it - if i use this simple Key:
logrt["C:\temp\myfile.log"]
then there is nothing in Monitoring - Latest Data.
I also tried to capture entire xml content with regex (confirmed that it works ok in regex101.com):
logrt["C:\temp\myfile.log","(<log.*?<\/log>)",,,,\1]
but again - nothing in Monitoring - Latest Data.
So how do i get the entire contents then?
Here is a sample log entry for reference:
<log status="0" start="638385804099562112" end="638385804283916928" taskname="MyTask - Table from ABC to XYZ DB_09212023_0439PM"><messages><msg code="2" type="0">Start Time: Tuesday, December 19, 2023 1:00:27 PM</msg><msg code="1" type="0">Executing (Delete Rows): DeleteRows MyTask-XYZ</msg><msg code="2" type="0">Start Time: Tuesday, December 19, 2023 1:00:27 PM</msg><msg code="100" type="160083">ERROR 160083: Failed to delete relationships for object</msg><msg code="100" type="-2147467259">Failed to execute (Delete Rows).</msg><msg code="3" type="0">Failed at Tuesday, December 19, 2023 1:00:28 PM (Elapsed Time: 0.73 seconds)</msg><msg code="100" type="-2147467259">Failed to execute (MyTask).</msg><msg code="3" type="0">Failed at Tuesday, December 19, 2023 1:00:28 PM (Elapsed Time: 0.96 seconds)</msg></messages></log>
Comment