Advanced Log Monitoring

This document describes generic log monitoring based on the advanced log monitoring plugin.

Introduction

This document describes generic log monitoring based on the advanced log monitoring plugin,
which is different from the OpenSource plugin. 

Requirements

The plugin has the requirements to function correctly:

Compatibility matrix

Linux

Systems where it has been tested

Rocky 9

Systems where it should work

Any Linux system supported by PandoraFMS

Windows

Systems where it has been tested

Windows Server 2022

Systems where it should work

Any Windows system supported by PandoraFMS

Configuration parameters

The plugin is configured using an external configuration file. This configuration file has a series of “general” parameters, a series of parameters specific to each record, and a set of parameters specific to each regular expression block.

General parameters

Specific log parameters

Definition of regular expressions

File\sdoes\snot\sexist → Find “File does not exist”
[0-9]*\serrores → Find strings “043 errores”

To understand each element, an example configuration file is shown below.

Linux

# Include, to load extenal/aditional configuration files
# include /tmp/my_other_configuration.conf

# Directory where temporal indexes will be stored (/tmp by default)
#index_dir /tmp

# Log problems with the logparser, (/tmp/pandora_logparser.log by default)
#logfile /tmp/pandora_logparser.log

# Sample of creating a log-type module
log_begin
log_module_name errors file
log_force_readall
log_location_file /var/log/errors.out
log_description get errors
log_type log_module
log_regexp_begin
log_regexp_rule (?i)error
log_regexp_severity CRITICAL
log_return_message Error
log_regexp_end
log_end

# Sample of a single log match
log_begin
log_module_name Weekly
log_location_file /var/log/weekly.out
log_description Errors cannot find
log_type return_lines
log_regexp_begin
log_regexp_rule output
log_regexp_severity WARNING
log_return_message Cannot find process to run
log_regexp_end
log_end

# Sample of wildcard matching of several logfiles within the same module
log_begin
log_rotate_mode md5
log_module_name system_log
log_force_readall
log_location_multiple /var/log/system.log*
log_description Errors cannot find
log_type return_lines
log_regexp_begin
log_regexp_rule Cannot
log_regexp_severity WARNING
log_return_message Cannot find process to run
log_regexp_end
log_end

# Sample of several wildcard matching on the same file
log_begin
log_module_name hits_apache
log_location_file /var/log/apache2
log_description Access log from Apache, we will get the integria access
log_type return_ocurrences
log_regexp_begin
log_regexp_rule Error -($1)\-($2) [0-9a-zA-Z]*
log_regexp_severity WARNING
log_return_message Otro bonito texto de error
log_regexp_end
log_regexp_begin
log_regexp_rule File\sdoes\snot\sexist
log_regexp_severity WARNING
log_regexp_end
log_regexp_begin
log_regexp_rule pandora_backend\.html
log_regexp_severity WARNING
log_return_message Something possible harmful happen
log_regexp_end
log_end

# Sample of wildcard matching of several logfiles with diferent dynamic modules
log_begin
log_rotate_mode inode
log_module_name test_log
log_force_readall
# If enabled, this token will create a different module using the module_name
# provided plus the full logfilename replacing / with " ".
log_create_module_for_each_log
log_location_multiple /tmp/log*/hola*
log_description Errors cannot find
log_type return_lines
log_regexp_begin
log_regexp_rule adios
log_regexp_severity WARNING
log_return_message Cannot find process to run
log_regexp_end
log_end

Windows

# Include external/additional configuration files
# include C:\PandoraFMS\conf\extra.conf

# Temporary index directory
index_dir C:\PandoraFMS\tmp\logparser

# Log file for logparser errors
logfile C:\PandoraFMS\logs\pandora_logparser.log


# Example: log module creation
log_begin
log_module_name errors_file
log_force_readall
log_location_file C:\Logs\errors.log
log_description get_errors
log_type log_module
log_regexp_begin
log_regexp_rule (?i)error
log_regexp_severity CRITICAL
log_return_message Error_detected
log_regexp_end
log_end


# Example: single log file matching
log_begin
log_module_name weekly_log
log_location_file C:\Logs\weekly.log
log_description weekly_errors
log_type return_lines
log_regexp_begin
log_regexp_rule output
log_regexp_severity WARNING
log_return_message Cannot_find_process_to_run
log_regexp_end
log_end


# Example: multiple log files in same module
log_begin
log_rotate_mode md5
log_module_name system_log
log_force_readall
log_location_multiple C:\Logs\system.log*
log_description system_errors
log_type return_lines
log_regexp_begin
log_regexp_rule Cannot
log_regexp_severity WARNING
log_return_message Cannot_find_process_to_run
log_regexp_end
log_end


# Example: multiple patterns in one log file
log_begin
log_module_name apache_access
log_location_file C:\Logs\apache\access.log
log_description apache_access_log
log_type return_occurrences

log_regexp_begin
log_regexp_rule Error\-([0-9]+)
log_regexp_severity WARNING
log_return_message Apache_error_detected
log_regexp_end

log_regexp_begin
log_regexp_rule File\sdoes\snot\sexist
log_regexp_severity WARNING
log_regexp_end

log_regexp_begin
log_regexp_rule pandora_backend\.html
log_regexp_severity WARNING
log_return_message Potential_issue_detected
log_regexp_end

log_end


# Example: dynamic modules for multiple files
log_begin
log_rotate_mode inode
log_module_name test_log_dynamic
log_force_readall

log_create_module_for_each_log
log_location_multiple C:\Logs\app*.log
log_description application_logs
log_type return_lines

log_regexp_begin
log_regexp_rule adios
log_regexp_severity WARNING
log_return_message Match_found
log_regexp_end

log_end

Plugin configuration

Copy the plugins to the agent's plugins directory, distribute them through file collections, or copy them to the Pandora agent folder. Do the same with any additional files that are needed. The plugin execution command within the agent configuration will be similar to this, but using the paths where the plugin and configuration file would be located.

Linux Execution example:

module_plugin /var/opt/PandoraFMS/etc/pandora/plugins/pandora_logparser /var/opt/PandoraFMS/etc/pandora/collections/fc_23/log_example.conf

In Windows it would be the same, but adapted to the paths on your machine:

module_plugin C:\Program Files\PandoraFMS\Pandora Agent\plugins\pandora_logparser.exe C:\Program Files\PandoraFMS\Pandora Agent\collections\fc_23\log_example.conf