Ad Widget

Collapse

Monitoring log with custom name format

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TrapoSAMA
    Junior Member
    • Aug 2020
    • 16

    #1

    Monitoring log with custom name format

    Hi!

    Is possible and how check a log with name and ubication like /folder1/folder2/month-year/log-day-month-year, the log change the name when day is finish.

    Thx.
  • isaqueprofeta
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Aug 2020
    • 154

    #2
    Review logrt agent key, you can set up a custom regexp for the rotation pattern of your logfile: https://www.zabbix.com/documentation...s/zabbix_agent

    Comment

    • TrapoSAMA
      Junior Member
      • Aug 2020
      • 16

      #3
      Hi!

      i try but i dont know why to use. Examples are simple and dont find how to use with format like day or month or year or today.

      Do you have some examples?

      Thx

      Comment

      • isaqueprofeta
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • Aug 2020
        • 154

        #4
        Originally posted by TrapoSAMA
        Do you have some examples?
        It's inside the Docs that I send on the link before...

        Examples:
        ⇒ logrt["/home/zabbix/logs/^logfile[0-9]{1,3}$",,,100] → will match a file like "logfile1" (will not match ".logfile1")
        ⇒ logrt["/home/user/^logfile_.*_[0-9]{1,3}$","pattern_to_match","UTF-8",100] → will collect data from files such "logfile_abc_1" or "logfile__001".

        Comment

        • TrapoSAMA
          Junior Member
          • Aug 2020
          • 16

          #5
          Hi!

          but the log structure is /var/log/2020-09/2020-09-08.log <- this is for today, the log change tomorrow and the previuos log cant be deleted, idel for the previous folder.

          Do you have a example for this type of pattern log ?

          Thx

          Comment

          • isaqueprofeta
            Senior Member
            Zabbix Certified SpecialistZabbix Certified Professional
            • Aug 2020
            • 154

            #6
            Originally posted by TrapoSAMA
            Hi!

            but the log structure is /var/log/2020-09/2020-09-08.log <- this is for today, the log change tomorrow and the previuos log cant be deleted, idel for the previous folder.

            Do you have a example for this type of pattern log ?

            Thx
            For your specific case no. But there's a lot of examples to study, in official Docs: https://www.zabbix.com/documentation...sions#examples

            Comment

            • Hamardaban
              Senior Member
              Zabbix Certified SpecialistZabbix Certified Professional
              • May 2019
              • 2713

              #7
              You initially incorrectly formulated your question - you change not only the file name, but also the path to the file.
              zabbix doesn't work that way.
              • Regular expressions for logrt are supported in filename only, directory regular expression matching is not supported.

              Comment

              • TrapoSAMA
                Junior Member
                • Aug 2020
                • 16

                #8
                Hi!

                If is only for the log name, how to identified one log with the today day format?

                Thx

                Comment

                • Hamardaban
                  Senior Member
                  Zabbix Certified SpecialistZabbix Certified Professional
                  • May 2019
                  • 2713

                  #9
                  /var/log/2020-09/2020-09-08.log
                  =
                  “^/var/log/2020-09/\d{4}-\d{2}-\d{2}.log$“

                  Comment

                  • jurgen16
                    Junior Member
                    • Jul 2023
                    • 11

                    #10
                    What about for log file that are like this

                    /var/log/containers/container_name_fdsdjkfasdfads5f4s6dfsda65f.log and the way I tried to catch this kind of file log is like this but didn't worked for me: /var/log/containers/container_name_\w{26}.log$

                    Comment

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

                      #11
                      Originally posted by jurgen16
                      What about for log file that are like this

                      /var/log/containers/container_name_fdsdjkfasdfads5f4s6dfsda65f.log and the way I tried to catch this kind of file log is like this but didn't worked for me: /var/log/containers/container_name_\w{26}.log$
                      "\/var\/log\/containers\/container_name_\w{27}.log$"

                      Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET, Rust.

                      Comment

                      Working...