Skip to content

Commit

Permalink
Merge pull request #935 from mountaindude/931
Browse files Browse the repository at this point in the history
931
  • Loading branch information
mountaindude authored Oct 23, 2024
2 parents faa4f95 + f9d8ecb commit 8d3263a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
3 changes: 3 additions & 0 deletions src/butler-sos.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions src/config/production_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 5 additions & 11 deletions src/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/lib/config-file-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const confifgFileSchema = {
properties: {
enable: { type: 'boolean' },
destinationAccount: {
type: 'array',
type: ['array', 'null'],
minItems: 0,
items: {
type: 'string',
Expand Down
14 changes: 9 additions & 5 deletions src/lib/post-to-influxdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
];
Expand Down Expand Up @@ -1000,9 +1000,13 @@ export async function postLogEventToInfluxdb(msg) {
subsystem: msg.subsystem?.length > 0 ? msg.subsystem : '<Unknown>',
method: msg.method?.length > 0 ? msg.method : '<Unknown>',
object_type: msg.object_type?.length > 0 ? msg.object_type : '<Unknown>',
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 : '<Unknown>',
event_activity_source:
msg.event_activity_source?.length > 0
? msg.event_activity_source
: '<Unknown>',
};

// Tags that are empty in some cases. Only add if they are non-empty
Expand Down
7 changes: 5 additions & 2 deletions src/lib/udp-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8d3263a

Please sign in to comment.