Skip to content

Commit

Permalink
Allow to add more events for the logs filtering
Browse files Browse the repository at this point in the history
Update Alignak test configuration
  • Loading branch information
mohierf committed Dec 17, 2019
1 parent a3b2cc1 commit 8951a46
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 10 deletions.
20 changes: 14 additions & 6 deletions module/plugins/logs/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
],

# Services filtering
'logs_services': []
'services': []
}

# Will be populated by the UI with it's own value
Expand All @@ -122,21 +122,29 @@ def load_config(the_app):

plugin_configuration = the_app.get_plugin_config('logs')
for prop, default in list(plugin_configuration.items()):
append = False
# Those are list of strings...
if prop in ['other_fields', 'events', 'hosts', 'logs_services']:
if prop in ['other_fields', 'events_list', 'events', 'hosts', 'services']:
if prop in ['events_list', 'hosts', 'services']:
append = True

if ',' in default:
default = [item.strip() for item in default.split(',')]
else:
default = [default]

params[prop] = default
if append:
params[prop].extend(default)
else:
params[prop] = default

logger.info("[logs] configuration, timestamp field: %s", params['time_field'])
logger.info("[logs] configuration, date format: %s", params['date_format'])
logger.info("[logs] configuration, other fields: %s", params['other_fields'])
logger.info("[logs] configuration, events list: %s", params['events_list'])
logger.info("[logs] configuration, fetching events: %s", params['events'])
logger.info("[logs] configuration, hosts: %s", params['hosts'])
logger.info("[logs] configuration, services: %s", params['logs_services'])
logger.info("[logs] configuration, services: %s", params['services'])

logger.info("[logs] configuration loaded.")

Expand Down Expand Up @@ -167,13 +175,13 @@ def set_services_list():
if app.request.forms.get('cancel'):
app.bottle.redirect("/logs")

params['logs_services'] = []
params['services'] = []

services_list = app.request.forms.getall('servicesList[]')
logger.debug("[logs] Selected services : ")
for service in services_list:
logger.debug("[logs] - service : %s", service)
params['logs_services'].append(service)
params['services'].append(service)

app.bottle.redirect("/logs")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
[module.mongo-logs]
name=mongo-logs
type=mongo-logs
python_name=alignak_module_mongo_logs

statsd_prefix=%(alignak_name)s.modules

# Module log level
;log_level=INFO

# MongoDB connection string
# EXAMPLE
# To describe a connection to a replica set named test, with the following mongod hosts:
# db1.example.net on port 27017 with sysop credentials and
# db2.example.net on port 2500.
# You would use a connection string that resembles the following:
# uri mongodb://sysop:password@db1.example.net,db2.example.net:2500/?replicaSet=test
#
# Default is a non replicated localhost server
#uri mongodb://localhost

# Database name where to store the logs/availability collection
# Default is shinken
#database alignak

# DB connection test period
# Every db_test_period seconds, the module tests if the DB connection is alive
# Default is 0 to skip this test
db_test_period=300

### ------------------------------------------------------------------------
### Logs management
### ------------------------------------------------------------------------
# Logs collection name
# Default is a collection named logs
#logs_collection logs

# Logs rotation
#
# Remove logs older than the specified value
# Value is specified as :
# 1d: 1 day
# 3m: 3 months ...
# d = days, w = weeks, m = months, y = years
# Default is 3 months
#max_logs_age 3m

# Commit volume
# The module commits at most commit_volume logs in the DB at every commit period
# Default is 1000 lines
#commit_volume 1000
commit_volume=10

# Commit period
# Every commit_period seconds, the module stores the received logs in the DB
# Default is to commit every 60 seconds
#commit_period 60

### ------------------------------------------------------------------------
### Hosts/services availability management
### ------------------------------------------------------------------------
# Hosts/services availability collection name
# Default is a collection named availability
#hav_collection availability

# Services filtering
# Filter is declared as a comma separated list of items:
# An item can be a regexp which is matched against service description (hostname/service)
# ^test*, matches all hosts which name starts with test
# /test*, matches all services which name starts with test
#
# An item containing : is a specific filter (only bi is supported currently)
# bi:>x, bi:>=x, bi:<x, bi:<=x, bi:=x to match business impact

# default is to ignore the services
# 2 is the default value for business impact if property is not explicitely declared for a service
# To consider only services with bi>4 (most important services), uncomment this configuration
#services_filter bi:>4
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ database=alignak
;password=

# Logs collection name
logs_collection=ls-logs
logs_collection=logs
;logs_collection=ls-logs
;logs_collection=alignak_events

# Hosts availability collection name
Expand Down Expand Up @@ -156,8 +157,10 @@ plugin.logs.service_description_field=service_description
plugin.logs.other_fields=type, state, state_type, host_name, service_description, command_name, contact_name, plugin_output
# Get only this list of events
plugin.logs.events=HOST ALERT, SERVICE ALERT, HOST NOTIFICATION, SERVICE NOTIFICATION
# Add some more filterable events
plugin.logs.events_list=TIMEPERIOD TRANSITION, RETENTION LOAD, RETENTION SAVE
# Get only events for these hosts
plugin.logs.hosts=docker_shinken
plugin.logs.hosts=
## ----------

;## ----------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ port=7772
; - logs, collect monitoring logs and send them to the Alignak backend
;modules=backend_broker, logs
;modules=webui,ui-graphite2,auth-ws-glpi,alignak-logs
modules=webui
modules=webui,mongo-logs
2 changes: 1 addition & 1 deletion test/test-configurations/alignak/etc/alignak.ini
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ retention_update_interval=5
; ### Note that if it set to 0, the scheduler will never try to clean its queues for oversizing
;tick_clean_queues=10
;tick_update_business_values=60
;tick_reset_topology_change_flags=1
;tick_reset_topo./../y_change_flags=1
;tick_check_for_expire_acknowledge=1
;tick_send_broks_to_modules=1
;tick_get_objects_from_from_queues=1
Expand Down

0 comments on commit 8951a46

Please sign in to comment.