Ad Widget

Collapse

How to group data from a log file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ltep
    Member
    • Nov 2022
    • 42

    #1

    How to group data from a log file

    Hello,
    I'm using log file monitoring. The log file is an .txt file on the C:\ drive.
    Collecting the log file lines is working fine. But how do i grab specific data automatically from each line and put it in an item?

    For example one line looks like this:

    2022-10-26 14:02:59,319 [7] INFO [TerminalPlugin (ID=3)] OnSaleResult : Transaction Succeed : Payment - Amount:20

    I was able to use the Log Time format yyyy-MM-dd hh:mm:ss to collect the timestamp. But the original timestamp stays in the collected line. How do i remove the timestap in the data?

    I also would like to grab data in the line. For example:
    item A = the value of amount which is 20
    item B = ID=3

  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    Preprocessing.. regexes, return groups.. But I am not sure, if that allows to preserve timestamp... never tried..
    But if you want to split this up into multiple items, then you need to set up dependent items, with different preprocessing to get exactly the thing you want.. main item gets update, dependent items get update...

    Comment

    • ltep
      Member
      • Nov 2022
      • 42

      #3
      Thanks Cyber.

      I was able to capture the ID value "3" with Preprocessing:

      Name = Regular expression
      Parameters = ID=(\d+)
      Output = \1

      Comment

      Working...