Appreciate if anyone can help me in order to identify how to type the correct value in the condition in order to match the log and receive the notification mail.
Also, Is there is any way to use SQL Expressions in this field ?? to be more fixable matching on things or excluding things.
It’s fine for me not to use * at the beginning, just I want to know the best way to use this VALUE field. In syslog I was able to use SQL expressions to match on a specific log and it was too rich as I can filter based on [ XX or YY ], [ XX and YY] at the same condition and so on.
I’m using this value in Syslog using SQL Exp. such as the below:
Here to get notification when the Syslog receives [status of the peer 10.10.10] or [status of the peer 10.8.8]: message LIKE ‘%status of the peer 10.10.10%’ or message LIKE ‘%status of the peer 10.8.8%’
And here if it receives any logs containing SRM excluding logs with TEMPO & TEMPR message LIKE ‘%SRM%’ and message NOT LIKE ‘%TEMPO%’ and message NOT LIKE '%TEMPR%'
Graylog is not working like this (SQL). Elastic search DB is not a full text search, but uses tokenizer (standard tokenizer by default) to analyze data, and you can search only by analyzed data.
So if you enable allow_leading_wildcard_searches = true you can search also inside words with * But beware, that it can use lot of memory and cpu power.
So you can use: message:*SRM* AND NOT message:*TEMPO* AND NOT message:*TEMPR*
or simple: *SRM* AND NOT *TEMPO* AND NOT *TEMPR*
Thanks for your feedback!
I don’t want to use * not to affect the server’s memory and cpu.
Let’s say I have the below log messages: Jul 7 2020 22:04:48 UTO-NPE-NE40E-01 %%01SRM/4/CPUMEMALARM(l):Board 9 CPU usage is Upper than threshold. Jul 7 2020 15:30:14 CFC-UPE-NE40E-X8-01 SRM_BASE/2/PORTPHYSICALUP: OID 1.3.6.1.4.1.2011.5.25.129.2.5.2 Physical state of the port changes to up.
As you can see SRM is within other characters without any spaces, when I use SRM or “SRM” in the VALUE field, the match not happen and so I don’t receive any emails.
How to match on a string such as SRM in the above examples ?
Probably best way is to use regex, you have more options:
/[0-9]+SRM/ - one or more numbers followed by SRM (matches 1. message)
/[0-9]{2}SRM/ - 2 numbers followed by SRM (matches 1. message)
/[0-9]*SRM(_BASE)?/ - match both messages (zero or more numbers optional + SRM + optional _BASE )
/[0-9]*SRM[a-z_]*/ - more general regex, match both mesages (zero or more numbers optional + SRM + string optional)
5./[0-9]*SRM[a-z0-9_]*/ - even more general regex, match both mesages (zero or more numbers optional + SRM + string or numeric optional)