'Push existing log files to loki using python logger/ loguru
I have log files that I need to send to loki. Below is sample format.
1001 hostname application [1234:543] debug Apr 15 09:41:36.64453 Alias:App Command:any Arguments: Log file rotated
1002 hostname application [1234:543] debug Apr 15 09:43:36.64453 successfully aggregated and redeemed
<xml1>
.....
</xml1>
<xml2>
.....
</xml2>
1003 hostname application [1234:543] debug Apr 15 09:45:36.64453 Alias:App Command:any Arguments: Log file rotated
Content of after time stamp is mostly multi line could have xml as well and next log line starts with similar format as 1002
Question is what approach I should have to parse such file.
I want to have values to keys: timestamp=epoch(Apr 15 09:41:36.64453), type=Debug/info... Message= everything after time stamp
I came up with approach to use regex to combine "1001 hostname" to find next log line and concat everything to message key.
And log this keys line by line so handler to send it loki.
Like to have a suugesstion on better way to do it.
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
