Ad Widget

Collapse

Triggers with 'find' function and a regexp don't work properly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zabbixuserfk
    Member
    • Apr 2020
    • 37

    #1

    Triggers with 'find' function and a regexp don't work properly

    Hello,

    I have an issue with triggers using the 'find' function with 'regexp' or 'like' operators and a regular expression pattern on Zabbix 6.4.2.
    The ones using the 'regexp' operator (the Warning and Major on the screenshot) fire whatever is in the log file, while the one using the 'like' operator doesn't fire at all, even if the message matches the pattern...
    The recovery expressions don't work either.

    These triggers have been migrated from a Zabbix 5.0 to a Zabbix 6.4.2.
    Is there something wrong with my syntax please ?​
    Attached Files
  • ISiroshtan
    Senior Member
    • Nov 2019
    • 324

    #2
    Hey there.

    The "like" behavior is expected, as it not uses regex pattern but does actual strings comparison of "pattern" and last value.

    Regarding regex match I don't have a Lab currently to do real life test, but have a gut feeling it's related to double backslash of "I". Any reason for that? Likely it ends up as non backslashed "|" character and as such the whole expression boils down to ".*" matching any string checked.
    Per my understanding it should be a single backslash to treat "|" as actual character and not the regexp "or". If there is some limitation in Zabbix web UI that forces you to use double backslash I would go for a "." character instead of "\\|" combination. quick test with regex101.com seem to indicate it should work (https://regex101.com/r/8m9rJW/1)

    Comment

    • zabbixuserfk
      Member
      • Apr 2020
      • 37

      #3
      Hello,

      Thank you for your answer, I've indeed managed to get around the issue with regexp such as "^CRITICAL.*Remplissage TBS.*$".
      Since it looks like a bug, is there a fix yet or no please ?

      Comment

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

        #4
        If you consider it as bug you are welcome to submit a report https://support.zabbix.com/browse/ZBX

        But I think your double \\-s in problem expression are the reason its not working, as ISiroshtan already pointed...

        Comment

        • zabbixuserfk
          Member
          • Apr 2020
          • 37

          #5
          Hello,

          The double \\-s are placed by Zabbix itself, either when we migrated these triggers from our 5.0 platform and when we use the little "wizard" by clicking the "Add" button next to the expression window (see screenshots below).
          Click image for larger version

Name:	TestTriggerWizard.png
Views:	4629
Size:	19.8 KB
ID:	478913

          Click image for larger version

Name:	TestTriggerExpression.png
Views:	4622
Size:	19.0 KB
ID:	478914

          In addition, it seems impossible to use a single \ to escape a special caracter directly in the expression window (see error below) :
          Click image for larger version

Name:	TestTriggerError.png
Views:	4595
Size:	36.6 KB
ID:	478915

          This is why it looks quite like a bug to me.

          Comment

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

            #6
            When I try to enter this with a wizard, I do not get double \\-s... and I have no issues with saving that created item... 6.0.25 here...
            Click image for larger version

Name:	image.png
Views:	4577
Size:	15.7 KB
ID:	478922
            ​​
            Click image for larger version

Name:	image.png
Views:	4570
Size:	14.6 KB
ID:	478923

            Click image for larger version

Name:	image.png
Views:	4689
Size:	6.1 KB
ID:	478924

            Comment

            • irontmp
              Member
              • Sep 2023
              • 36

              #7
              Originally posted by zabbixuserfk
              Hello,

              I have an issue with triggers using the 'find' function with 'regexp' or 'like' operators and a regular expression pattern on Zabbix 6.4.2.
              The ones using Victron EasySolar-II 48/3000/35-32 MPPT 250/70 GX [49/146] 8.5 Raccordements en option (the Warning and Major on the screenshot) fire whatever is in the log file, while the one using the 'like' operator doesn't fire at all, even if the message matches the pattern...
              The recovery expressions don't work either.

              These triggers have been migrated from a Zabbix 5.0 to a Zabbix 6.4.2.
              Is there something wrong with my syntax please ?
              I'm using a word trigger in one of my macros and I'm using the regular expression check box so I can add regular expressions to my trigger word. Now I'm familiar in programming with perl but it's been a while and I'm not exactly sure how to do this in Mac Droid language. What I have right now is: /locate/i Which will trigger if the macro finds the word locate case insensitive. What I want is if it finds the word locate with or without whitespace after it. How would I write that?

              Comment

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

                #8

                find accepts both "regexp" and "iregexp" for case sensitivity or not...
                regex "locate\s*"
                locate matches the characters locate literally (case sensitive)
                \s matches any whitespace character (equivalent to [\r\n\t\f\v ])
                * matches the previous token between zero and unlimited times, as many times as possible, giving back as needed (greedy)

                Comment

                Working...