mirror of
https://github.com/rsyslog/loganalyzer.git
synced 2025-09-25 18:59:12 +02:00
Added support for new filtering using REGEXP on supported logstream sources.
Currently MYSQL and PostGRESQL are supported due the native support of REGEXP. Other logstreams or database engines are not supported yet. To use REGEXP in searches, prepend the search phrase with the ~ character.
This commit is contained in:
parent
6adead274c
commit
3080373d4a
@ -1005,6 +1005,15 @@ abstract class LogStream {
|
||||
$myBits |= FILTER_MODE_SEARCHFULL;
|
||||
}
|
||||
|
||||
// If Filter is a REGEX match!
|
||||
$pos = strpos($szValue, "~");
|
||||
if ( $pos !== false && $pos == 0 )
|
||||
{
|
||||
//trunscate -
|
||||
$szValue = substr( $szValue, 1);
|
||||
$myBits |= FILTER_MODE_SEARCHREGEX;
|
||||
}
|
||||
|
||||
// return result
|
||||
return $myBits;
|
||||
}
|
||||
|
@ -801,6 +801,18 @@ class LogStreamDB extends LogStream {
|
||||
}
|
||||
// ---
|
||||
}
|
||||
else if ( $myfilter[FILTER_MODE] & FILTER_MODE_SEARCHREGEX )
|
||||
{
|
||||
// --- Check if user wants to include or exclude!
|
||||
if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE)
|
||||
$addnod = "";
|
||||
else
|
||||
$addnod = " NOT";
|
||||
// ---
|
||||
|
||||
$szSearchBegin = " REGEXP '";
|
||||
$szSearchEnd = "' ";
|
||||
}
|
||||
else
|
||||
{
|
||||
// --- Check if user wants to include or exclude!
|
||||
|
@ -800,6 +800,48 @@ class LogStreamPDO extends LogStream {
|
||||
}
|
||||
// ---
|
||||
}
|
||||
else if ( $myfilter[FILTER_MODE] & FILTER_MODE_SEARCHREGEX )
|
||||
{
|
||||
//REGEXP Supported by MYSQL
|
||||
if ( $this->_logStreamConfigObj->DBType == DB_MYSQL )
|
||||
{
|
||||
// --- Check if user wants to include or exclude!
|
||||
if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE)
|
||||
$addnod = " ";
|
||||
else
|
||||
$addnod = " NOT";
|
||||
// ---
|
||||
|
||||
$szSearchBegin = "REGEXP '";
|
||||
$szSearchEnd = "' ";
|
||||
}
|
||||
//REGEXP Supported by POSTGRESQL
|
||||
else if ( $this->_logStreamConfigObj->DBType == DB_PGSQL )
|
||||
{
|
||||
// --- Check if user wants to include or exclude!
|
||||
if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE)
|
||||
$addnod = " ";
|
||||
else
|
||||
$addnod = " !";
|
||||
// ---
|
||||
|
||||
$szSearchBegin = "~* '";
|
||||
$szSearchEnd = "' ";
|
||||
}
|
||||
else //Fallback use LIKE
|
||||
{
|
||||
// --- Check if user wants to include or exclude!
|
||||
if ( $myfilter[FILTER_MODE] & FILTER_MODE_INCLUDE)
|
||||
$addnod = " ";
|
||||
else
|
||||
$addnod = " NOT";
|
||||
// ---
|
||||
|
||||
// Database Layer does not support REGEXP
|
||||
$szSearchBegin = "LIKE '%";
|
||||
$szSearchEnd = "%' ";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// --- Check if user wants to include or exclude!
|
||||
|
@ -67,6 +67,7 @@ define('FILTER_MODE', 'filtermode');
|
||||
define('FILTER_MODE_INCLUDE', 1);
|
||||
define('FILTER_MODE_EXCLUDE', 2);
|
||||
define('FILTER_MODE_SEARCHFULL', 4);
|
||||
define('FILTER_MODE_SEARCHREGEX', 8);
|
||||
|
||||
// --- Init Facility LIST
|
||||
$content['filter_facility_list'][] = array( "ID" => SYSLOG_KERN, "DisplayName" => "KERN", "selected" => "" );
|
||||
|
Loading…
x
Reference in New Issue
Block a user