diff --git a/src/butler-sos.js b/src/butler-sos.js index bbb60f32..1df2e38e 100755 --- a/src/butler-sos.js +++ b/src/butler-sos.js @@ -54,6 +54,9 @@ async function sleep(ms) { } async function mainScript() { + // Set env variable to indicate that it is ok to change config settings + process.env.ALLOW_CONFIG_MUTATIONS = 'true'; + // Load globals dynamically/async to ensure singleton pattern works const settingsObj = (await import('./globals.js')).default; const globals = await settingsObj.init(); diff --git a/src/config/production_template.yaml b/src/config/production_template.yaml index 8bfdaa6c..3a20562b 100644 --- a/src/config/production_template.yaml +++ b/src/config/production_template.yaml @@ -163,6 +163,8 @@ Butler-SOS: enable: false # Should log events from the repository service be handled? scheduler: enable: false # Should log events from the scheduler service be handled? + qixPerf: + enable: true # Should log events relating to QIX performance be handled? categorise: # Take actions on log events based on their content enable: false rules: # Rules are used to match log events to filters diff --git a/src/globals.js b/src/globals.js index 31df1b82..93445f57 100755 --- a/src/globals.js +++ b/src/globals.js @@ -659,14 +659,6 @@ class Settings { }, tags: tagValuesUserProxySessions, }, - // { - // measurement: 'user_events', - // fields: { - // userFull: Influx.FieldType.STRING, - // userId: Influx.FieldType.STRING - // }, - // tags: ['host', 'event_action', 'userFull', 'userDirectory', 'userId', 'origin'] - // }, ], }); } else if (this.config.get('Butler-SOS.influxdbConfig.version') === 2) { @@ -687,10 +679,12 @@ class Settings { `CONFIG: Influxdb version ${this.config.get('Butler-SOS.influxdbConfig.version')} is not supported!` ); } - } - // Now initialise InfluxDB - await this.initInfluxDB(); + // Now initialise InfluxDB + await this.initInfluxDB(); + } else { + this.logger.info(`CONFIG: Influxdb not enabled, skipping setup of db.`); + } // ------------------------------------ // Create MQTT client object and connect to MQTT broker diff --git a/src/lib/config-file-schema.js b/src/lib/config-file-schema.js index 626a00f9..44135feb 100755 --- a/src/lib/config-file-schema.js +++ b/src/lib/config-file-schema.js @@ -72,7 +72,7 @@ export const confifgFileSchema = { properties: { enable: { type: 'boolean' }, destinationAccount: { - type: 'array', + type: ['array', 'null'], minItems: 0, items: { type: 'string', diff --git a/src/lib/post-to-influxdb.js b/src/lib/post-to-influxdb.js index 3937a6ef..cb219370 100755 --- a/src/lib/post-to-influxdb.js +++ b/src/lib/post-to-influxdb.js @@ -454,9 +454,9 @@ export async function postHealthMetricsToInfluxdb(serverName, host, body, server new Point('cache') .uintField('hits', body.cache.hits) .uintField('lookups', body.cache.lookups) - .uintField('added', body.cache.added) - .uintField('replaced', body.cache.replaced) - .uintField('bytes_added', body.cache.bytes_added), + .intField('added', body.cache.added) + .intField('replaced', body.cache.replaced) + .intField('bytes_added', body.cache.bytes_added), new Point('saturated').booleanField('saturated', body.saturated), ]; @@ -1000,9 +1000,13 @@ export async function postLogEventToInfluxdb(msg) { subsystem: msg.subsystem?.length > 0 ? msg.subsystem : '', method: msg.method?.length > 0 ? msg.method : '', object_type: msg.object_type?.length > 0 ? msg.object_type : '', - proxy_session_id: msg.proxy_session_id?.length > 0 ? msg.proxy_session_id : '-1', + proxy_session_id: + msg.proxy_session_id?.length > 0 ? msg.proxy_session_id : '-1', session_id: msg.session_id?.length > 0 ? msg.session_id : '-1', - event_activity_source: msg.event_activity_source?.length > 0 ? msg.event_activity_source : '', + event_activity_source: + msg.event_activity_source?.length > 0 + ? msg.event_activity_source + : '', }; // Tags that are empty in some cases. Only add if they are non-empty diff --git a/src/lib/udp-event.js b/src/lib/udp-event.js index d5eddfe2..c5480ca2 100644 --- a/src/lib/udp-event.js +++ b/src/lib/udp-event.js @@ -287,8 +287,11 @@ export class UdpEvents { export function setupUdpEventsStorage() { // Is storing event counts to InfluxDB enabled? - if (globals.config.get('Butler-SOS.qlikSenseEvents.influxdb.enable') !== true) { - globals.logger.verbose( + if ( + globals.config.get('Butler-SOS.influxdbConfig.enable') !== true || + globals.config.get('Butler-SOS.qlikSenseEvents.influxdb.enable') !== true + ) { + globals.logger.info( 'EVENT COUNTS: Feature is disabled in config file. Skipping setup of timer for storing event counts to InfluxDB' ); return;