diff --git a/src/lib/incident_mgmt/new_relic.js b/src/lib/incident_mgmt/new_relic.js index f063b574..74480882 100644 --- a/src/lib/incident_mgmt/new_relic.js +++ b/src/lib/incident_mgmt/new_relic.js @@ -605,9 +605,9 @@ export async function sendReloadTaskFailureEvent(reloadParams) { .then(async (rateLimiterRes) => { try { globals.logger.info( - `TASK FAILED NEWRELIC: Rate limiting check passed for failed task event. Task name: "${params.qs_taskName}"`, + `[QSEOW] TASK FAILED NEWRELIC: Rate limiting check passed for failed task event. Task name: "${params.qs_taskName}"`, ); - globals.logger.verbose(`TASK FAILED NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); + globals.logger.verbose(`[QSEOW] TASK FAILED NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); // Get config and needed metadata const incidentConfig = getReloadFailedEventConfig(); @@ -716,16 +716,16 @@ export async function sendReloadTaskFailureEvent(reloadParams) { return null; } catch (err) { if (err.message) { - globals.logger.error(`TASK FAILED NEW RELIC 1 message: ${err.message}`); + globals.logger.error(`[QSEOW] TASK FAILED NEW RELIC 1 message: ${err.message}`); } if (err.stack) { - globals.logger.error(`TASK FAILED NEW RELIC 1 stack: ${err.stack}`); + globals.logger.error(`[QSEOW] TASK FAILED NEW RELIC 1 stack: ${err.stack}`); } // If neither message nor stack is available, just log the error object if (!err.message && !err.stack) { - globals.logger.error(`TASK FAILED NEW RELIC 1: ${JSON.stringify(err, null, 2)}`); + globals.logger.error(`[QSEOW] TASK FAILED NEW RELIC 1: ${JSON.stringify(err, null, 2)}`); } return null; @@ -733,9 +733,9 @@ export async function sendReloadTaskFailureEvent(reloadParams) { }) .catch((rateLimiterRes) => { globals.logger.verbose( - `TASK FAILED NEWRELIC: Rate limiting failed. Not sending reload failure event to New Relic for task "${params.qs_taskName}"`, + `[QSEOW] TASK FAILED NEWRELIC: Rate limiting failed. Not sending reload failure event to New Relic for task "${params.qs_taskName}"`, ); - globals.logger.verbose(`TASK FAILED NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); + globals.logger.verbose(`[QSEOW] TASK FAILED NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); }); } @@ -747,9 +747,9 @@ export async function sendReloadTaskFailureLog(reloadParams) { .then(async (rateLimiterRes) => { try { globals.logger.info( - `TASK FAILED NEWRELIC: Rate limiting check passed for failed task log entry. Task name: "${params.qs_taskName}"`, + `[QSEOW] TASK FAILED NEWRELIC: Rate limiting check passed for failed task log entry. Task name: "${params.qs_taskName}"`, ); - globals.logger.verbose(`TASK FAILED NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); + globals.logger.verbose(`[QSEOW] TASK FAILED NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); // Get config and needed metadata const incidentConfig = getReloadFailedLogConfig(); @@ -832,7 +832,7 @@ export async function sendReloadTaskFailureLog(reloadParams) { } } } catch (err) { - globals.logger.error(`SCRIPTLOG: ${err}`); + globals.logger.error(`[QSEOW] Get value of reload task custom property: ${err}`); } } @@ -856,16 +856,16 @@ export async function sendReloadTaskFailureLog(reloadParams) { return null; } catch (err) { if (err.message) { - globals.logger.error(`TASK FAILED NEW RELIC 2 message: ${err.message}`); + globals.logger.error(`[QSEOW] TASK FAILED NEW RELIC 2 message: ${err.message}`); } if (err.stack) { - globals.logger.error(`TASK FAILED NEW RELIC 2 stack: ${err.stack}`); + globals.logger.error(`[QSEOW] TASK FAILED NEW RELIC 2 stack: ${err.stack}`); } // If neither message nor stack is available, just log the error object if (!err.message && !err.stack) { - globals.logger.error(`TASK FAILED NEW RELIC 2: ${JSON.stringify(err, null, 2)}`); + globals.logger.error(`[QSEOW] TASK FAILED NEW RELIC 2: ${JSON.stringify(err, null, 2)}`); } return null; @@ -873,9 +873,9 @@ export async function sendReloadTaskFailureLog(reloadParams) { }) .catch((rateLimiterRes) => { globals.logger.verbose( - `TASK FAILED NEWRELIC: Rate limiting failed. Not sending reload failure log entry to New Relic for task "${params.qs_taskName}"`, + `[QSEOW] TASK FAILED NEWRELIC: Rate limiting failed. Not sending reload failure log entry to New Relic for task "${params.qs_taskName}"`, ); - globals.logger.verbose(`TASK FAILED NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); + globals.logger.verbose(`[QSEOW] TASK FAILED NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); }); } @@ -887,9 +887,9 @@ export function sendReloadTaskAbortedEvent(reloadParams) { .then(async (rateLimiterRes) => { try { globals.logger.info( - `TASK ABORT NEWRELIC: Rate limiting check passed for abort task event. Task name: "${params.qs_taskName}"`, + `[QSEOW] TASK ABORT NEWRELIC: Rate limiting check passed for abort task event. Task name: "${params.qs_taskName}"`, ); - globals.logger.verbose(`TASK ABORT NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); + globals.logger.verbose(`[QSEOW] TASK ABORT NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); // Get config and needed metadata const incidentConfig = getReloadAbortedEventConfig(); @@ -974,7 +974,7 @@ export function sendReloadTaskAbortedEvent(reloadParams) { } } } catch (err) { - globals.logger.error(`SCRIPTLOG: ${err}`); + globals.logger.error(`[QSEOW] Get custom property for reload task: ${err}`); } } @@ -998,16 +998,16 @@ export function sendReloadTaskAbortedEvent(reloadParams) { return null; } catch (err) { if (err.message) { - globals.logger.error(`TASK ABORT NEW RELIC 1 message: ${err.message}`); + globals.logger.error(`[QSEOW] TASK ABORT NEW RELIC 1 message: ${err.message}`); } if (err.stack) { - globals.logger.error(`TASK ABORT NEW RELIC 1 stack: ${err.stack}`); + globals.logger.error(`[QSEOW] TASK ABORT NEW RELIC 1 stack: ${err.stack}`); } // If neither message nor stack is available, just log the error object if (!err.message && !err.stack) { - globals.logger.error(`TASK ABORT NEW RELIC 1: ${JSON.stringify(err, null, 2)}`); + globals.logger.error(`[QSEOW] TASK ABORT NEW RELIC 1: ${JSON.stringify(err, null, 2)}`); } return null; @@ -1015,9 +1015,9 @@ export function sendReloadTaskAbortedEvent(reloadParams) { }) .catch((rateLimiterRes) => { globals.logger.verbose( - `TASK ABORT NEWRELIC: Rate limiting failed. Not sending reload aborted event to New Relic for task "${params.qs_taskName}"`, + `[QSEOW] TASK ABORT NEWRELIC: Rate limiting failed. Not sending reload aborted event to New Relic for task "${params.qs_taskName}"`, ); - globals.logger.verbose(`TASK ABORT NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); + globals.logger.verbose(`[QSEOW] TASK ABORT NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); }); } @@ -1029,9 +1029,9 @@ export function sendReloadTaskAbortedLog(reloadParams) { .then(async (rateLimiterRes) => { try { globals.logger.info( - `TASK ABORT NEWRELIC: Rate limiting check passed for abort task log entry. Task name: "${params.qs_taskName}"`, + `[QSEOW] TASK ABORT NEWRELIC: Rate limiting check passed for abort task log entry. Task name: "${params.qs_taskName}"`, ); - globals.logger.verbose(`TASK ABORT NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); + globals.logger.verbose(`[QSEOW] TASK ABORT NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); // Get config and needed metadata const incidentConfig = getReloadAbortedLogConfig(); @@ -1116,7 +1116,7 @@ export function sendReloadTaskAbortedLog(reloadParams) { } } } catch (err) { - globals.logger.error(`SCRIPTLOG: ${err}`); + globals.logger.error(`[QSEOW] Get custom property for reload task: ${err}`); } } @@ -1140,16 +1140,16 @@ export function sendReloadTaskAbortedLog(reloadParams) { return null; } catch (err) { if (err.message) { - globals.logger.error(`TASK ABORT NEW RELIC 2 message: ${err.message}`); + globals.logger.error(`[QSEOW] TASK ABORT NEW RELIC 2 message: ${err.message}`); } if (err.stack) { - globals.logger.error(`TASK ABORT NEW RELIC 2 stack: ${err.stack}`); + globals.logger.error(`[QSEOW] TASK ABORT NEW RELIC 2 stack: ${err.stack}`); } // If neither message nor stack is available, just log the error object if (!err.message && !err.stack) { - globals.logger.error(`TASK ABORT NEW RELIC 2: ${JSON.stringify(err, null, 2)}`); + globals.logger.error(`[QSEOW] TASK ABORT NEW RELIC 2: ${JSON.stringify(err, null, 2)}`); } return null; @@ -1157,8 +1157,8 @@ export function sendReloadTaskAbortedLog(reloadParams) { }) .catch((rateLimiterRes) => { globals.logger.verbose( - `TASK ABORT NEWRELIC: Rate limiting failed. Not sending reload abort log entry to New Relic for task "${params.qs_taskName}"`, + `[QSEOW] TASK ABORT NEWRELIC: Rate limiting failed. Not sending reload abort log entry to New Relic for task "${params.qs_taskName}"`, ); - globals.logger.verbose(`TASK ABORT NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); + globals.logger.verbose(`[QSEOW] TASK ABORT NEWRELIC: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); }); } diff --git a/src/lib/post_to_influxdb.js b/src/lib/post_to_influxdb.js index eb727b2b..7262cec5 100755 --- a/src/lib/post_to_influxdb.js +++ b/src/lib/post_to_influxdb.js @@ -65,7 +65,7 @@ export function postButlerMemoryUsageToInfluxdb(memory) { // copyrightYearRange: "1993-2024", // } export async function postQlikSenseVersionToInfluxDB(qlikSenseVersion) { - globals.logger.verbose('INFLUXDB QLIK SENSE VERSION: Sending Qlik Sense version to InfluxDB'); + globals.logger.verbose('[QSEOW] INFLUXDB QLIK SENSE VERSION: Sending Qlik Sense version to InfluxDB'); // Get tags from config file // Stored in array Butler.qlikSenseVersion.versionMonitor.destination.influxDb.tag @@ -118,10 +118,12 @@ export async function postQlikSenseVersionToInfluxDB(qlikSenseVersion) { const deepClonedDatapoint = _.cloneDeep(datapoint); await globals.influx.writePoints(deepClonedDatapoint); - globals.logger.silly(`INFLUXDB QLIK SENSE VERSION: Influxdb datapoint for Qlik Sense version: ${JSON.stringify(datapoint, null, 2)}`); + globals.logger.silly( + `[QSEOW] INFLUXDB QLIK SENSE VERSION: Influxdb datapoint for Qlik Sense version: ${JSON.stringify(datapoint, null, 2)}`, + ); datapoint = null; - globals.logger.verbose('INFLUXDB QLIK SENSE VERSION: Sent Qlik Sense version to InfluxDB'); + globals.logger.verbose('[QSEOW] INFLUXDB QLIK SENSE VERSION: Sent Qlik Sense version to InfluxDB'); } // Function to store Qlik Sense server license status to InfluxDB @@ -133,7 +135,7 @@ export async function postQlikSenseVersionToInfluxDB(qlikSenseVersion) { // "daysUntilExpiry": , // } export async function postQlikSenseServerLicenseStatusToInfluxDB(qlikSenseServerLicenseStatus) { - globals.logger.verbose('INFLUXDB QLIK SENSE SERVER LICENSE STATUS: Sending Qlik Sense server license status to InfluxDB'); + globals.logger.verbose('[QSEOW] INFLUXDB QLIK SENSE SERVER LICENSE STATUS: Sending Qlik Sense server license status to InfluxDB'); // Get tags from config file // Stored in array Butler.qlikSenseLicense.serverLicenseMonitor.destination.influxDb.tag @@ -182,7 +184,7 @@ export async function postQlikSenseServerLicenseStatusToInfluxDB(qlikSenseServer await globals.influx.writePoints(deepClonedDatapoint); globals.logger.silly( - `INFLUXDB QLIK SENSE SERVER LICENSE STATUS: Influxdb datapoint for Qlik Sense server license status: ${JSON.stringify( + `[QSEOW] INFLUXDB QLIK SENSE SERVER LICENSE STATUS: Influxdb datapoint for Qlik Sense server license status: ${JSON.stringify( datapoint, null, 2, @@ -190,7 +192,7 @@ export async function postQlikSenseServerLicenseStatusToInfluxDB(qlikSenseServer ); datapoint = null; - globals.logger.verbose('INFLUXDB QLIK SENSE SERVER LICENSE STATUS: Sent Qlik Sense server license status to InfluxDB'); + globals.logger.verbose('[QSEOW] INFLUXDB QLIK SENSE SERVER LICENSE STATUS: Sent Qlik Sense server license status to InfluxDB'); } // Function to store Qlik Sense access license status to InfluxDB @@ -245,7 +247,7 @@ export async function postQlikSenseServerLicenseStatusToInfluxDB(qlikSenseServer // "schemaPath": "AccessTypeOverview" // } export async function postQlikSenseLicenseStatusToInfluxDB(qlikSenseLicenseStatus) { - globals.logger.verbose('INFLUXDB QLIK SENSE LICENSE STATUS: Sending Qlik Sense license status to InfluxDB'); + globals.logger.verbose('[QSEOW] INFLUXDB QLIK SENSE LICENSE STATUS: Sending Qlik Sense license status to InfluxDB'); // Get tags from config file // Stored in array Butler.qlikSenseLicense.licenseMonitor.destination.influxDb.tag @@ -396,16 +398,16 @@ export async function postQlikSenseLicenseStatusToInfluxDB(qlikSenseLicenseStatu await globals.influx.writePoints(deepClonedDatapoint); globals.logger.silly( - `INFLUXDB QLIK SENSE LICENSE STATUS: Influxdb datapoint for Qlik Sense license status: ${JSON.stringify(datapoint, null, 2)}`, + `[QSEOW] INFLUXDB QLIK SENSE LICENSE STATUS: Influxdb datapoint for Qlik Sense license status: ${JSON.stringify(datapoint, null, 2)}`, ); datapoint = null; - globals.logger.info('INFLUXDB QLIK SENSE LICENSE STATUS: Sent aggregated Qlik Sense license status to InfluxDB'); + globals.logger.info('[QSEOW] INFLUXDB QLIK SENSE LICENSE STATUS: Sent aggregated Qlik Sense license status to InfluxDB'); } // Function to store info about released Qlik Sense licenses to InfluxDB export async function postQlikSenseLicenseReleasedToInfluxDB(licenseInfo) { - globals.logger.verbose('INFLUXDB QLIK SENSE LICENSE RELEASE: Sending info on released Qlik Sense license to InfluxDB'); + globals.logger.verbose('[QSEOW] INFLUXDB QLIK SENSE LICENSE RELEASE: Sending info on released Qlik Sense license to InfluxDB'); // Get tags from config file // Stored in array Butler.qlikSenseLicense.licenseMonitor.destination.influxDb.tag @@ -453,11 +455,11 @@ export async function postQlikSenseLicenseReleasedToInfluxDB(licenseInfo) { await globals.influx.writePoints(deepClonedDatapoint); globals.logger.silly( - `INFLUXDB QLIK SENSE LICENSE RELEASE: Influxdb datapoint for released Qlik Sense license: ${JSON.stringify(datapoint, null, 2)}`, + `[QSEOW] INFLUXDB QLIK SENSE LICENSE RELEASE: Influxdb datapoint for released Qlik Sense license: ${JSON.stringify(datapoint, null, 2)}`, ); datapoint = null; - globals.logger.debug('INFLUXDB QLIK SENSE LICENSE RELEASE: Sent info on released Qlik Sense license to InfluxDB'); + globals.logger.debug('[QSEOW] INFLUXDB QLIK SENSE LICENSE RELEASE: Sent info on released Qlik Sense license to InfluxDB'); } // Function to store windows service status to InfluxDB @@ -546,7 +548,7 @@ export function postWindowsServiceStatusToInfluxDB(serviceStatus) { // Store information about successful reload tasks to InfluxDB export function postReloadTaskSuccessNotificationInfluxDb(reloadParams) { try { - globals.logger.verbose('INFLUXDB RELOAD TASK SUCCESS: Sending reload task notification to InfluxDB'); + globals.logger.verbose('[QSEOW] INFLUXDB RELOAD TASK SUCCESS: Sending reload task notification to InfluxDB'); // Add tags let tags = {}; @@ -587,7 +589,7 @@ export function postReloadTaskSuccessNotificationInfluxDb(reloadParams) { // Get task info const { taskInfo } = reloadParams; - globals.logger.debug(`INFLUXDB RELOAD TASK SUCCESS: Task info:\n${JSON.stringify(taskInfo, null, 2)}`); + globals.logger.debug(`[QSEOW] INFLUXDB RELOAD TASK SUCCESS: Task info:\n${JSON.stringify(taskInfo, null, 2)}`); // Use task info to enrich log entry sent to InfluxDB datapoint[0].tags.task_executingNodeName = taskInfo.executingNodeName; @@ -650,24 +652,26 @@ export function postReloadTaskSuccessNotificationInfluxDb(reloadParams) { .then(() => { globals.logger.silly( - `INFLUXDB RELOAD TASK SUCCESS: Influxdb datapoint for reload task notification: ${JSON.stringify(datapoint, null, 2)}`, + `[QSEOW] INFLUXDB RELOAD TASK SUCCESS: Influxdb datapoint for reload task notification: ${JSON.stringify(datapoint, null, 2)}`, ); datapoint = null; - globals.logger.verbose('INFLUXDB RELOAD TASK SUCCESS: Sent reload task notification to InfluxDB'); + globals.logger.verbose('[QSEOW] INFLUXDB RELOAD TASK SUCCESS: Sent reload task notification to InfluxDB'); }) .catch((err) => { - globals.logger.error(`INFLUXDB RELOAD TASK SUCCESS: Error saving reload task notification to InfluxDB! ${err.stack}`); + globals.logger.error( + `[QSEOW] INFLUXDB RELOAD TASK SUCCESS: Error saving reload task notification to InfluxDB! ${err.stack}`, + ); }); } catch (err) { - globals.logger.error(`INFLUXDB RELOAD TASK SUCCESS: ${err}`); + globals.logger.error(`[QSEOW] INFLUXDB RELOAD TASK SUCCESS: ${err}`); } } // Store information about failed reload tasks to InfluxDB export function postReloadTaskFailureNotificationInfluxDb(reloadParams) { try { - globals.logger.info('INFLUXDB RELOAD TASK FAILED: Sending reload task notification to InfluxDB'); + globals.logger.info('[QSEOW] INFLUXDB RELOAD TASK FAILED: Sending reload task notification to InfluxDB'); // Add tags let tags = {}; @@ -721,7 +725,7 @@ export function postReloadTaskFailureNotificationInfluxDb(reloadParams) { scriptLogData.scriptLogTail = ''; } - globals.logger.debug(`INFLUXDB RELOAD TASK FAILED: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`); + globals.logger.debug(`[QSEOW] INFLUXDB RELOAD TASK FAILED: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`); // Use script log data to enrich log entry sent to InfluxDB datapoint[0].tags.task_executingNodeName = scriptLogData.executingNodeName; @@ -793,16 +797,18 @@ export function postReloadTaskFailureNotificationInfluxDb(reloadParams) { .then(() => { globals.logger.silly( - `INFLUXDB RELOAD TASK FAILED: Influxdb datapoint for reload task notification: ${JSON.stringify(datapoint, null, 2)}`, + `[QSEOW] INFLUXDB RELOAD TASK FAILED: Influxdb datapoint for reload task notification: ${JSON.stringify(datapoint, null, 2)}`, ); datapoint = null; - globals.logger.verbose('INFLUXDB RELOAD TASK FAILED: Sent reload task notification to InfluxDB'); + globals.logger.verbose('[QSEOW] INFLUXDB RELOAD TASK FAILED: Sent reload task notification to InfluxDB'); }) .catch((err) => { - globals.logger.error(`INFLUXDB RELOAD TASK FAILED: Error saving reload task notification to InfluxDB! ${err.stack}`); + globals.logger.error( + `[QSEOW] INFLUXDB RELOAD TASK FAILED: Error saving reload task notification to InfluxDB! ${err.stack}`, + ); }); } catch (err) { - globals.logger.error(`INFLUXDB RELOAD TASK FAILED: ${err}`); + globals.logger.error(`[QSEOW] INFLUXDB RELOAD TASK FAILED: ${err}`); } } diff --git a/src/lib/qscloud/api/app.js b/src/lib/qscloud/api/app.js index 84adc517..e6cdae5d 100644 --- a/src/lib/qscloud/api/app.js +++ b/src/lib/qscloud/api/app.js @@ -1,7 +1,6 @@ -/* eslint-disable import/prefer-default-export */ import axios from 'axios'; import globals from '../../../globals.js'; -import { verifyGuid } from '../../guid_util.js'; +import { verifyGuid } from '../../guid_util.js'; // Function to get info about a specific Qlik Sense Cloud app // Parameters: @@ -10,7 +9,7 @@ export async function getQlikSenseCloudAppInfo(appId) { try { // Make sure appId is valid GUID. If not, log error and return false if (verifyGuid(appId) === false) { - globals.logger.error(`SENSE CLOUD GET APP ITEMS: Invalid appId: ${appId}`); + globals.logger.error(`[QSCLOUD] SENSE CLOUD GET APP ITEMS: Invalid appId: ${appId}`); return false; } @@ -30,7 +29,7 @@ export async function getQlikSenseCloudAppInfo(appId) { return appInfo; } catch (err) { - globals.logger.error(`SENSE CLOUD GET APP INFO: ${err}`); + globals.logger.error(`[QSCLOUD] SENSE CLOUD GET APP INFO: ${err}`); return false; } } @@ -42,7 +41,7 @@ export async function getQlikSenseCloudAppMetadata(appId) { try { // Make sure appId is valid GUID. If not, log error and return false if (verifyGuid(appId) === false) { - globals.logger.error(`SENSE CLOUD GET APP ITEMS: Invalid appId: ${appId}`); + globals.logger.error(`[QSCLOUD] SENSE CLOUD GET APP ITEMS: Invalid appId: ${appId}`); return false; } @@ -62,7 +61,7 @@ export async function getQlikSenseCloudAppMetadata(appId) { return appMetadata; } catch (err) { - globals.logger.error(`SENSE CLOUD GET APP METADATA: ${err}`); + globals.logger.error(`[QSCLOUD] SENSE CLOUD GET APP METADATA: ${err}`); return false; } } @@ -74,7 +73,7 @@ export async function getQlikSenseCloudAppItems(appId) { try { // Make sure appId is valid GUID. If not, log error and return false if (verifyGuid(appId) === false) { - globals.logger.error(`SENSE CLOUD GET APP ITEMS: Invalid appId: ${appId}`); + globals.logger.error(`[QSCLOUD] SENSE CLOUD GET APP ITEMS: Invalid appId: ${appId}`); return false; } @@ -105,7 +104,7 @@ export async function getQlikSenseCloudAppItems(appId) { return appItems; } catch (err) { - globals.logger.error(`Qlik SENSE CLOUD GET SCRIPT LOG: ${err}`); + globals.logger.error(`[QSCLOUD] Qlik SENSE CLOUD GET SCRIPT LOG: ${err}`); return false; } } diff --git a/src/lib/qscloud/api/appreloadinfo.js b/src/lib/qscloud/api/appreloadinfo.js index 7f268d43..d6fa3f89 100644 --- a/src/lib/qscloud/api/appreloadinfo.js +++ b/src/lib/qscloud/api/appreloadinfo.js @@ -26,14 +26,14 @@ export async function getQlikSenseCloudAppReloadScriptLog(appId, reloadId) { // Get number of lines in scriptLogFull const scriptLogLineCount = scriptLogFull.length; - globals.logger.verbose('QLIK SENSE CLOUD GET SCRIPT LOG: Done getting script log'); + globals.logger.verbose('[QSCLOUD] QLIK SENSE CLOUD GET SCRIPT LOG: Done getting script log'); return { scriptLogFull, scriptLogSize: scriptLogLineCount, }; } catch (err) { - globals.logger.error(`QLIK SENSE CLOUD GET SCRIPT LOG: ${err}`); + globals.logger.error(`[QSCLOUD] QLIK SENSE CLOUD GET SCRIPT LOG: ${err}`); return false; } } @@ -45,7 +45,7 @@ export async function getQlikSenseCloudAppReloadScriptLog(appId, reloadId) { export function getQlikSenseCloudAppReloadScriptLogHead(scriptLogFull, headLineCount) { if (headLineCount > 0) { const scriptLogHead = scriptLogFull.slice(0, headLineCount).join('\r\n'); - globals.logger.debug(`QLIK SENSE CLOUD GET SCRIPT LOG: Script log head:\n${scriptLogHead}`); + globals.logger.debug(`[QSCLOUD] QLIK SENSE CLOUD GET SCRIPT LOG: Script log head:\n${scriptLogHead}`); return scriptLogHead; } else { @@ -60,7 +60,7 @@ export function getQlikSenseCloudAppReloadScriptLogHead(scriptLogFull, headLineC export function getQlikSenseCloudAppReloadScriptLogTail(scriptLogFull, tailLineCount) { if (tailLineCount > 0) { const scriptLogTail = scriptLogFull.slice(Math.max(scriptLogFull.length - tailLineCount, 0)).join('\r\n'); - globals.logger.debug(`QLIK SENSE CLOUD GET SCRIPT LOG: Script log tails:\n${scriptLogTail}`); + globals.logger.debug(`[QSCLOUD] QLIK SENSE CLOUD GET SCRIPT LOG: Script log tails:\n${scriptLogTail}`); return scriptLogTail; } else { @@ -138,7 +138,7 @@ export async function getQlikSenseCloudAppReloadInfo(reloadId) { return reloadInfo; } catch (err) { - globals.logger.error(`Qlik SENSE CLOUD GET RELOAD INFO: ${err}`); + globals.logger.error(`[QSCLOUD] Qlik SENSE CLOUD GET RELOAD INFO: ${err}`); return false; } } diff --git a/src/lib/qscloud/api/user.js b/src/lib/qscloud/api/user.js index b505f7ac..7c6ea989 100644 --- a/src/lib/qscloud/api/user.js +++ b/src/lib/qscloud/api/user.js @@ -1,4 +1,3 @@ -/* eslint-disable import/prefer-default-export */ import axios from 'axios'; import globals from '../../../globals.js'; @@ -24,7 +23,7 @@ export async function getQlikSenseCloudUserInfo(userId) { return appInfo; } catch (err) { - globals.logger.error(`Qlik SENSE CLOUD GET SCRIPT LOG: ${err}`); + globals.logger.error(`[QSCLOUD] Qlik SENSE CLOUD GET SCRIPT LOG: ${err}`); return false; } } \ No newline at end of file diff --git a/src/lib/qscloud/email_notification_qscloud.js b/src/lib/qscloud/email_notification_qscloud.js index 007e6621..480c375d 100644 --- a/src/lib/qscloud/email_notification_qscloud.js +++ b/src/lib/qscloud/email_notification_qscloud.js @@ -28,7 +28,7 @@ function getAppReloadFailedEmailConfig() { // Is email alerts on failed reloads enabled? if (!globals.config.get('Butler.qlikSenseCloud.event.mqtt.tenant.alert.emailNotification.reloadAppFailure.enable')) { globals.logger.error( - 'EMAIL ALERT - QS CLOUD APP RELOAD FAILED: Email alerts on failed reloads are disabled in the config file.', + '[QSCLOUD] EMAIL ALERT - APP RELOAD FAILED: Email alerts on failed reloads are disabled in the config file.', ); return false; } @@ -69,7 +69,7 @@ function getAppReloadFailedEmailConfig() { ), }; } catch (err) { - globals.logger.error(`EMAIL ALERT - QS CLOUD APP RELOAD FAILED: ${err}`); + globals.logger.error(`[QSCLOUD] EMAIL ALERT - APP RELOAD FAILED: ${err}`); return false; } } @@ -78,7 +78,7 @@ function getAppReloadFailedEmailConfig() { export async function sendQlikSenseCloudAppReloadFailureNotificationEmail(reloadParams) { try { globals.logger.info( - `EMAIL ALERT - QS CLOUD APP RELOAD FAILED: Rate limiting check passed for failed task notification. App name: "${reloadParams.appName}"`, + `[QSCLOUD] EMAIL ALERT - APP RELOAD FAILED: Rate limiting check passed for failed task notification. App name: "${reloadParams.appName}"`, ); // Logic for determining if alert email should be sent or not @@ -131,7 +131,7 @@ export async function sendQlikSenseCloudAppReloadFailureNotificationEmail(reload if (appTags === undefined || appTags?.length === 0 || appHasAlertTag === undefined) { globals.logger.warn( - `EMAIL ALERT - QS CLOUD APP RELOAD FAILED: App [${reloadParams.appId}] "${reloadParams.appName}" does not have the tag "${alertTag}" set. Not sending alert email based on app tag.`, + `[QSCLOUD] EMAIL ALERT - APP RELOAD FAILED: App [${reloadParams.appId}] "${reloadParams.appName}" does not have the tag "${alertTag}" set. Not sending alert email based on app tag.`, ); } else if (appHasAlertTag !== undefined) { if (emailConfig?.globalSendList?.length > 0) { @@ -151,7 +151,7 @@ export async function sendQlikSenseCloudAppReloadFailureNotificationEmail(reload if (appOwner.email === undefined || appOwner?.email?.length === 0) { globals.logger.warn( - `EMAIL ALERT - QS CLOUD APP RELOAD FAILED: App owner email address is not set for app [${reloadParams.appId}] "${reloadParams.appName}". Not sending alert email to app owner "${appOwner.name}".`, + `[QSCLOUD] EMAIL ALERT - APP RELOAD FAILED: App owner email address is not set for app [${reloadParams.appId}] "${reloadParams.appName}". Not sending alert email to app owner "${appOwner.name}".`, ); } else { // App owner email address exists. @@ -198,7 +198,7 @@ export async function sendQlikSenseCloudAppReloadFailureNotificationEmail(reload // Check if we have any email addresses to send to if (globalSendList?.length === 0) { globals.logger.warn( - `EMAIL ALERT - QS CLOUD APP RELOAD FAILED: No email addresses found to send alert email for app [${reloadParams.appId}] "${reloadParams.appName}".`, + `[QSCLOUD] EMAIL ALERT - APP RELOAD FAILED: No email addresses found to send alert email for app [${reloadParams.appId}] "${reloadParams.appName}".`, ); return false; } @@ -236,9 +236,15 @@ export async function sendQlikSenseCloudAppReloadFailureNotificationEmail(reload // Get length of entire script log (character count) scriptLogData.scriptLogSizeCharacters = reloadParams.scriptLog.scriptLogFull.join('').length; - // Get the first and last rows of the script log - scriptLogData.scriptLogHead = getQlikSenseCloudAppReloadScriptLogHead(reloadParams.scriptLog.scriptLogFull, scriptLogData.scriptLogHeadCount); - scriptLogData.scriptLogTail = getQlikSenseCloudAppReloadScriptLogTail(reloadParams.scriptLog.scriptLogFull, scriptLogData.scriptLogTailCount); + // Get the first and last rows of the script log + scriptLogData.scriptLogHead = getQlikSenseCloudAppReloadScriptLogHead( + reloadParams.scriptLog.scriptLogFull, + scriptLogData.scriptLogHeadCount, + ); + scriptLogData.scriptLogTail = getQlikSenseCloudAppReloadScriptLogTail( + reloadParams.scriptLog.scriptLogFull, + scriptLogData.scriptLogTailCount, + ); } else { scriptLogData.scriptLogHead = ''; scriptLogData.scriptLogTail = ''; @@ -246,7 +252,7 @@ export async function sendQlikSenseCloudAppReloadFailureNotificationEmail(reload scriptLogData.scriptLogSizeCharacters = 0; } - globals.logger.debug(`EMAIL ALERT - QS CLOUD APP RELOAD FAILED: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`); + globals.logger.debug(`[QSCLOUD] EMAIL ALERT - APP RELOAD FAILED: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`); } // Format log message line breaks to work in HTML email @@ -336,9 +342,11 @@ export async function sendQlikSenseCloudAppReloadFailureNotificationEmail(reload .then(async (rateLimiterRes) => { try { globals.logger.info( - `EMAIL ALERT - QS CLOUD: Rate limiting check passed for failed app reload notification. App name: "${reloadParams.appName}", email: "${recipientEmailAddress}"`, + `[QSCLOUD] EMAIL ALERT - QS CLOUD: Rate limiting check passed for failed app reload notification. App name: "${reloadParams.appName}", email: "${recipientEmailAddress}"`, + ); + globals.logger.debug( + `[QSCLOUD] EMAIL ALERT - QS CLOUD: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); - globals.logger.debug(`EMAIL ALERT - QS CLOUD: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); // Only send email if there is an actual email address if (recipientEmailAddress?.length > 0) { @@ -353,24 +361,24 @@ export async function sendQlikSenseCloudAppReloadFailureNotificationEmail(reload ); } else { globals.logger.warn( - `EMAIL ALERT - QS CLOUD APP RELOAD FAILED: No email address found for app [${reloadParams.appId}] "${reloadParams.appName}". Not sending alert email.`, + `[QSCLOUD] EMAIL ALERT - APP RELOAD FAILED: No email address found for app [${reloadParams.appId}] "${reloadParams.appName}". Not sending alert email.`, ); } } catch (err) { - globals.logger.error(`EMAIL ALERT - QS CLOUD APP RELOAD FAILED: ${err}`); + globals.logger.error(`[QSCLOUD] EMAIL ALERT - APP RELOAD FAILED: ${err}`); } }) .catch((err) => { globals.logger.warn( - `EMAIL ALERT - QS CLOUD APP RELOAD FAILED: Rate limiting failed. Not sending reload notification email for app [${reloadParams.appId}] "${reloadParams.appName}"`, + `[QSCLOUD] EMAIL ALERT - APP RELOAD FAILED: Rate limiting failed. Not sending reload notification email for app [${reloadParams.appId}] "${reloadParams.appName}"`, ); globals.logger.debug( - `EMAIL ALERT - QS CLOUD APP RELOAD FAILED: Rate limiting details "${JSON.stringify(err, null, 2)}"`, + `[QSCLOUD] EMAIL ALERT - APP RELOAD FAILED: Rate limiting details "${JSON.stringify(err, null, 2)}"`, ); }); } } catch (err) { - globals.logger.error(`EMAIL ALERT - QS CLOUD APP RELOAD FAILED: ${err}`); + globals.logger.error(`[QSCLOUD] EMAIL ALERT - APP RELOAD FAILED: ${err}`); } return true; diff --git a/src/lib/qscloud/mqtt_event_app_reload_finished.js b/src/lib/qscloud/mqtt_event_app_reload_finished.js index 522c62b7..e91e2829 100644 --- a/src/lib/qscloud/mqtt_event_app_reload_finished.js +++ b/src/lib/qscloud/mqtt_event_app_reload_finished.js @@ -2,10 +2,7 @@ import path from 'path'; import fs from 'fs'; import globals from '../../globals.js'; -import { - getQlikSenseCloudAppReloadScriptLog, - getQlikSenseCloudAppReloadInfo, -} from './api/appreloadinfo.js'; +import { getQlikSenseCloudAppReloadScriptLog, getQlikSenseCloudAppReloadInfo } from './api/appreloadinfo.js'; import { getQlikSenseCloudAppInfo, getQlikSenseCloudAppMetadata, getQlikSenseCloudAppItems } from './api/app.js'; import { sendQlikSenseCloudAppReloadFailureNotificationTeams } from './msteams_notification_qscloud.js'; import { sendQlikSenseCloudAppReloadFailureNotificationSlack } from './slack_notification_qscloud.js'; @@ -60,7 +57,7 @@ export async function handleQlikSenseCloudAppReloadFinished(message) { // Valid tenant ID is defined in the Butler configuration file if (!monitoredTenants.some((tenant) => tenant.id === tenantId)) { logger.warn( - `QLIK SENSE CLOUD: Incoming MQTT event from Qlik Sense Cloud, but tenant ID "${tenantId}" is not defined in the Butler configuration file. Skipping event.`, + `[QSCLOUD] Incoming MQTT event from Qlik Sense Cloud, but tenant ID "${tenantId}" is not defined in the Butler configuration file. Skipping event.`, ); return false; } @@ -81,7 +78,7 @@ export async function handleQlikSenseCloudAppReloadFinished(message) { let appItems = {}; // App reload did fail. Send enabled notifications/alerts, store script log etc - logger.info(`QLIK SENSE CLOUD: App reload failed. App ID=[${appId}] name="${message.data.name}"`); + logger.info(`[QSCLOUD] App reload failed. App ID=[${appId}] name="${message.data.name}"`); // Are notifications from QS Cloud enabled? if (globals.config.get('Butler.qlikSenseCloud.enable') === true) { @@ -96,16 +93,16 @@ export async function handleQlikSenseCloudAppReloadFinished(message) { try { scriptLog = await getQlikSenseCloudAppReloadScriptLog(appId, reloadId); } catch (err) { - logger.error(`QLIK SENSE CLOUD: Could not get app reload script log. Error=${JSON.stringify(err, null, 2)}`); + logger.error(`[QSCLOUD] Could not get app reload script log. Error=${JSON.stringify(err, null, 2)}`); } // If return value is false, the script log could not be obtained if (scriptLog === false) { - logger.warn(`QLIK SENSE CLOUD: Could not get app reload script log. App ID="${appId}", reload ID="${reloadId}"`); + logger.warn(`[QSCLOUD] Could not get app reload script log. App ID="${appId}", reload ID="${reloadId}"`); } else { - logger.verbose(`QLIK SENSE CLOUD: App reload script log obtained. App ID="${appId}", reload ID="${reloadId}"`); + logger.verbose(`[QSCLOUD] App reload script log obtained. App ID="${appId}", reload ID="${reloadId}"`); } - logger.debug(`QLIK SENSE CLOUD: App reload script log: ${scriptLog}`); + logger.debug(`[QSCLOUD] App reload script log: ${scriptLog}`); // Reload info is available via "GET /v1/reloads/{reloadId}" // https://qlik.dev/apis/rest/reloads/#get-v1-reloads-reloadId @@ -113,10 +110,10 @@ export async function handleQlikSenseCloudAppReloadFinished(message) { reloadInfo = await getQlikSenseCloudAppReloadInfo(reloadId); reloadTrigger = reloadInfo.type; - logger.verbose(`QLIK SENSE CLOUD: App reload info obtained. App ID="${appId}", reload ID="${reloadId}"`); - logger.debug(`QLIK SENSE CLOUD: App reload info: ${JSON.stringify(reloadInfo, null, 2)}`); + logger.verbose(`[QSCLOUD] App reload info obtained. App ID="${appId}", reload ID="${reloadId}"`); + logger.debug(`[QSCLOUD] App reload info: ${JSON.stringify(reloadInfo, null, 2)}`); } catch (err) { - logger.error(`QLIK SENSE CLOUD: Could not get app reload info. Error=${JSON.stringify(err, null, 2)}`); + logger.error(`[QSCLOUD] Could not get app reload info. Error=${JSON.stringify(err, null, 2)}`); } // App info is available via "GET /v1/apps/{appId}" @@ -124,10 +121,10 @@ export async function handleQlikSenseCloudAppReloadFinished(message) { try { appInfo = await getQlikSenseCloudAppInfo(appId); - logger.verbose(`QLIK SENSE CLOUD: App info obtained. App ID="${appId}"`); - logger.debug(`QLIK SENSE CLOUD: App info: ${JSON.stringify(appInfo, null, 2)}`); + logger.verbose(`[QSCLOUD] App info obtained. App ID="${appId}"`); + logger.debug(`[QSCLOUD] App info: ${JSON.stringify(appInfo, null, 2)}`); } catch (err) { - logger.error(`QLIK SENSE CLOUD: Could not get app info. Error=${JSON.stringify(err, null, 2)}`); + logger.error(`[QSCLOUD] Could not get app info. Error=${JSON.stringify(err, null, 2)}`); } // App metadata is available via "GET /v1/apps/{appId}/data/metadata" @@ -135,10 +132,10 @@ export async function handleQlikSenseCloudAppReloadFinished(message) { try { appMetadata = await getQlikSenseCloudAppMetadata(appId); - logger.verbose(`QLIK SENSE CLOUD: App metadata obtained. App ID="${appId}"`); - logger.debug(`QLIK SENSE CLOUD: App metadata: ${JSON.stringify(appMetadata, null, 2)}`); + logger.verbose(`[QSCLOUD] App metadata obtained. App ID="${appId}"`); + logger.debug(`[QSCLOUD] App metadata: ${JSON.stringify(appMetadata, null, 2)}`); } catch (err) { - logger.error(`QLIK SENSE CLOUD: Could not get app metadata. Error=${JSON.stringify(err, null, 2)}`); + logger.error(`[QSCLOUD] Could not get app metadata. Error=${JSON.stringify(err, null, 2)}`); } // App items are available via "GET /v1/items" @@ -150,7 +147,7 @@ export async function handleQlikSenseCloudAppReloadFinished(message) { // error if not if (appItems?.data.length !== 1 || appItems?.data[0].resourceId !== appId) { logger.error( - `QLIK SENSE CLOUD: App items obtained, but app ID does not match. App ID="${appId}", appItems="${JSON.stringify( + `[QSCLOUD] App items obtained, but app ID does not match. App ID="${appId}", appItems="${JSON.stringify( appItems, null, 2, @@ -161,10 +158,10 @@ export async function handleQlikSenseCloudAppReloadFinished(message) { appItems = {}; } - logger.verbose(`QLIK SENSE CLOUD: App items obtained. App ID="${appId}"`); - logger.debug(`QLIK SENSE CLOUD: App items: ${JSON.stringify(appItems, null, 2)}`); + logger.verbose(`[QSCLOUD] App items obtained. App ID="${appId}"`); + logger.debug(`[QSCLOUD] App items: ${JSON.stringify(appItems, null, 2)}`); } catch (err) { - logger.error(`QLIK SENSE CLOUD: Could not get app items. Error=${JSON.stringify(err, null, 2)}`); + logger.error(`[QSCLOUD] Could not get app items. Error=${JSON.stringify(err, null, 2)}`); } // Get info from config file @@ -177,7 +174,7 @@ export async function handleQlikSenseCloudAppReloadFinished(message) { // Save script log to disk file, if enabled if (globals.config.get('Butler.scriptLog.storeOnDisk.qsCloud.appReloadFailure.enable') === true) { - logger.verbose(`QLIK SENSE CLOUD: Storing script log to disk file`); + logger.verbose(`[QSCLOUD] Storing script log to disk file`); // Get path to the directory where script logs will be stored const scriptLogDirRoot = globals.config.get('Butler.scriptLog.storeOnDisk.qsCloud.appReloadFailure.logDirectory'); @@ -188,7 +185,7 @@ export async function handleQlikSenseCloudAppReloadFinished(message) { const logDate = eventTime.slice(0, 10); const reloadLogDir = path.resolve(scriptLogDirRoot, logDate); - logger.debug(`QLIK SENSE CLOUD: Script log directory: ${reloadLogDir}`); + logger.debug(`[QSCLOUD] Script log directory: ${reloadLogDir}`); // Get error time stamp from eventTime, in format YYY-MM-DD_HH-MM-SS const logTimeStamp = eventTime.slice(0, 19).replace(/ /g, '_').replace(/:/g, '-'); @@ -200,10 +197,10 @@ export async function handleQlikSenseCloudAppReloadFinished(message) { // Write script log to disk file try { - logger.info(`QLIK SENSE CLOUD: Writing failed task script log: ${fileName}`); + logger.info(`[QSCLOUD] Writing failed task script log: ${fileName}`); fs.writeFileSync(fileName, scriptLog.scriptLogFull.join('\n')); } catch (err) { - logger.error(`QLIK SENSE CLOUD: Could not store script log to disk file. File="${fileName}", error=${err}`); + logger.error(`[QSCLOUD] Could not store script log to disk file. File="${fileName}", error=${err}`); } } @@ -212,7 +209,7 @@ export async function handleQlikSenseCloudAppReloadFinished(message) { globals.config.get('Butler.qlikSenseCloud.event.mqtt.tenant.alert.teamsNotification.reloadAppFailure.enable') === true ) { - logger.verbose(`QLIK SENSE CLOUD: Sending Teams notification about app reload failure`); + logger.verbose(`[QSCLOUD] Sending Teams notification about app reload failure`); // Should we get extended info about the event, or go with the basic info provided in the event/MQTT message? // If extended info is enabled, we need to make API calls to get the extended info @@ -271,7 +268,7 @@ export async function handleQlikSenseCloudAppReloadFinished(message) { globals.config.get('Butler.qlikSenseCloud.event.mqtt.tenant.alert.slackNotification.reloadAppFailure.enable') === true ) { - logger.verbose(`QLIK SENSE CLOUD: Sending Slack notification about app reload failure`); + logger.verbose(`[QSCLOUD] Sending Slack notification about app reload failure`); // Should we get extended info about the event, or go with the basic info provided in the event/MQTT message? // If extended info is enabled, we need to make API calls to get the extended info @@ -331,7 +328,7 @@ export async function handleQlikSenseCloudAppReloadFinished(message) { globals.config.get('Butler.qlikSenseCloud.event.mqtt.tenant.alert.emailNotification.reloadAppFailure.enable') === true ) { - logger.verbose(`QLIK SENSE CLOUD: Sending email notification about app reload failure`); + logger.verbose(`[QSCLOUD] Sending email notification about app reload failure`); // Get extended info about the event // This includes: @@ -385,7 +382,7 @@ export async function handleQlikSenseCloudAppReloadFinished(message) { return true; } catch (err) { - logger.error(`Qlik Sense Cloud app reload finished event handling error: ${err}`); + logger.error(`[QSCLOUD] Qlik Sense Cloud app reload finished event handling error: ${err}`); return false; } } diff --git a/src/lib/qscloud/msteams_notification_qscloud.js b/src/lib/qscloud/msteams_notification_qscloud.js index 20d59e26..69a63573 100644 --- a/src/lib/qscloud/msteams_notification_qscloud.js +++ b/src/lib/qscloud/msteams_notification_qscloud.js @@ -29,7 +29,7 @@ function getAppReloadFailedTeamsConfig() { if (!globals.config.get('Butler.qlikSenseCloud.event.mqtt.tenant.alert.teamsNotification.reloadAppFailure.enable')) { // Teams task falure notifications are disabled globals.logger.error( - "TEAMS ALERT - QS CLOUD APP RELOAD FAILED: Reload failure Teams notifications are disabled in config file - won't send Teams message", + "[QSCLOUD] TEAMS ALERT - APP RELOAD FAILED: Reload failure Teams notifications are disabled in config file - won't send Teams message", ); return false; } @@ -42,7 +42,7 @@ function getAppReloadFailedTeamsConfig() { ) { // Invalid Teams message type globals.logger.error( - `TEAMS ALERT - QS CLOUD APP RELOAD FAILED: Invalid Teams message type: ${globals.config.get( + `[QSCLOUD] TEAMS ALERT - APP RELOAD FAILED: Invalid Teams message type: ${globals.config.get( 'Butler.qlikSenseCloud.event.mqtt.tenant.alert.teamsNotification.reloadAppFailure.messageType', )}`, ); @@ -68,7 +68,7 @@ function getAppReloadFailedTeamsConfig() { ), }; } catch (err) { - globals.logger.error(`TEAMS ALERT - QS CLOUD APP RELOAD FAILED: ${err}`); + globals.logger.error(`[QSCLOUD] TEAMS ALERT - APP RELOAD FAILED: ${err}`); return false; } } @@ -135,16 +135,24 @@ async function sendTeams(teamsWebhookUrl, teamsConfig, templateContext, msgType) if (msgType === 'reload') { // Escape any back slashes in the script logs const regExpText = /(?!\\n)\\{1}/gm; - globals.logger.debug(`TEAMS SEND: Script log head escaping: ${regExpText.exec(templateContext.scriptLogHead)}`); - globals.logger.debug(`TEAMS SEND: Script log tail escaping: ${regExpText.exec(templateContext.scriptLogTail)}`); + globals.logger.debug( + `[QSCLOUD] TEAMS SEND: Script log head escaping: ${regExpText.exec(templateContext.scriptLogHead)}`, + ); + globals.logger.debug( + `[QSCLOUD] TEAMS SEND: Script log tail escaping: ${regExpText.exec(templateContext.scriptLogTail)}`, + ); templateContext.scriptLogHead = templateContext.scriptLogHead.replace(regExpText, '\\\\'); templateContext.scriptLogTail = templateContext.scriptLogTail.replace(regExpText, '\\\\'); } else if (msgType === 'qscloud-app-reload') { // Escape any back slashes in the script logs const regExpText = /(?!\\n)\\{1}/gm; - globals.logger.debug(`TEAMS SEND: Script log head escaping: ${regExpText.exec(templateContext.scriptLogHead)}`); - globals.logger.debug(`TEAMS SEND: Script log tail escaping: ${regExpText.exec(templateContext.scriptLogTail)}`); + globals.logger.debug( + `[QSCLOUD] TEAMS SEND: Script log head escaping: ${regExpText.exec(templateContext.scriptLogHead)}`, + ); + globals.logger.debug( + `[QSCLOUD] TEAMS SEND: Script log tail escaping: ${regExpText.exec(templateContext.scriptLogTail)}`, + ); templateContext.scriptLogHead = templateContext.scriptLogHead.replace(regExpText, '\\\\'); templateContext.scriptLogTail = templateContext.scriptLogTail.replace(regExpText, '\\\\'); @@ -152,15 +160,15 @@ async function sendTeams(teamsWebhookUrl, teamsConfig, templateContext, msgType) renderedText = compiledTemplate(templateContext); - globals.logger.debug(`TEAMS SEND: Rendered message:\n${renderedText}`); + globals.logger.debug(`[QSCLOUD] TEAMS SEND: Rendered message:\n${renderedText}`); // Parse the JSON string to get rid of extra linebreaks etc. msg = JSON.parse(renderedText); } else { - globals.logger.error(`TEAMS SEND: Could not open Teams template file ${teamsConfig.templateFile}.`); + globals.logger.error(`[QSCLOUD] TEAMS SEND: Could not open Teams template file ${teamsConfig.templateFile}.`); } } catch (err) { - globals.logger.error(`TEAMS SEND: Error processing Teams template file: ${err}`); + globals.logger.error(`[QSCLOUD] TEAMS SEND: Error processing Teams template file: ${err}`); } } @@ -169,11 +177,13 @@ async function sendTeams(teamsWebhookUrl, teamsConfig, templateContext, msgType) const res = await webhook.sendMessage(); if (res !== undefined) { - globals.logger.debug(`TEAMS SEND: Result from calling TeamsApi.TeamsSend: ${res.statusText} (${res.status}): ${res.data}`); + globals.logger.debug( + `[QSCLOUD] TEAMS SEND: Result from calling TeamsApi.TeamsSend: ${res.statusText} (${res.status}): ${res.data}`, + ); } } } catch (err) { - globals.logger.error(`TEAMS SEND: ${err}`); + globals.logger.error(`[QSCLOUD] TEAMS SEND: ${err}`); } } @@ -184,10 +194,10 @@ export function sendQlikSenseCloudAppReloadFailureNotificationTeams(reloadParams .then(async (rateLimiterRes) => { try { globals.logger.info( - `TEAMS ALERT - QS CLOUD APP RELOAD FAILED: Rate limiting check passed for failed task notification. App name: "${reloadParams.appName}"`, + `[QSCLOUD] TEAMS ALERT - APP RELOAD FAILED: Rate limiting check passed for failed task notification. App name: "${reloadParams.appName}"`, ); globals.logger.verbose( - `TEAMS ALERT - QS CLOUD APP RELOAD FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, + `[QSCLOUD] TEAMS ALERT - APP RELOAD FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); // Make sure Teams sending is enabled in the config file and that we have all required settings @@ -229,8 +239,14 @@ export function sendQlikSenseCloudAppReloadFailureNotificationTeams(reloadParams scriptLogData.scriptLogSizeRows = reloadParams.scriptLog.scriptLogFull.length; // Get the first and last rows of the script log - scriptLogData.scriptLogHead = getQlikSenseCloudAppReloadScriptLogHead(reloadParams.scriptLog.scriptLogFull, scriptLogData.scriptLogHeadCount); - scriptLogData.scriptLogTail = getQlikSenseCloudAppReloadScriptLogTail(reloadParams.scriptLog.scriptLogFull, scriptLogData.scriptLogTailCount); + scriptLogData.scriptLogHead = getQlikSenseCloudAppReloadScriptLogHead( + reloadParams.scriptLog.scriptLogFull, + scriptLogData.scriptLogHeadCount, + ); + scriptLogData.scriptLogTail = getQlikSenseCloudAppReloadScriptLogTail( + reloadParams.scriptLog.scriptLogFull, + scriptLogData.scriptLogTailCount, + ); } else { scriptLogData.scriptLogHead = ''; scriptLogData.scriptLogTail = ''; @@ -239,7 +255,7 @@ export function sendQlikSenseCloudAppReloadFailureNotificationTeams(reloadParams } globals.logger.debug( - `TEAMS ALERT - QS CLOUD APP RELOAD FAILED: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`, + `[QSCLOUD] TEAMS ALERT - APP RELOAD FAILED: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`, ); } @@ -376,16 +392,16 @@ export function sendQlikSenseCloudAppReloadFailureNotificationTeams(reloadParams const { webhookUrl } = teamsConfig; sendTeams(webhookUrl, teamsConfig, templateContext, 'qscloud-app-reload'); } catch (err) { - globals.logger.error(`TEAMS ALERT - QS CLOUD APP RELOAD FAILED: ${err}`); + globals.logger.error(`[QSCLOUD] TEAMS ALERT - APP RELOAD FAILED: ${err}`); } return true; }) .catch((rateLimiterRes) => { globals.logger.warn( - `TEAMS ALERT - QS CLOUD APP RELOAD FAILED: Rate limiting failed. Not sending reload notification Teams for app [${reloadParams.appId}] "${reloadParams.appName}"`, + `[QSCLOUD] TEAMS ALERT - APP RELOAD FAILED: Rate limiting failed. Not sending reload notification Teams for app [${reloadParams.appId}] "${reloadParams.appName}"`, ); globals.logger.debug( - `TEAMS ALERT - QS CLOUD APP RELOAD FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, + `[QSCLOUD] TEAMS ALERT - APP RELOAD FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); }); } diff --git a/src/lib/qscloud/slack_notification_qscloud.js b/src/lib/qscloud/slack_notification_qscloud.js index da03ed71..573b475b 100644 --- a/src/lib/qscloud/slack_notification_qscloud.js +++ b/src/lib/qscloud/slack_notification_qscloud.js @@ -28,7 +28,7 @@ function getAppReloadFailedSlackConfig() { if (!globals.config.get('Butler.qlikSenseCloud.event.mqtt.tenant.alert.slackNotification.reloadAppFailure.enable')) { // Slack task falure notifications are disabled globals.logger.error( - "SLACK ALERT - QS CLOUD APP RELOAD FAILED: Reload failure Slack notifications are disabled in config file - won't send Slack message", + '[QSCLOUD] SLACK ALERT - APP RELOAD FAILED: Reload failure Slack notifications are disabled in config file - will not send Slack message', ); return false; } @@ -41,7 +41,7 @@ function getAppReloadFailedSlackConfig() { ) { // Invalid Slack message type globals.logger.error( - `SLACK ALERT - QS CLOUD APP RELOAD FAILED: Invalid Slack message type: ${globals.config.get( + `[QSCLOUD] SLACK ALERT - APP RELOAD FAILED: Invalid Slack message type: ${globals.config.get( 'Butler.qlikSenseCloud.event.mqtt.tenant.alert.slackNotification.reloadAppFailure.messageType', )}`, ); @@ -54,7 +54,7 @@ function getAppReloadFailedSlackConfig() { // Basic formatting. Make sure requried parameters are present if (!globals.config.has('Butler.qlikSenseCloud.event.mqtt.tenant.alert.slackNotification.reloadAppFailure.basicMsgTemplate')) { // No message text in config file. - globals.logger.error('SLACK ALERT - QS CLOUD APP RELOAD FAILED: No message text in config file.'); + globals.logger.error('[QSCLOUD] SLACK ALERT - APP RELOAD FAILED: No message text in config file.'); return false; } } else if ( @@ -63,7 +63,7 @@ function getAppReloadFailedSlackConfig() { ) { // Extended formatting using Slack blocks. Make sure requried parameters are present if (!globals.config.has('Butler.qlikSenseCloud.event.mqtt.tenant.alert.slackNotification.reloadAppFailure.templateFile')) { - globals.logger.error('SLACK ALERT - QS CLOUD APP RELOAD FAILED: Message template file not specified in config file.'); + globals.logger.error('[QSCLOUD] SLACK ALERT - APP RELOAD FAILED: Message template file not specified in config file.'); return false; } } @@ -90,7 +90,7 @@ function getAppReloadFailedSlackConfig() { channel: globals.config.get('Butler.qlikSenseCloud.event.mqtt.tenant.alert.slackNotification.reloadAppFailure.channel'), }; } catch (err) { - globals.logger.error(`SLACK ALERT - QS CLOUD APP RELOAD FAILED: ${err}`); + globals.logger.error(`[QSCLOUD] SLACK ALERT - APP RELOAD FAILED: ${err}`); return false; } } @@ -162,16 +162,24 @@ async function sendSlack(slackConfig, templateContext, msgType) { if (msgType === 'reload') { // Escape any back slashes in the script logs const regExpText = /(?!\\n)\\{1}/gm; - globals.logger.debug(`SLACK SEND: Script log head escaping: ${regExpText.exec(templateContext.scriptLogHead)}`); - globals.logger.debug(`SLACK SEND: Script log tail escaping: ${regExpText.exec(templateContext.scriptLogTail)}`); + globals.logger.debug( + `[QSCLOUD] SLACK SEND: Script log head escaping: ${regExpText.exec(templateContext.scriptLogHead)}`, + ); + globals.logger.debug( + `[QSCLOUD] SLACK SEND: Script log tail escaping: ${regExpText.exec(templateContext.scriptLogTail)}`, + ); templateContext.scriptLogHead = templateContext.scriptLogHead.replace(regExpText, '\\\\'); templateContext.scriptLogTail = templateContext.scriptLogTail.replace(regExpText, '\\\\'); } else if (msgType === 'qscloud-app-reload') { // Escape any back slashes in the script logs const regExpText = /(?!\\n)\\{1}/gm; - globals.logger.debug(`SLACK SEND: Script log head escaping: ${regExpText.exec(templateContext.scriptLogHead)}`); - globals.logger.debug(`SLACK SEND: Script log tail escaping: ${regExpText.exec(templateContext.scriptLogTail)}`); + globals.logger.debug( + `[QSCLOUD] SLACK SEND: Script log head escaping: ${regExpText.exec(templateContext.scriptLogHead)}`, + ); + globals.logger.debug( + `[QSCLOUD] SLACK SEND: Script log tail escaping: ${regExpText.exec(templateContext.scriptLogTail)}`, + ); templateContext.scriptLogHead = templateContext.scriptLogHead.replace(regExpText, '\\\\'); templateContext.scriptLogTail = templateContext.scriptLogTail.replace(regExpText, '\\\\'); @@ -179,12 +187,12 @@ async function sendSlack(slackConfig, templateContext, msgType) { slackMsg = compiledTemplate(templateContext); - globals.logger.debug(`SLACK SEND: Rendered message:\n${slackMsg}`); + globals.logger.debug(`[QSCLOUD] SLACK SEND: Rendered message:\n${slackMsg}`); } else { - globals.logger.error(`SLACK SEND: Could not open Slack template file ${slackConfig.templateFile}.`); + globals.logger.error(`[QSCLOUD] SLACK SEND: Could not open Slack template file ${slackConfig.templateFile}.`); } } catch (err) { - globals.logger.error(`SLACK SEND: Error processing Slack template file: ${err}`); + globals.logger.error(`[QSCLOUD] SLACK SEND: Error processing Slack template file: ${err}`); } } @@ -193,11 +201,13 @@ async function sendSlack(slackConfig, templateContext, msgType) { const res = await slackSend(slackConfig, globals.logger); if (res !== undefined) { - globals.logger.debug(`SLACK SEND: Result from calling SlackApi.SlackSend: ${res.statusText} (${res.status}): ${res.data}`); + globals.logger.debug( + `[QSCLOUD] SLACK SEND: Result from calling SlackApi.SlackSend: ${res.statusText} (${res.status}): ${res.data}`, + ); } } } catch (err) { - globals.logger.error(`SLACK SEND: ${err}`); + globals.logger.error(`[QSCLOUD] SLACK SEND: ${err}`); } } @@ -208,10 +218,10 @@ export function sendQlikSenseCloudAppReloadFailureNotificationSlack(reloadParams .then(async (rateLimiterRes) => { try { globals.logger.info( - `SLACK ALERT - QS CLOUD APP RELOAD FAILED: Rate limiting check passed for failed task notification. App name: "${reloadParams.appName}"`, + `[QSCLOUD] SLACK ALERT - APP RELOAD FAILED: Rate limiting check passed for failed task notification. App name: "${reloadParams.appName}"`, ); globals.logger.verbose( - `SLACK ALERT - QS CLOUD APP RELOAD FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, + `[QSCLOUD] SLACK ALERT - APP RELOAD FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); // Make sure Slack sending is enabled in the config file and that we have all required settings @@ -253,8 +263,14 @@ export function sendQlikSenseCloudAppReloadFailureNotificationSlack(reloadParams scriptLogData.scriptLogSizeRows = reloadParams.scriptLog.scriptLogFull.length; // Get the first and last rows of the script log - scriptLogData.scriptLogHead = getQlikSenseCloudAppReloadScriptLogHead(reloadParams.scriptLog.scriptLogFull, scriptLogData.scriptLogHeadCount); - scriptLogData.scriptLogTail = getQlikSenseCloudAppReloadScriptLogTail(reloadParams.scriptLog.scriptLogFull, scriptLogData.scriptLogTailCount); + scriptLogData.scriptLogHead = getQlikSenseCloudAppReloadScriptLogHead( + reloadParams.scriptLog.scriptLogFull, + scriptLogData.scriptLogHeadCount, + ); + scriptLogData.scriptLogTail = getQlikSenseCloudAppReloadScriptLogTail( + reloadParams.scriptLog.scriptLogFull, + scriptLogData.scriptLogTailCount, + ); } else { scriptLogData.scriptLogHead = ''; scriptLogData.scriptLogTail = ''; @@ -263,7 +279,7 @@ export function sendQlikSenseCloudAppReloadFailureNotificationSlack(reloadParams } globals.logger.debug( - `SLACK ALERT - QS CLOUD APP RELOAD FAILED: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`, + `[QSCLOUD] SLACK ALERT - APP RELOAD FAILED: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`, ); } @@ -410,16 +426,16 @@ export function sendQlikSenseCloudAppReloadFailureNotificationSlack(reloadParams sendSlack(slackConfig, templateContext, 'qscloud-app-reload'); } catch (err) { - globals.logger.error(`SLACK ALERT - QS CLOUD APP RELOAD FAILED: ${err}`); + globals.logger.error(`[QSCLOUD] SLACK ALERT - APP RELOAD FAILED: ${err}`); } return true; }) .catch((rateLimiterRes) => { globals.logger.warn( - `SLACK ALERT - QS CLOUD APP RELOAD FAILED: Rate limiting failed. Not sending reload notification Slack for app [${reloadParams.appId}] "${reloadParams.appName}"`, + `[QSCLOUD] SLACK ALERT - APP RELOAD FAILED: Rate limiting failed. Not sending reload notification Slack for app [${reloadParams.appId}] "${reloadParams.appName}"`, ); globals.logger.debug( - `SLACK ALERT - QS CLOUD APP RELOAD FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, + `[QSCLOUD] SLACK ALERT - APP RELOAD FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); }); } diff --git a/src/lib/qseow/msteams_notification.js b/src/lib/qseow/msteams_notification.js index 873c1bc2..dfb1fa34 100644 --- a/src/lib/qseow/msteams_notification.js +++ b/src/lib/qseow/msteams_notification.js @@ -53,7 +53,7 @@ function getTeamsReloadFailedNotificationConfigOk() { if (!globals.config.get('Butler.teamsNotification.reloadTaskFailure.enable')) { // Teams task falure notifications are disabled globals.logger.error( - "TEAMS RELOAD TASK FAILED: Reload failure Teams notifications are disabled in config file - won't send Teams message", + '[QSEOW] TEAMS RELOAD TASK FAILED: Reload failure Teams notifications are disabled in config file - will not send Teams message', ); return false; } @@ -64,7 +64,7 @@ function getTeamsReloadFailedNotificationConfigOk() { ) { // Invalid Teams message type globals.logger.error( - `TEAMS RELOAD TASK FAILED: Invalid Teams message type: ${globals.config.get( + `[QSEOW] TEAMS RELOAD TASK FAILED: Invalid Teams message type: ${globals.config.get( 'Butler.teamsNotification.reloadTaskFailure.messageType', )}`, ); @@ -75,13 +75,13 @@ function getTeamsReloadFailedNotificationConfigOk() { // Basic formatting. Make sure requried parameters are present if (!globals.config.has('Butler.teamsNotification.reloadTaskFailure.basicMsgTemplate')) { // No message text in config file. - globals.logger.error('TEAMS RELOAD TASK FAILED: No message text in config file.'); + globals.logger.error('[QSEOW] TEAMS RELOAD TASK FAILED: No message text in config file.'); return false; } } else if (globals.config.get('Butler.teamsNotification.reloadTaskFailure.messageType') === 'formatted') { // Extended formatting using Teams blocks. Make sure requried parameters are present if (!globals.config.has('Butler.teamsNotification.reloadTaskFailure.templateFile')) { - globals.logger.error('TEAMS RELOAD TASK FAILED: Message template file not specified in config file.'); + globals.logger.error('[QSEOW] TEAMS RELOAD TASK FAILED: Message template file not specified in config file.'); return false; } } @@ -105,7 +105,7 @@ function getTeamsReloadFailedNotificationConfigOk() { : '', }; } catch (err) { - globals.logger.error(`TEAMS RELOAD TASK FAILED: ${err}`); + globals.logger.error(`[QSEOW] TEAMS RELOAD TASK FAILED: ${err}`); return false; } } @@ -115,7 +115,7 @@ function getTeamsReloadAbortedNotificationConfigOk() { if (!globals.config.get('Butler.teamsNotification.reloadTaskAborted.enable')) { // Teams task aborted notifications are disabled globals.logger.error( - "TEAMS RELOAD TASK ABORTED: Reload aborted Teams notifications are disabled in config file - won't send Teams message", + '[QSEOW] TEAMS RELOAD TASK ABORTED: Reload aborted Teams notifications are disabled in config file - will not send Teams message', ); return false; } @@ -126,7 +126,7 @@ function getTeamsReloadAbortedNotificationConfigOk() { ) { // Invalid Teams message type globals.logger.error( - `TEAMS RELOAD TASK ABORTED: Invalid Teams message type: ${globals.config.get( + `[QSEOW] TEAMS RELOAD TASK ABORTED: Invalid Teams message type: ${globals.config.get( 'Butler.teamsNotification.reloadTaskAborted.messageType', )}`, ); @@ -137,13 +137,13 @@ function getTeamsReloadAbortedNotificationConfigOk() { // Basic formatting. Make sure requried parameters are present if (!globals.config.has('Butler.teamsNotification.reloadTaskAborted.basicMsgTemplate')) { // No message text in config file. - globals.logger.error('TEAMS RELOAD TASK ABORTED: No message text in config file.'); + globals.logger.error('[QSEOW] TEAMS RELOAD TASK ABORTED: No message text in config file.'); return false; } } else if (globals.config.get('Butler.teamsNotification.reloadTaskAborted.messageType') === 'formatted') { // Extended formatting using Teams blocks. Make sure requried parameters are present if (!globals.config.has('Butler.teamsNotification.reloadTaskAborted.templateFile')) { - globals.logger.error('TEAMS RELOAD TASK ABORTED: Message template file not specified in config file.'); + globals.logger.error('[QSEOW] TEAMS RELOAD TASK ABORTED: Message template file not specified in config file.'); return false; } } @@ -170,7 +170,7 @@ function getTeamsReloadAbortedNotificationConfigOk() { : '', }; } catch (err) { - globals.logger.error(`TEAMS RELOAD TASK ABORTED: ${err}`); + globals.logger.error(`[QSEOW] TEAMS RELOAD TASK ABORTED: ${err}`); return false; } } @@ -180,7 +180,7 @@ function getTeamsServiceMonitorNotificationConfig(serviceStatus) { if (!globals.config.get('Butler.serviceMonitor.alertDestination.teams.enable')) { // Teams notifications are disabled globals.logger.error( - "TEAMS SERVICE MONITOR: TEAMS SERVICE MONITOR notifications are disabled in config file - won't send Teams message", + '[QSEOW] TEAMS SERVICE MONITOR: TEAMS SERVICE MONITOR notifications are disabled in config file - will not send Teams message', ); return false; } @@ -191,7 +191,7 @@ function getTeamsServiceMonitorNotificationConfig(serviceStatus) { ) { // Invalid Teams message type globals.logger.error( - `TEAMS SERVICE MONITOR: Invalid Teams message type: ${globals.config.get( + `[QSEOW] TEAMS SERVICE MONITOR: Invalid Teams message type: ${globals.config.get( 'Butler.teamsNotification.serviceStopped.messageType', )}`, ); @@ -204,7 +204,7 @@ function getTeamsServiceMonitorNotificationConfig(serviceStatus) { ) { // Invalid Teams message type globals.logger.error( - `TEAMS SERVICE MONITOR: Invalid Teams message type: ${globals.config.get( + `[QSEOW] TEAMS SERVICE MONITOR: Invalid Teams message type: ${globals.config.get( 'Butler.teamsNotification.serviceStopped.messageType', )}`, ); @@ -215,13 +215,13 @@ function getTeamsServiceMonitorNotificationConfig(serviceStatus) { // Basic formatting. Make sure requried parameters are present if (!globals.config.has('Butler.teamsNotification.serviceStopped.basicMsgTemplate')) { // No message text in config file. - globals.logger.error('TEAMS SERVICE MONITOR: No service stopped basic message text in config file.'); + globals.logger.error('[QSEOW] TEAMS SERVICE MONITOR: No service stopped basic message text in config file.'); return false; } } else if (globals.config.get('Butler.teamsNotification.serviceStopped.messageType') === 'formatted') { // Extended formatting using Teams blocks. Make sure requried parameters are present if (!globals.config.has('Butler.teamsNotification.serviceStopped.templateFile')) { - globals.logger.error('TEAMS SERVICE MONITOR: Service stopped message template file not specified in config file.'); + globals.logger.error('[QSEOW] TEAMS SERVICE MONITOR: Service stopped message template file not specified in config file.'); return false; } } @@ -230,13 +230,13 @@ function getTeamsServiceMonitorNotificationConfig(serviceStatus) { // Basic formatting. Make sure requried parameters are present if (!globals.config.has('Butler.teamsNotification.serviceStarted.basicMsgTemplate')) { // No message text in config file. - globals.logger.error('TEAMS SERVICE MONITOR: No service started basic message text in config file.'); + globals.logger.error('[QSEOW] TEAMS SERVICE MONITOR: No service started basic message text in config file.'); return false; } } else if (globals.config.get('Butler.teamsNotification.serviceStarted.messageType') === 'formatted') { // Extended formatting using Teams blocks. Make sure requried parameters are present if (!globals.config.has('Butler.teamsNotification.serviceStarted.templateFile')) { - globals.logger.error('TEAMS SERVICE MONITOR: Service started message template file not specified in config file.'); + globals.logger.error('[QSEOW] TEAMS SERVICE MONITOR: Service started message template file not specified in config file.'); return false; } } @@ -281,7 +281,7 @@ function getTeamsServiceMonitorNotificationConfig(serviceStatus) { return result; } catch (err) { - globals.logger.error(`TEAMS SERVICE MONITOR: ${err}`); + globals.logger.error(`[QSEOW] TEAMS SERVICE MONITOR: ${err}`); return false; } } @@ -339,8 +339,12 @@ async function sendTeams(teamsWebhookUrl, teamsConfig, templateContext, msgType) if (msgType === 'reload') { // Escape any back slashes in the script logs const regExpText = /(?!\\n)\\{1}/gm; - globals.logger.debug(`TEAMS SEND: Script log head escaping: ${regExpText.exec(templateContext.scriptLogHead)}`); - globals.logger.debug(`TEAMS SEND: Script log tail escaping: ${regExpText.exec(templateContext.scriptLogTail)}`); + globals.logger.debug( + `[QSEOW] TEAMS SEND: Script log head escaping: ${regExpText.exec(templateContext.scriptLogHead)}`, + ); + globals.logger.debug( + `[QSEOW] TEAMS SEND: Script log tail escaping: ${regExpText.exec(templateContext.scriptLogTail)}`, + ); templateContext.scriptLogHead = templateContext.scriptLogHead.replace(regExpText, '\\\\'); templateContext.scriptLogTail = templateContext.scriptLogTail.replace(regExpText, '\\\\'); @@ -348,15 +352,15 @@ async function sendTeams(teamsWebhookUrl, teamsConfig, templateContext, msgType) renderedText = compiledTemplate(templateContext); - globals.logger.debug(`TEAMS SEND: Rendered message:\n${renderedText}`); + globals.logger.debug(`[QSEOW] TEAMS SEND: Rendered message:\n${renderedText}`); // Parse the JSON string to get rid of extra linebreaks etc. msg = JSON.parse(renderedText); } else { - globals.logger.error(`TEAMS SEND: Could not open Teams template file ${teamsConfig.templateFile}.`); + globals.logger.error(`[QSEOW] TEAMS SEND: Could not open Teams template file ${teamsConfig.templateFile}.`); } } catch (err) { - globals.logger.error(`TEAMS SEND: Error processing Teams template file: ${err}`); + globals.logger.error(`[QSEOW] TEAMS SEND: Error processing Teams template file: ${err}`); } } @@ -365,11 +369,13 @@ async function sendTeams(teamsWebhookUrl, teamsConfig, templateContext, msgType) const res = await webhook.sendMessage(); if (res !== undefined) { - globals.logger.debug(`TEAMS SEND: Result from calling TeamsApi.TeamsSend: ${res.statusText} (${res.status}): ${res.data}`); + globals.logger.debug( + `[QSEOW] TEAMS SEND: Result from calling TeamsApi.TeamsSend: ${res.statusText} (${res.status}): ${res.data}`, + ); } } } catch (err) { - globals.logger.error(`TEAMS SEND: ${err}`); + globals.logger.error(`[QSEOW] TEAMS SEND: ${err}`); } } @@ -379,9 +385,11 @@ export function sendReloadTaskFailureNotificationTeams(reloadParams) { .then(async (rateLimiterRes) => { try { globals.logger.info( - `TEAMS RELOAD TASK FAILED: Rate limiting check passed for failed task notification. Task name: "${reloadParams.taskName}"`, + `[QSEOW] TEAMS RELOAD TASK FAILED: Rate limiting check passed for failed task notification. Task name: "${reloadParams.taskName}"`, + ); + globals.logger.verbose( + `[QSEOW] TEAMS RELOAD TASK FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); - globals.logger.verbose(`TEAMS RELOAD TASK FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); // Make sure Teams sending is enabled in the config file and that we have all required settings const teamsConfig = getTeamsReloadFailedNotificationConfigOk(); @@ -410,7 +418,7 @@ export function sendReloadTaskFailureNotificationTeams(reloadParams) { scriptLogData.scriptLogTail = ''; } - globals.logger.debug(`TEAMS RELOAD TASK FAILED: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`); + globals.logger.debug(`[QSEOW] TEAMS RELOAD TASK FAILED: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`); // Get Sense URLs from config file. Can be used as template fields. const senseUrls = getQlikSenseUrls(); @@ -500,7 +508,7 @@ export function sendReloadTaskFailureNotificationTeams(reloadParams) { // Check if script log is longer than 3000 characters. Truncate if so. if (templateContext.scriptLogHead.length >= 3000) { globals.logger.warn( - `TEAMS: Script log head field is too long (${templateContext.scriptLogHead.length}), will truncate before posting to Teams.`, + `[QSEOW] TEAMS: Script log head field is too long (${templateContext.scriptLogHead.length}), will truncate before posting to Teams.`, ); templateContext.scriptLogHead = templateContext.scriptLogHead .replaceAll('&', '&') @@ -524,7 +532,7 @@ export function sendReloadTaskFailureNotificationTeams(reloadParams) { if (templateContext.scriptLogTail.length >= 3000) { globals.logger.warn( - `TEAMS: Script log head field is too long (${templateContext.scriptLogTail.length}), will truncate before posting to Teams.`, + `[QSEOW] TEAMS: Script log head field is too long (${templateContext.scriptLogTail.length}), will truncate before posting to Teams.`, ); templateContext.scriptLogTail = templateContext.scriptLogTail .replaceAll('&', '&') @@ -549,15 +557,15 @@ export function sendReloadTaskFailureNotificationTeams(reloadParams) { const webhookUrl = globals.config.get('Butler.teamsNotification.reloadTaskFailure.webhookURL'); sendTeams(webhookUrl, teamsConfig, templateContext, 'reload'); } catch (err) { - globals.logger.error(`TEAMS RELOAD TASK FAILED: ${err}`); + globals.logger.error(`[QSEOW] TEAMS RELOAD TASK FAILED: ${err}`); } return true; }) .catch((rateLimiterRes) => { globals.logger.warn( - `TEAMS RELOAD TASK FAILED: Rate limiting failed. Not sending reload notification Teams for task "${reloadParams.taskName}"`, + `[QSEOW] TEAMS RELOAD TASK FAILED: Rate limiting failed. Not sending reload notification Teams for task "${reloadParams.taskName}"`, ); - globals.logger.debug(`TEAMS RELOAD TASK FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); + globals.logger.debug(`[QSEOW] TEAMS RELOAD TASK FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); }); } @@ -567,9 +575,11 @@ export function sendReloadTaskAbortedNotificationTeams(reloadParams) { .then(async (rateLimiterRes) => { try { globals.logger.info( - `TEAMS RELOAD TASK ABORTED: Rate limiting check passed for aborted task notification. Task name: "${reloadParams.taskName}"`, + `[QSEOW] TEAMS RELOAD TASK ABORTED: Rate limiting check passed for aborted task notification. Task name: "${reloadParams.taskName}"`, + ); + globals.logger.verbose( + `[QSEOW] TEAMS RELOAD TASK ABORTED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); - globals.logger.verbose(`TEAMS RELOAD TASK ABORTED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); // Make sure Teams sending is enabled in the config file and that we have all required settings const teamsConfig = getTeamsReloadAbortedNotificationConfigOk(); @@ -597,7 +607,7 @@ export function sendReloadTaskAbortedNotificationTeams(reloadParams) { scriptLogData.scriptLogTail = ''; } - globals.logger.debug(`TEAMS RELOAD TASK ABORTED: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`); + globals.logger.debug(`[QSEOW] TEAMS RELOAD TASK ABORTED: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`); // Get Sense URLs from config file. Can be used as template fields. const senseUrls = getQlikSenseUrls(); @@ -689,7 +699,7 @@ export function sendReloadTaskAbortedNotificationTeams(reloadParams) { // Check if script log is longer than 3000 characters. Truncate if so. if (templateContext.scriptLogHead.length >= 3000) { globals.logger.warn( - `TEAMS: Script log head field is too long (${templateContext.scriptLogHead.length}), will truncate before posting to Teams.`, + `[QSEOW] TEAMS: Script log head field is too long (${templateContext.scriptLogHead.length}), will truncate before posting to Teams.`, ); templateContext.scriptLogHead = templateContext.scriptLogHead .replaceAll('&', '&') @@ -713,7 +723,7 @@ export function sendReloadTaskAbortedNotificationTeams(reloadParams) { if (templateContext.scriptLogTail.length >= 3000) { globals.logger.warn( - `TEAMS: Script log head field is too long (${templateContext.scriptLogTail.length}), will truncate before posting to Teams.`, + `[QSEOW] TEAMS: Script log head field is too long (${templateContext.scriptLogTail.length}), will truncate before posting to Teams.`, ); templateContext.scriptLogTail = templateContext.scriptLogTail .replaceAll('&', '&') @@ -738,15 +748,15 @@ export function sendReloadTaskAbortedNotificationTeams(reloadParams) { const webhookUrl = globals.config.get('Butler.teamsNotification.reloadTaskAborted.webhookURL'); sendTeams(webhookUrl, teamsConfig, templateContext, 'reload'); } catch (err) { - globals.logger.error(`TEAMS RELOAD TASK ABORTED: ${err}`); + globals.logger.error(`[QSEOW] TEAMS RELOAD TASK ABORTED: ${err}`); } return true; }) .catch((rateLimiterRes) => { globals.logger.verbose( - `TEAMS RELOAD TASK ABORTED: Rate limiting failed. Not sending reload notification Teams for task "${reloadParams.taskName}"`, + `[QSEOW] TEAMS RELOAD TASK ABORTED: Rate limiting failed. Not sending reload notification Teams for task "${reloadParams.taskName}"`, ); - globals.logger.verbose(`TEAMS RELOAD TASK ABORTED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); + globals.logger.verbose(`[QSEOW] TEAMS RELOAD TASK ABORTED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); }); } @@ -756,9 +766,9 @@ export function sendServiceMonitorNotificationTeams(serviceParams) { .then(async (rateLimiterRes) => { try { globals.logger.info( - `TEAMS SERVICE MONITOR: Rate limiting check passed for service monitor notification. Host: "${serviceParams.host}", service: "${serviceParams.serviceName}"`, + `[QSEOW] TEAMS SERVICE MONITOR: Rate limiting check passed for service monitor notification. Host: "${serviceParams.host}", service: "${serviceParams.serviceName}"`, ); - globals.logger.verbose(`TEAMS SERVICE MONITOR: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); + globals.logger.verbose(`[QSEOW] TEAMS SERVICE MONITOR: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); // Make sure Teams sending is enabled in the config file and that we have all required settings const teamsConfig = getTeamsServiceMonitorNotificationConfig(serviceParams.serviceStatus); @@ -794,14 +804,14 @@ export function sendServiceMonitorNotificationTeams(serviceParams) { sendTeams(webhookUrl, teamsConfig, templateContext, 'serviceStarted'); } } catch (err) { - globals.logger.error(`TEAMS SERVICE MONITOR: ${err}`); + globals.logger.error(`[QSEOW] TEAMS SERVICE MONITOR: ${err}`); } return true; }) .catch((rateLimiterRes) => { globals.logger.verbose( - `TEAMS SERVICE MONITOR: Rate limiting failed. Not sending service monitor notification for service "${serviceParams.serviceName}" on host "${serviceParams.host}"`, + `[QSEOW] TEAMS SERVICE MONITOR: Rate limiting failed. Not sending service monitor notification for service "${serviceParams.serviceName}" on host "${serviceParams.host}"`, ); - globals.logger.verbose(`TEAMS SERVICE MONITOR: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); + globals.logger.verbose(`[QSEOW] TEAMS SERVICE MONITOR: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); }); } diff --git a/src/lib/qseow/qliksense_license.js b/src/lib/qseow/qliksense_license.js index a2172296..e59b2aaf 100644 --- a/src/lib/qseow/qliksense_license.js +++ b/src/lib/qseow/qliksense_license.js @@ -7,7 +7,7 @@ import { postQlikSenseLicenseReleasedToInfluxDB, postQlikSenseServerLicenseStatusToInfluxDB, } from '../post_to_influxdb.js'; -import { callQlikSenseServerLicenseWebhook } from '../webhook_notification.js'; +import { callQlikSenseServerLicenseWebhook } from './webhook_notification.js'; // Function to check Qlik Sense server license status async function checkQlikSenseServerLicenseStatus(config, logger) { @@ -32,12 +32,12 @@ async function checkQlikSenseServerLicenseStatus(config, logger) { // Is status code 200 or body is empty? if (result.statusCode !== 200 || !result.body) { - logger.error(`QLIKSENSE SERVER LICENSE MONITOR: HTTP status code ${result.statusCode}`); + logger.error(`[QSEOW] QLIKSENSE SERVER LICENSE MONITOR: HTTP status code ${result.statusCode}`); return; } // Debug log - logger.debug(`QLIKSENSE SERVER LICENSE MONITOR: ${JSON.stringify(result.body)}`); + logger.debug(`[QSEOW] QLIKSENSE SERVER LICENSE MONITOR: ${JSON.stringify(result.body)}`); // Returned icense JSON has the following structure: // { @@ -103,14 +103,16 @@ async function checkQlikSenseServerLicenseStatus(config, logger) { // Use warn logging if days until expiry is less than value specified in config file, // otherwise use info logging if (daysUntilExpiry !== null && expiryDateStr !== null && licenseExpired !== null) { - globals.logger.info(`QLIK SENSE SERVER LICENSE: License expired: ${licenseExpired}`); + globals.logger.info(`[QSEOW] QLIK SENSE SERVER LICENSE: License expired: ${licenseExpired}`); if (daysUntilExpiry <= globals.config.get('Butler.qlikSenseLicense.serverLicenseMonitor.alert.thresholdDays')) { - globals.logger.warn(`QLIK SENSE SERVER LICENSE: Qlik Sense server license is about to expire in ${daysUntilExpiry} days!`); - globals.logger.warn(`QLIK SENSE SERVER LICENSE: Expiry date: ${expiryDate}`); + globals.logger.warn( + `[QSEOW] QLIK SENSE SERVER LICENSE: Qlik Sense server license is about to expire in ${daysUntilExpiry} days!`, + ); + globals.logger.warn(`[QSEOW] QLIK SENSE SERVER LICENSE: Expiry date: ${expiryDate}`); } else { - globals.logger.info(`QLIK SENSE SERVER LICENSE: Qlik Sense server license expiry in ${daysUntilExpiry} days`); - globals.logger.info(`QLIK SENSE SERVER LICENSE: Expiry date: ${expiryDate}`); + globals.logger.info(`[QSEOW] QLIK SENSE SERVER LICENSE: Qlik Sense server license expiry in ${daysUntilExpiry} days`); + globals.logger.info(`[QSEOW] QLIK SENSE SERVER LICENSE: Expiry date: ${expiryDate}`); } } @@ -193,9 +195,9 @@ async function checkQlikSenseServerLicenseStatus(config, logger) { } } } catch (err) { - logger.error(`QLIKSENSE SERVER LICENSE MONITOR: ${err}`); + logger.error(`[QSEOW] QLIKSENSE SERVER LICENSE MONITOR: ${err}`); if (err.stack) { - logger.error(`QLIKSENSE SERVER LICENSE MONITOR: ${err.stack}`); + logger.error(`[QSEOW] QLIKSENSE SERVER LICENSE MONITOR: ${err.stack}`); } } } @@ -223,12 +225,12 @@ async function checkQlikSenseAccessLicenseStatus(config, logger) { // Is status code 200 or body is empty? if (result1.statusCode !== 200 || !result1.body) { - logger.error(`QLIKSENSE LICENSE MONITOR: HTTP status code ${result1.statusCode}`); + logger.error(`[QSEOW] QLIKSENSE LICENSE MONITOR: HTTP status code ${result1.statusCode}`); return; } // Debug log - logger.debug(`QLIKSENSE LICENSE MONITOR: ${JSON.stringify(result1.body)}`); + logger.debug(`[QSEOW] QLIKSENSE LICENSE MONITOR: ${JSON.stringify(result1.body)}`); // To which destination should we send the license information? // Check InfluDB first @@ -240,9 +242,9 @@ async function checkQlikSenseAccessLicenseStatus(config, logger) { await postQlikSenseLicenseStatusToInfluxDB(result1.body); } } catch (err) { - logger.error(`QLIKSENSE LICENSE MONITOR: ${err}`); + logger.error(`[QSEOW] QLIKSENSE LICENSE MONITOR: ${err}`); if (err.stack) { - logger.error(`QLIKSENSE LICENSE MONITOR: ${err.stack}`); + logger.error(`[QSEOW] QLIKSENSE LICENSE MONITOR: ${err.stack}`); } } } @@ -262,25 +264,25 @@ async function licenseReleaseProfessional(config, logger, qrsInstance) { cutoffDate.setHours(23, 59, 59, 999); // verbose log, format dates as yyyy-mm-ddThh:mm:ss.sssZ - logger.verbose(`QLIKSENSE LICENSE RELEASE PROFESSIONAL: currentDate: ${currentDate.toISOString()}`); - logger.verbose(`QLIKSENSE LICENSE RELEASE PROFESSIONAL: releaseThresholdDays: ${releaseThresholdDays}`); - logger.verbose(`QLIKSENSE LICENSE RELEASE PROFESSIONAL: cutoffDate: ${cutoffDate.toISOString()}`); + logger.verbose(`[QSEOW] QLIKSENSE LICENSE RELEASE PROFESSIONAL: currentDate: ${currentDate.toISOString()}`); + logger.verbose(`[QSEOW] QLIKSENSE LICENSE RELEASE PROFESSIONAL: releaseThresholdDays: ${releaseThresholdDays}`); + logger.verbose(`[QSEOW] QLIKSENSE LICENSE RELEASE PROFESSIONAL: cutoffDate: ${cutoffDate.toISOString()}`); // Get all assigned professional licenses const url = `license/professionalaccesstype/full?filter=lastUsed le '${cutoffDate.toISOString()}'`; - logger.debug(`QLIKSENSE LICENSE RELEASE PROFESSIONAL: Query URL: ${url}`); + logger.debug(`[QSEOW] QLIKSENSE LICENSE RELEASE PROFESSIONAL: Query URL: ${url}`); const result1 = await qrsInstance.Get(url); // Is status code other than 200 or body is empty? if (result1.statusCode !== 200 || !result1.body) { logger.error( - `QLIKSENSE LICENSE RELEASE PROFESSIONAL: Could not get list of assigned professional licenses. HTTP status code ${result1.statusCode}`, + `[QSEOW] QLIKSENSE LICENSE RELEASE PROFESSIONAL: Could not get list of assigned professional licenses. HTTP status code ${result1.statusCode}`, ); return false; } // Debug log - logger.debug(`QLIKSENSE LICENSE RELEASE PROFESSIONAL: Assigned: ${JSON.stringify(result1.body)}`); + logger.debug(`[QSEOW] QLIKSENSE LICENSE RELEASE PROFESSIONAL: Assigned: ${JSON.stringify(result1.body)}`); // Determnine which allocated licenses to release. // Only release licenses that are NOT quarantined @@ -302,18 +304,18 @@ async function licenseReleaseProfessional(config, logger, qrsInstance) { const res = await qrsInstance.Get(`user/${license.user.id}`); if (res.statusCode !== 200 || !res.body) { logger.error( - `QLIKSENSE LICENSE RELEASE PROFESSIONAL: Failed getting user info for user [${license.user.id}] ${license.user.userDirectory}\\${license.user.userId}`, + `[QSEOW] QLIKSENSE LICENSE RELEASE PROFESSIONAL: Failed getting user info for user [${license.user.id}] ${license.user.userDirectory}\\${license.user.userId}`, ); return false; } currentUser = res.body; } catch (err) { logger.error( - `QLIKSENSE LICENSE RELEASE PROFESSIONAL: Failed getting user info for user [${license.user.id}] ${license.user.userDirectory}\\${license.user.userId}`, + `[QSEOW] QLIKSENSE LICENSE RELEASE PROFESSIONAL: Failed getting user info for user [${license.user.id}] ${license.user.userDirectory}\\${license.user.userId}`, ); if (err.stack) { logger.error( - `QLIKSENSE LICENSE RELEASE PROFESSIONAL: Failed getting user info for user [${license.user.id}] ${license.user.userDirectory}\\${license.user.userId}. ${err.stack}`, + `[QSEOW] QLIKSENSE LICENSE RELEASE PROFESSIONAL: Failed getting user info for user [${license.user.id}] ${license.user.userDirectory}\\${license.user.userId}. ${err.stack}`, ); } return false; @@ -470,7 +472,7 @@ async function licenseReleaseProfessional(config, logger, qrsInstance) { // Should currentUser be released? if (!doNotRelease) { logger.info( - `QLIKSENSE LICENSE RELEASE PROFESSIONAL: Adding user ${license.user.userDirectory}\\${license.user.userId} (days since last use: ${daysSinceLastUse}) to releaseProfessional array`, + `[QSEOW] QLIKSENSE LICENSE RELEASE PROFESSIONAL: Adding user ${license.user.userDirectory}\\${license.user.userId} (days since last use: ${daysSinceLastUse}) to releaseProfessional array`, ); releaseProfessional.push({ licenseId: license.id, @@ -480,14 +482,14 @@ async function licenseReleaseProfessional(config, logger, qrsInstance) { }); } else { logger.info( - `QLIKSENSE LICENSE RELEASE PROFESSIONAL: License for user ${license.user.userDirectory}\\${license.user.userId} not released because: ${doNotReleaseReason}`, + `[QSEOW] QLIKSENSE LICENSE RELEASE PROFESSIONAL: License for user ${license.user.userDirectory}\\${license.user.userId} not released because: ${doNotReleaseReason}`, ); } } } logger.verbose( - `QLIKSENSE LICENSE RELEASE PROFESSIONAL: Professional licenses to be released: ${JSON.stringify(releaseProfessional, null, 2)}`, + `[QSEOW] QLIKSENSE LICENSE RELEASE PROFESSIONAL: Professional licenses to be released: ${JSON.stringify(releaseProfessional, null, 2)}`, ); // Is license release dry-run enabled? If so, do not release any licenses @@ -498,7 +500,7 @@ async function licenseReleaseProfessional(config, logger, qrsInstance) { // eslint-disable-next-line no-restricted-syntax for (const licenseRelease of releaseProfessional) { logger.info( - `QLIKSENSE LICENSE RELEASE PROFESSIONAL: Releasing license for user ${licenseRelease.userDir}\\${licenseRelease.userId} (days since last use: ${licenseRelease.daysSinceLastUse})`, + `[QSEOW] QLIKSENSE LICENSE RELEASE PROFESSIONAL: Releasing license for user ${licenseRelease.userDir}\\${licenseRelease.userId} (days since last use: ${licenseRelease.daysSinceLastUse})`, ); // Release license @@ -507,12 +509,12 @@ async function licenseReleaseProfessional(config, logger, qrsInstance) { // Is status code 204? Error if it's nmt if (result2.statusCode !== 204) { - logger.error(`QLIKSENSE LICENSE RELEASE PROFESSIONAL: HTTP status code ${result2.statusCode}`); + logger.error(`[QSEOW] QLIKSENSE LICENSE RELEASE PROFESSIONAL: HTTP status code ${result2.statusCode}`); return false; } // Debug log - logger.debug(`QLIKSENSE LICENSE RELEASE PROFESSIONAL: ${JSON.stringify(result2.body)}`); + logger.debug(`[QSEOW] QLIKSENSE LICENSE RELEASE PROFESSIONAL: ${JSON.stringify(result2.body)}`); // Write info about released license to InfluxDB? if ( @@ -548,25 +550,25 @@ async function licenseReleaseAnalyzer(config, logger, qrsInstance) { cutoffDate.setHours(23, 59, 59, 999); // verbose log, format dates as yyyy-mm-ddThh:mm:ss.sssZ - logger.verbose(`QLIKSENSE LICENSE RELEASE ANALYZER: currentDate: ${currentDate.toISOString()}`); - logger.verbose(`QLIKSENSE LICENSE RELEASE ANALYZER: releaseThresholdDays: ${releaseThresholdDays}`); - logger.verbose(`QLIKSENSE LICENSE RELEASE ANALYZER: cutoffDate: ${cutoffDate.toISOString()}`); + logger.verbose(`[QSEOW] QLIKSENSE LICENSE RELEASE ANALYZER: currentDate: ${currentDate.toISOString()}`); + logger.verbose(`[QSEOW] QLIKSENSE LICENSE RELEASE ANALYZER: releaseThresholdDays: ${releaseThresholdDays}`); + logger.verbose(`[QSEOW] QLIKSENSE LICENSE RELEASE ANALYZER: cutoffDate: ${cutoffDate.toISOString()}`); // Get all assigned analyzer licenses const url = `license/analyzeraccesstype/full?filter=lastUsed le '${cutoffDate.toISOString()}'`; - logger.debug(`QLIKSENSE LICENSE RELEASE ANALYZER: Query URL: ${url}`); + logger.debug(`[QSEOW] QLIKSENSE LICENSE RELEASE ANALYZER: Query URL: ${url}`); const result3 = await qrsInstance.Get(url); // Is status code 200 or body is empty? if (result3.statusCode !== 200 || !result3.body) { logger.error( - `QLIKSENSE LICENSE RELEASE ANALYZER: Could not get list of assigned analyzer licenses. HTTP status code ${result3.statusCode}`, + `[QSEOW] QLIKSENSE LICENSE RELEASE ANALYZER: Could not get list of assigned analyzer licenses. HTTP status code ${result3.statusCode}`, ); return false; } // Debug log - logger.debug(`QLIKSENSE LICENSE RELEASE ANALYZER: Assigned: ${JSON.stringify(result3.body)}`); + logger.debug(`[QSEOW] QLIKSENSE LICENSE RELEASE ANALYZER: Assigned: ${JSON.stringify(result3.body)}`); // Determnine which allocated licenses to release. // Only release licenses that are NOT quarantined @@ -588,18 +590,18 @@ async function licenseReleaseAnalyzer(config, logger, qrsInstance) { const res = await qrsInstance.Get(`user/${license.user.id}`); if (res.statusCode !== 200 || !res.body) { logger.error( - `QLIKSENSE LICENSE RELEASE ANALYZER: Failed getting user info for user [${license.user.id}] ${license.user.userDirectory}\\${license.user.userId}`, + `[QSEOW] QLIKSENSE LICENSE RELEASE ANALYZER: Failed getting user info for user [${license.user.id}] ${license.user.userDirectory}\\${license.user.userId}`, ); return false; } currentUser = res.body; } catch (err) { logger.error( - `QLIKSENSE LICENSE RELEASE ANALYZER: Failed getting user info for user [${license.user.id}] ${license.user.userDirectory}\\${license.user.userId}`, + `[QSEOW] QLIKSENSE LICENSE RELEASE ANALYZER: Failed getting user info for user [${license.user.id}] ${license.user.userDirectory}\\${license.user.userId}`, ); if (err.stack) { logger.error( - `QLIKSENSE LICENSE RELEASE ANALYZER: Failed getting user info for user [${license.user.id}] ${license.user.userDirectory}\\${license.user.userId}. ${err.stack}`, + `[QSEOW] QLIKSENSE LICENSE RELEASE ANALYZER: Failed getting user info for user [${license.user.id}] ${license.user.userDirectory}\\${license.user.userId}. ${err.stack}`, ); } return false; @@ -750,7 +752,7 @@ async function licenseReleaseAnalyzer(config, logger, qrsInstance) { // Should currentUser be released? if (!doNotRelease) { logger.info( - `QLIKSENSE LICENSE RELEASE ANALYZER: Adding user ${license.user.userDirectory}\\${license.user.userId} (days since last use: ${daysSinceLastUse}) to releaseAnalyzer array`, + `[QSEOW] QLIKSENSE LICENSE RELEASE ANALYZER: Adding user ${license.user.userDirectory}\\${license.user.userId} (days since last use: ${daysSinceLastUse}) to releaseAnalyzer array`, ); releaseAnalyzer.push({ licenseId: license.id, @@ -760,23 +762,25 @@ async function licenseReleaseAnalyzer(config, logger, qrsInstance) { }); } else { logger.info( - `QLIKSENSE LICENSE RELEASE ANALYZER: License for user ${license.user.userDirectory}\\${license.user.userId} not released because: ${doNotReleaseReason}`, + `[QSEOW] QLIKSENSE LICENSE RELEASE ANALYZER: License for user ${license.user.userDirectory}\\${license.user.userId} not released because: ${doNotReleaseReason}`, ); } } } - logger.verbose(`QLIKSENSE LICENSE RELEASE ANALYZER: Analyzer licenses to be released: ${JSON.stringify(releaseAnalyzer, null, 2)}`); + logger.verbose( + `[QSEOW] QLIKSENSE LICENSE RELEASE ANALYZER: Analyzer licenses to be released: ${JSON.stringify(releaseAnalyzer, null, 2)}`, + ); // Is license release dry-run enabled? If so, do not release any licenses if (config.get('Butler.qlikSenseLicense.licenseRelease.dryRun') === true) { - logger.info('QLIKSENSE LICENSE RELEASE ANALYZER: Dry-run enabled. No licenses will be released'); + logger.info('[QSEOW] QLIKSENSE LICENSE RELEASE ANALYZER: Dry-run enabled. No licenses will be released'); } else { // Release all licenses in the releaseAnalyzer array // eslint-disable-next-line no-restricted-syntax for (const licenseRelease of releaseAnalyzer) { logger.info( - `QLIKSENSE LICENSE RELEASE ANALYZER: Releasing license for user ${licenseRelease.userDir}\\${licenseRelease.userId} (days since last use: ${licenseRelease.daysSinceLastUse})`, + `[QSEOW] QLIKSENSE LICENSE RELEASE ANALYZER: Releasing license for user ${licenseRelease.userDir}\\${licenseRelease.userId} (days since last use: ${licenseRelease.daysSinceLastUse})`, ); // Release license @@ -785,12 +789,12 @@ async function licenseReleaseAnalyzer(config, logger, qrsInstance) { // Is status code 204? Error if it's nmt if (result4.statusCode !== 204) { - logger.error(`QLIKSENSE LICENSE RELEASE ANALYZER: HTTP status code ${result4.statusCode}`); + logger.error(`[QSEOW] QLIKSENSE LICENSE RELEASE ANALYZER: HTTP status code ${result4.statusCode}`); return false; } // Debug log - logger.debug(`QLIKSENSE LICENSE RELEASE ANALYZER: ${JSON.stringify(result4.body)}`); + logger.debug(`[QSEOW] QLIKSENSE LICENSE RELEASE ANALYZER: ${JSON.stringify(result4.body)}`); // Write info about released license to InfluxDB? if ( @@ -853,9 +857,9 @@ async function checkQlikSenseLicenseRelease(config, logger) { return true; } catch (err) { - logger.error(`QLIKSENSE LICENSE RELEASE: ${err}`); + logger.error(`[QSEOW] QLIKSENSE LICENSE RELEASE: ${err}`); if (err.stack) { - logger.error(`QLIKSENSE LICENSE RELEASE: ${err.stack}`); + logger.error(`[QSEOW] QLIKSENSE LICENSE RELEASE: ${err.stack}`); } return false; } @@ -871,13 +875,13 @@ export async function setupQlikSenseAccessLicenseMonitor(config, logger) { }, sched); // Do an initial license check - logger.verbose('Doing initial Qlik Sense license check'); + logger.verbose('[QSEOW] Doing initial Qlik Sense license check'); checkQlikSenseAccessLicenseStatus(config, logger, true); } } catch (err) { - logger.error(`QLIKSENSE LICENSE MONITOR INIT: ${err}`); + logger.error(`[QSEOW] QLIKSENSE LICENSE MONITOR INIT: ${err}`); if (err.stack) { - logger.error(`QLIKSENSE LICENSE MONITOR INIT: ${err.stack}`); + logger.error(`[QSEOW] QLIKSENSE LICENSE MONITOR INIT: ${err.stack}`); } } } @@ -892,13 +896,13 @@ export async function setupQlikSenseLicenseRelease(config, logger) { }, sched); // Do an initial release - logger.verbose('Doing initial Qlik Sense license check'); + logger.verbose('[QSEOW] Doing initial Qlik Sense license check'); checkQlikSenseLicenseRelease(config, logger); } } catch (err) { - logger.error(`QLIKSENSE LICENSE RELEASE INIT: ${err}`); + logger.error(`[QSEOW] QLIKSENSE LICENSE RELEASE INIT: ${err}`); if (err.stack) { - logger.error(`QLIKSENSE LICENSE RELEASE INIT: ${err.stack}`); + logger.error(`[QSEOW] QLIKSENSE LICENSE RELEASE INIT: ${err.stack}`); } } } @@ -913,13 +917,13 @@ export async function setupQlikSenseServerLicenseMonitor(config, logger) { }, sched); // Do an initial license check - logger.verbose('Doing initial Qlik Sense server license check'); + logger.verbose('[QSEOW] Doing initial Qlik Sense server license check'); checkQlikSenseServerLicenseStatus(config, logger); } } catch (err) { - logger.error(`QLIKSENSE SERVER LICENSE MONITOR INIT: ${err}`); + logger.error(`[QSEOW] QLIKSENSE SERVER LICENSE MONITOR INIT: ${err}`); if (err.stack) { - logger.error(`QLIKSENSE SERVER LICENSE MONITOR INIT: ${err.stack}`); + logger.error(`[QSEOW] QLIKSENSE SERVER LICENSE MONITOR INIT: ${err.stack}`); } } } diff --git a/src/lib/qseow/qliksense_version.js b/src/lib/qseow/qliksense_version.js index 1494a32d..6f3da9ae 100644 --- a/src/lib/qseow/qliksense_version.js +++ b/src/lib/qseow/qliksense_version.js @@ -28,7 +28,7 @@ async function checkQlikSenseVersion(config, logger) { // Is status code 200 or body is empty? if (result.status !== 200 || !result.data) { - logger.error(`QLIKSENSE VERSION MONITOR: HTTP status code ${result.status}, "${result.statusText}"`); + logger.error(`[QSEOW] QLIKSENSE VERSION MONITOR: HTTP status code ${result.status}, "${result.statusText}"`); return; } @@ -36,10 +36,10 @@ async function checkQlikSenseVersion(config, logger) { logger.debug(`QLIKSENSE VERSION MONITOR: ${JSON.stringify(result.data)}`); // Log version info to console log - logger.info(`QLIKSENSE VERSION MONITOR: Qlik Sense product name: ${result.data.productName}`); - logger.info(`QLIKSENSE VERSION MONITOR: Qlik Sense deployment type: ${result.data.deploymentType}`); - logger.info(`QLIKSENSE VERSION MONITOR: Qlik Sense version: ${result.data.version}`); - logger.info(`QLIKSENSE VERSION MONITOR: Qlik Sense release: ${result.data.releaseLabel}`); + logger.info(`[QSEOW] QLIKSENSE VERSION MONITOR: Qlik Sense product name: ${result.data.productName}`); + logger.info(`[QSEOW] QLIKSENSE VERSION MONITOR: Qlik Sense deployment type: ${result.data.deploymentType}`); + logger.info(`[QSEOW] QLIKSENSE VERSION MONITOR: Qlik Sense version: ${result.data.version}`); + logger.info(`[QSEOW] QLIKSENSE VERSION MONITOR: Qlik Sense release: ${result.data.releaseLabel}`); // To which destination should we send the version information? // Check InfluDB first @@ -51,9 +51,9 @@ async function checkQlikSenseVersion(config, logger) { await postQlikSenseVersionToInfluxDB(result.data); } } catch (err) { - logger.error(`QLIKSENSE VERSION MONITOR: ${err}`); + logger.error(`[QSEOW] QLIKSENSE VERSION MONITOR: ${err}`); if (err.stack) { - logger.error(`QLIKSENSE VERSION MONITOR: ${err.stack}`); + logger.error(`[QSEOW] QLIKSENSE VERSION MONITOR: ${err.stack}`); } } } @@ -68,13 +68,13 @@ export async function setupQlikSenseVersionMonitor(config, logger) { }, sched); // Do an initial version check - logger.verbose('Doing initial Qlik Sense version check'); + logger.verbose('[QSEOW] Doing initial Qlik Sense version check'); checkQlikSenseVersion(config, logger, true); } } catch (err) { - logger.error(`QLIKSENSE VERSION MONITOR INIT: ${err}`); + logger.error(`[QSEOW] QLIKSENSE VERSION MONITOR INIT: ${err}`); if (err.stack) { - logger.error(`QLIKSENSE VERSION MONITOR INIT: ${err.stack}`); + logger.error(`[QSEOW] QLIKSENSE VERSION MONITOR INIT: ${err.stack}`); } } } diff --git a/src/lib/qseow/service_monitor.js b/src/lib/qseow/service_monitor.js index 0a719885..22298440 100644 --- a/src/lib/qseow/service_monitor.js +++ b/src/lib/qseow/service_monitor.js @@ -4,7 +4,7 @@ import { createMachine, createActor } from 'xstate'; import { statusAll, status, details } from './winsvc.js'; import globals from '../../globals.js'; import newRelic from '../incident_mgmt/new_relic_service_monitor.js'; -import { sendServiceMonitorWebhook } from '../webhook_notification.js'; +import { sendServiceMonitorWebhook } from './webhook_notification.js'; import { sendServiceMonitorNotificationSlack } from './slack_notification.js'; import { sendServiceMonitorNotificationTeams } from './msteams_notification.js'; import { sendServiceMonitorNotificationEmail } from './smtp.js'; @@ -116,7 +116,9 @@ const serviceMonitorMqttSend2 = (config, logger, svc) => { }; const verifyServicesExist = async (config, logger) => { - logger.info('VERIFY WIN SERVICES EXIST: Verifying that all Windows services specified in config file exist and can be reached.'); + logger.info( + 'VERIFY WIN SERVICES EXIST: Verifying that all Windows services specified in config file exist and can be reached.', + ); // Return false if one or more services do not exist or cannot be reached. // Return true if all services are reachable. @@ -195,7 +197,9 @@ const checkServiceStatus = async (config, logger, isFirstCheck = false) => { // Get status of this service const serviceStatus = await status(logger, service.name, host.host); - logger.debug(`Got reply: Service ${service.name} (="${service.friendlyName}") on host ${host.host} status: ${serviceStatus}`); + logger.debug( + `Got reply: Service ${service.name} (="${service.friendlyName}") on host ${host.host} status: ${serviceStatus}`, + ); // Get details about this service const serviceDetails = await details(logger, service.name, host.host); diff --git a/src/lib/qseow/slack_notification.js b/src/lib/qseow/slack_notification.js index 8bfc2d0d..5b5089a6 100644 --- a/src/lib/qseow/slack_notification.js +++ b/src/lib/qseow/slack_notification.js @@ -55,7 +55,7 @@ function getSlackReloadFailedNotificationConfigOk() { if (!globals.config.get('Butler.slackNotification.reloadTaskFailure.enable')) { // Slack task falure notifications are disabled globals.logger.error( - "SLACK RELOAD TASK FAILED: Reload failure Slack notifications are disabled in config file - won't send Slack message", + '[QSEOW] SLACK RELOAD TASK FAILED: Reload failure Slack notifications are disabled in config file - will not send Slack message', ); return false; } @@ -66,7 +66,7 @@ function getSlackReloadFailedNotificationConfigOk() { ) { // Invalid Slack message type globals.logger.error( - `SLACK RELOAD TASK FAILED: Invalid Slack message type: ${globals.config.get( + `[QSEOW] SLACK RELOAD TASK FAILED: Invalid Slack message type: ${globals.config.get( 'Butler.slackNotification.reloadTaskFailure.messageType', )}`, ); @@ -77,13 +77,13 @@ function getSlackReloadFailedNotificationConfigOk() { // Basic formatting. Make sure requried parameters are present if (!globals.config.has('Butler.slackNotification.reloadTaskFailure.basicMsgTemplate')) { // No message text in config file. - globals.logger.error('SLACK RELOAD TASK FAILED: No message text in config file.'); + globals.logger.error('[QSEOW] SLACK RELOAD TASK FAILED: No message text in config file.'); return false; } } else if (globals.config.get('Butler.slackNotification.reloadTaskFailure.messageType') === 'formatted') { // Extended formatting using Slack blocks. Make sure requried parameters are present if (!globals.config.has('Butler.slackNotification.reloadTaskFailure.templateFile')) { - globals.logger.error('SLACK RELOAD TASK FAILED: Message template file not specified in config file.'); + globals.logger.error('[QSEOW] SLACK RELOAD TASK FAILED: Message template file not specified in config file.'); return false; } } @@ -116,7 +116,7 @@ function getSlackReloadFailedNotificationConfigOk() { : '', }; } catch (err) { - globals.logger.error(`SLACK RELOAD TASK FAILED: ${err}`); + globals.logger.error(`[QSEOW] SLACK RELOAD TASK FAILED: ${err}`); return false; } } @@ -126,7 +126,7 @@ function getSlackReloadAbortedNotificationConfigOk() { if (!globals.config.get('Butler.slackNotification.reloadTaskAborted.enable')) { // Slack task aborted notifications are disabled globals.logger.error( - "SLACK RELOAD TASK ABORTED: Reload aborted Slack notifications are disabled in config file - won't send Slack message", + '[QSEOW] SLACK RELOAD TASK ABORTED: Reload aborted Slack notifications are disabled in config file - will not send Slack message', ); return false; } @@ -137,7 +137,7 @@ function getSlackReloadAbortedNotificationConfigOk() { ) { // Invalid Slack message type globals.logger.error( - `SLACK RELOAD TASK ABORTED: Invalid Slack message type: ${globals.config.get( + `[QSEOW] SLACK RELOAD TASK ABORTED: Invalid Slack message type: ${globals.config.get( 'Butler.slackNotification.reloadTaskAborted.messageType', )}`, ); @@ -148,13 +148,13 @@ function getSlackReloadAbortedNotificationConfigOk() { // Basic formatting. Make sure requried parameters are present if (!globals.config.has('Butler.slackNotification.reloadTaskAborted.basicMsgTemplate')) { // No message text in config file. - globals.logger.error('SLACK RELOAD TASK ABORTED: No message text in config file.'); + globals.logger.error('[QSEOW] SLACK RELOAD TASK ABORTED: No message text in config file.'); return false; } } else if (globals.config.get('Butler.slackNotification.reloadTaskAborted.messageType') === 'formatted') { // Extended formatting using Slack blocks. Make sure requried parameters are present if (!globals.config.has('Butler.slackNotification.reloadTaskAborted.templateFile')) { - globals.logger.error('SLACK RELOAD TASK ABORTED: Message template file not specified in config file.'); + globals.logger.error('[QSEOW] SLACK RELOAD TASK ABORTED: Message template file not specified in config file.'); return false; } } @@ -187,7 +187,7 @@ function getSlackReloadAbortedNotificationConfigOk() { : '', }; } catch (err) { - globals.logger.error(`SLACK RELOAD TASK ABORTED: ${err}`); + globals.logger.error(`[QSEOW] SLACK RELOAD TASK ABORTED: ${err}`); return false; } } @@ -197,7 +197,7 @@ function getSlackServiceMonitorNotificationConfig(serviceStatus) { if (!globals.config.get('Butler.serviceMonitor.alertDestination.slack.enable')) { // Slack notifications are disabled globals.logger.error( - "SLACK SERVICE MONITOR: SLACK SERVICE MONITOR notifications are disabled in config file - won't send Slack message", + '[QSEOW] SLACK SERVICE MONITOR: SLACK SERVICE MONITOR notifications are disabled in config file - will not send Slack message', ); return false; } @@ -208,7 +208,7 @@ function getSlackServiceMonitorNotificationConfig(serviceStatus) { ) { // Invalid Slack message type globals.logger.error( - `SLACK SERVICE MONITOR: Invalid Slack message type: ${globals.config.get( + `[QSEOW] SLACK SERVICE MONITOR: Invalid Slack message type: ${globals.config.get( 'Butler.slackNotification.serviceStopped.messageType', )}`, ); @@ -221,7 +221,7 @@ function getSlackServiceMonitorNotificationConfig(serviceStatus) { ) { // Invalid Slack message type globals.logger.error( - `SLACK SERVICE MONITOR: Invalid Slack message type: ${globals.config.get( + `[QSEOW] SLACK SERVICE MONITOR: Invalid Slack message type: ${globals.config.get( 'Butler.slackNotification.serviceStarted.messageType', )}`, ); @@ -232,13 +232,13 @@ function getSlackServiceMonitorNotificationConfig(serviceStatus) { // Basic formatting. Make sure required parameters are present if (!globals.config.has('Butler.slackNotification.serviceStopped.basicMsgTemplate')) { // No message text in config file. - globals.logger.error('SLACK SERVICE MONITOR: No service stopped basic message text in config file.'); + globals.logger.error('[QSEOW] SLACK SERVICE MONITOR: No service stopped basic message text in config file.'); return false; } } else if (globals.config.get('Butler.slackNotification.serviceStopped.messageType') === 'formatted') { // Extended formatting using Slack blocks. Make sure requried parameters are present if (!globals.config.has('Butler.slackNotification.serviceStopped.templateFile')) { - globals.logger.error('SLACK SERVICE MONITOR: Service stopped message template file not specified in config file.'); + globals.logger.error('[QSEOW] SLACK SERVICE MONITOR: Service stopped message template file not specified in config file.'); return false; } } @@ -247,13 +247,13 @@ function getSlackServiceMonitorNotificationConfig(serviceStatus) { // Basic formatting. Make sure required parameters are present if (!globals.config.has('Butler.slackNotification.serviceStarted.basicMsgTemplate')) { // No message text in config file. - globals.logger.error('SLACK SERVICE MONITOR: No service started basic message text in config file.'); + globals.logger.error('[QSEOW] SLACK SERVICE MONITOR: No service started basic message text in config file.'); return false; } } else if (globals.config.get('Butler.slackNotification.serviceStarted.messageType') === 'formatted') { // Extended formatting using Slack blocks. Make sure requried parameters are present if (!globals.config.has('Butler.slackNotification.serviceStarted.templateFile')) { - globals.logger.error('SLACK SERVICE MONITOR: Service started message template file not specified in config file.'); + globals.logger.error('[QSEOW] SLACK SERVICE MONITOR: Service started message template file not specified in config file.'); return false; } } @@ -310,7 +310,7 @@ function getSlackServiceMonitorNotificationConfig(serviceStatus) { return result; } catch (err) { - globals.logger.error(`SLACK SERVICE MONITOR: ${err}`); + globals.logger.error(`[QSEOW] SLACK SERVICE MONITOR: ${err}`); return false; } } @@ -383,8 +383,12 @@ async function sendSlack(slackConfig, templateContext, msgType) { if (msgType === 'reload') { // Escape any back slashes in the script logs const regExpText = /(?!\\n)\\{1}/gm; - globals.logger.debug(`SLACK SEND: Script log head escaping: ${regExpText.exec(templateContext.scriptLogHead)}`); - globals.logger.debug(`SLACK SEND: Script log tail escaping: ${regExpText.exec(templateContext.scriptLogTail)}`); + globals.logger.debug( + `[QSEOW] SLACK SEND: Script log head escaping: ${regExpText.exec(templateContext.scriptLogHead)}`, + ); + globals.logger.debug( + `[QSEOW] SLACK SEND: Script log tail escaping: ${regExpText.exec(templateContext.scriptLogTail)}`, + ); templateContext.scriptLogHead = templateContext.scriptLogHead.replace(regExpText, '\\\\'); templateContext.scriptLogTail = templateContext.scriptLogTail.replace(regExpText, '\\\\'); @@ -393,12 +397,12 @@ async function sendSlack(slackConfig, templateContext, msgType) { // Render Slack message using template. Do not convert to < and > as Slack will not render the message correctly slackMsg = compiledTemplate(templateContext); - globals.logger.debug(`SLACK SEND: Rendered message:\n${slackMsg}`); + globals.logger.debug(`[QSEOW] SLACK SEND: Rendered message:\n${slackMsg}`); } else { - globals.logger.error(`SLACK SEND: Could not open Slack template file ${slackConfig.templateFile}.`); + globals.logger.error(`[QSEOW] SLACK SEND: Could not open Slack template file ${slackConfig.templateFile}.`); } } catch (err) { - globals.logger.error(`SLACK SEND: Error processing Slack template file: ${err}`); + globals.logger.error(`[QSEOW] SLACK SEND: Error processing Slack template file: ${err}`); } } @@ -406,11 +410,11 @@ async function sendSlack(slackConfig, templateContext, msgType) { msg.text = slackMsg; const res = await slackSend(msg, globals.logger); if (res !== undefined) { - globals.logger.debug(`SLACK SEND: Result from calling slackSend: ${res.statusText} (${res.status}): ${res.data}`); + globals.logger.debug(`[QSEOW] SLACK SEND: Result from calling slackSend: ${res.statusText} (${res.status}): ${res.data}`); } } } catch (err) { - globals.logger.error(`SLACK SEND: ${err}`); + globals.logger.error(`[QSEOW] SLACK SEND: ${err}`); } } @@ -420,9 +424,11 @@ export function sendReloadTaskFailureNotificationSlack(reloadParams) { .then(async (rateLimiterRes) => { try { globals.logger.info( - `SLACK RELOAD TASK FAILED: Rate limiting check passed for failed task notification. Task name: "${reloadParams.taskName}"`, + `[QSEOW] SLACK RELOAD TASK FAILED: Rate limiting check passed for failed task notification. Task name: "${reloadParams.taskName}"`, + ); + globals.logger.verbose( + `[QSEOW] SLACK RELOAD TASK FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); - globals.logger.verbose(`SLACK RELOAD TASK FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); // Make sure Slack sending is enabled in the config file and that we have all required settings const slackConfig = getSlackReloadFailedNotificationConfigOk(); @@ -451,7 +457,7 @@ export function sendReloadTaskFailureNotificationSlack(reloadParams) { scriptLogData.scriptLogTail = ''; } - globals.logger.debug(`SLACK RELOAD TASK FAILED: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`); + globals.logger.debug(`[QSEOW] SLACK RELOAD TASK FAILED: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`); // Get Sense URLs from config file. Can be used as template fields. const senseUrls = getQlikSenseUrls(); @@ -559,7 +565,7 @@ export function sendReloadTaskFailureNotificationSlack(reloadParams) { // https://api.slack.com/reference/block-kit/blocks#section_fields if (templateContext.scriptLogHead.length >= 3000) { globals.logger.warn( - `SLACK: Script log head field is too long (${templateContext.scriptLogHead.length}), will truncate before posting to Slack.`, + `[QSEOW] SLACK: Script log head field is too long (${templateContext.scriptLogHead.length}), will truncate before posting to Slack.`, ); templateContext.scriptLogHead = templateContext.scriptLogHead .replaceAll('&', '&') @@ -583,7 +589,7 @@ export function sendReloadTaskFailureNotificationSlack(reloadParams) { if (templateContext.scriptLogTail.length >= 3000) { globals.logger.warn( - `SLACK: Script log head field is too long (${templateContext.scriptLogTail.length}), will truncate before posting to Slack.`, + `[QSEOW] SLACK: Script log head field is too long (${templateContext.scriptLogTail.length}), will truncate before posting to Slack.`, ); templateContext.scriptLogTail = templateContext.scriptLogTail .replaceAll('&', '&') @@ -607,15 +613,15 @@ export function sendReloadTaskFailureNotificationSlack(reloadParams) { sendSlack(slackConfig, templateContext, 'reload'); } catch (err) { - globals.logger.error(`SLACK RELOAD TASK FAILED: ${err}`); + globals.logger.error(`[QSEOW] SLACK RELOAD TASK FAILED: ${err}`); } return true; }) .catch((err) => { globals.logger.warn( - `SLACK RELOAD TASK FAILED: Rate limiting failed. Not sending reload notification Slack for task "${reloadParams.taskName}"`, + `[QSEOW] SLACK RELOAD TASK FAILED: Rate limiting failed. Not sending reload notification Slack for task "${reloadParams.taskName}"`, ); - globals.logger.debug(`SLACK RELOAD TASK FAILED: Rate limiting details "${JSON.stringify(err, null, 2)}"`); + globals.logger.debug(`[QSEOW] SLACK RELOAD TASK FAILED: Rate limiting details "${JSON.stringify(err, null, 2)}"`); }); } @@ -625,9 +631,11 @@ export function sendReloadTaskAbortedNotificationSlack(reloadParams) { .then(async (rateLimiterRes) => { try { globals.logger.info( - `SLACK RELOAD TASK ABORTED: Rate limiting check passed for aborted task notification. Task name: "${reloadParams.taskName}"`, + `[QSEOW] SLACK RELOAD TASK ABORTED: Rate limiting check passed for aborted task notification. Task name: "${reloadParams.taskName}"`, + ); + globals.logger.verbose( + `[QSEOW] SLACK RELOAD TASK ABORTED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); - globals.logger.verbose(`SLACK RELOAD TASK ABORTED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); // Make sure Slack sending is enabled in the config file and that we have all required settings const slackConfig = getSlackReloadAbortedNotificationConfigOk(); @@ -656,7 +664,7 @@ export function sendReloadTaskAbortedNotificationSlack(reloadParams) { scriptLogData.scriptLogTail = ''; } - globals.logger.debug(`SLACK RELOAD TASK ABORTED: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`); + globals.logger.debug(`[QSEOW] SLACK RELOAD TASK ABORTED: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`); // Get Sense URLs from config file. Can be used as template fields. const senseUrls = getQlikSenseUrls(); @@ -747,7 +755,7 @@ export function sendReloadTaskAbortedNotificationSlack(reloadParams) { // https://api.slack.com/reference/block-kit/blocks#section_fields if (templateContext.scriptLogHead.length >= 3000) { globals.logger.warn( - `SLACK: Script log head field is too long (${templateContext.scriptLogHead.length}), will truncate before posting to Slack.`, + `[QSEOW] SLACK: Script log head field is too long (${templateContext.scriptLogHead.length}), will truncate before posting to Slack.`, ); templateContext.scriptLogHead = templateContext.scriptLogHead .replaceAll('&', '&') @@ -771,7 +779,7 @@ export function sendReloadTaskAbortedNotificationSlack(reloadParams) { if (templateContext.scriptLogTail.length >= 3000) { globals.logger.warn( - `SLACK: Script log head field is too long (${templateContext.scriptLogTail.length}), will truncate before posting to Slack.`, + `[QSEOW] SLACK: Script log head field is too long (${templateContext.scriptLogTail.length}), will truncate before posting to Slack.`, ); templateContext.scriptLogTail = templateContext.scriptLogTail .replaceAll('&', '&') @@ -795,15 +803,15 @@ export function sendReloadTaskAbortedNotificationSlack(reloadParams) { sendSlack(slackConfig, templateContext, 'reload'); } catch (err) { - globals.logger.error(`SLACK RELOAD TASK ABORTED: ${err}`); + globals.logger.error(`[QSEOW] SLACK RELOAD TASK ABORTED: ${err}`); } return true; }) .catch((err) => { globals.logger.verbose( - `SLACK RELOAD TASK ABORTED: Rate limiting failed. Not sending reload notification Slack for task "${reloadParams.taskName}"`, + `[QSEOW] SLACK RELOAD TASK ABORTED: Rate limiting failed. Not sending reload notification Slack for task "${reloadParams.taskName}"`, ); - globals.logger.verbose(`SLACK RELOAD TASK ABORTED: Rate limiting details "${JSON.stringify(err, null, 2)}"`); + globals.logger.verbose(`[QSEOW] SLACK RELOAD TASK ABORTED: Rate limiting details "${JSON.stringify(err, null, 2)}"`); }); } @@ -813,9 +821,9 @@ export function sendServiceMonitorNotificationSlack(serviceParams) { .then(async (rateLimiterRes) => { try { globals.logger.info( - `SLACK SERVICE MONITOR: Rate limiting check passed for service monitor notification. Host: "${serviceParams.host}", service: "${serviceParams.serviceName}"`, + `[QSEOW] SLACK SERVICE MONITOR: Rate limiting check passed for service monitor notification. Host: "${serviceParams.host}", service: "${serviceParams.serviceName}"`, ); - globals.logger.verbose(`SLACK SERVICE MONITOR: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); + globals.logger.verbose(`[QSEOW] SLACK SERVICE MONITOR: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); // Make sure Slack sending is enabled in the config file and that we have all required settings const slackConfig = getSlackServiceMonitorNotificationConfig(serviceParams.serviceStatus); @@ -849,14 +857,14 @@ export function sendServiceMonitorNotificationSlack(serviceParams) { sendSlack(slackConfig, templateContext, 'serviceStarted'); } } catch (err) { - globals.logger.error(`SLACK SERVICE MONITOR: ${err}`); + globals.logger.error(`[QSEOW] SLACK SERVICE MONITOR: ${err}`); } return true; }) .catch((err) => { globals.logger.warn( - `SLACK SERVICE MONITOR: Rate limiting failed. Not sending service monitor notification for service "${serviceParams.serviceName}" on host "${serviceParams.host}"`, + `[QSEOW] SLACK SERVICE MONITOR: Rate limiting failed. Not sending service monitor notification for service "${serviceParams.serviceName}" on host "${serviceParams.host}"`, ); - globals.logger.debug(`SLACK SERVICE MONITOR: Rate limiting details "${JSON.stringify(err, null, 2)}"`); + globals.logger.debug(`[QSEOW] SLACK SERVICE MONITOR: Rate limiting details "${JSON.stringify(err, null, 2)}"`); }); } diff --git a/src/lib/qseow/smtp.js b/src/lib/qseow/smtp.js index cad3ae22..45fe00ed 100644 --- a/src/lib/qseow/smtp.js +++ b/src/lib/qseow/smtp.js @@ -57,13 +57,13 @@ export function isSmtpConfigOk() { // First make sure email sending is enabled in the config file if (!globals.config.get('Butler.emailNotification.enable')) { // SMTP is disabled - globals.logger.error("EMAIL CONFIG: SMTP notifications are disabled in config file - won't send email"); + globals.logger.error('[QSEOW] EMAIL CONFIG: SMTP notifications are disabled in config file - will not send email'); return false; } return true; } catch (err) { - globals.logger.error(`EMAIL CONFIG: ${err}`); + globals.logger.error(`[QSEOW] EMAIL CONFIG: ${err}`); return false; } } @@ -73,13 +73,15 @@ function isEmailReloadSuccessNotificationConfigOk() { // First make sure email sending is enabled in the config file if (!globals.config.get('Butler.emailNotification.reloadTaskSuccess.enable')) { // SMTP is disabled - globals.logger.error("EMAIL CONFIG: Reload success email notifications are disabled in config file - won't send email"); + globals.logger.error( + '[QSEOW] EMAIL CONFIG: Reload success email notifications are disabled in config file - will not send email', + ); return false; } return true; } catch (err) { - globals.logger.error(`EMAIL CONFIG: ${err}`); + globals.logger.error(`[QSEOW] EMAIL CONFIG: ${err}`); return false; } } @@ -89,13 +91,15 @@ function isEmailReloadFailedNotificationConfigOk() { // First make sure email sending is enabled in the config file if (!globals.config.get('Butler.emailNotification.reloadTaskFailure.enable')) { // SMTP is disabled - globals.logger.error("EMAIL CONFIG: Reload failure email notifications are disabled in config file - won't send email"); + globals.logger.error( + '[QSEOW] EMAIL CONFIG: Reload failure email notifications are disabled in config file - will not send email', + ); return false; } return true; } catch (err) { - globals.logger.error(`EMAIL CONFIG: ${err}`); + globals.logger.error(`[QSEOW] EMAIL CONFIG: ${err}`); return false; } } @@ -105,13 +109,15 @@ function isEmailReloadAbortedNotificationConfigOk() { // First make sure email sending is enabled in the config file if (!globals.config.get('Butler.emailNotification.reloadTaskAborted.enable')) { // SMTP is disabled - globals.logger.error("EMAIL CONFIG: Reload aborted email notifications are disabled in config file - won't send email"); + globals.logger.error( + '[QSEOW] EMAIL CONFIG: Reload aborted email notifications are disabled in config file - will not send email', + ); return false; } return true; } catch (err) { - globals.logger.error(`EMAIL CONFIG: ${err}`); + globals.logger.error(`[QSEOW] EMAIL CONFIG: ${err}`); return false; } } @@ -124,13 +130,15 @@ function isEmailServiceMonitorNotificationConfig() { !globals.config.get('Butler.serviceMonitor.alertDestination.email.enable') ) { // SMTP is disabled - globals.logger.error("EMAIL CONFIG: Service monitor email notifications are disabled in config file - won't send email"); + globals.logger.error( + '[QSEOW] EMAIL CONFIG: Service monitor email notifications are disabled in config file - will not send email', + ); return false; } return true; } catch (err) { - globals.logger.error(`EMAIL CONFIG: ${err}`); + globals.logger.error(`[QSEOW] EMAIL CONFIG: ${err}`); return false; } } @@ -209,22 +217,24 @@ export async function sendEmail(from, recipientsEmail, emailPriority, subjectHan // Verify SMTP configuration // eslint-disable-next-line no-await-in-loop const smtpStatus = await transporter.verify(); - globals.logger.debug(`EMAIL CONFIG: SMTP status: ${smtpStatus}`); - globals.logger.debug(`EMAIL CONFIG: Message=${JSON.stringify(message, null, 2)}`); + globals.logger.debug(`[QSEOW] EMAIL CONFIG: SMTP status: ${smtpStatus}`); + globals.logger.debug(`[QSEOW] EMAIL CONFIG: Message=${JSON.stringify(message, null, 2)}`); if (smtpStatus) { // eslint-disable-next-line no-await-in-loop const result = await transporter.sendMail(message); - globals.logger.debug(`EMAIL CONFIG: Sending reload failure notification result: ${JSON.stringify(result, null, 2)}`); + globals.logger.debug( + `[QSEOW] EMAIL CONFIG: Sending reload failure notification result: ${JSON.stringify(result, null, 2)}`, + ); } else { - globals.logger.warn('EMAIL CONFIG: SMTP transporter not ready'); + globals.logger.warn('[QSEOW] EMAIL CONFIG: SMTP transporter not ready'); } } else { - globals.logger.warn(`EMAIL CONFIG: Recipient email adress not valid: ${recipientEmail}`); + globals.logger.warn(`[QSEOW] EMAIL CONFIG: Recipient email adress not valid: ${recipientEmail}`); } } } catch (err) { - globals.logger.error(`EMAIL CONFIG: ${err}`); + globals.logger.error(`[QSEOW] EMAIL CONFIG: ${err}`); } } @@ -256,22 +266,22 @@ export async function sendEmailBasic(from, recipientsEmail, emailPriority, subje // Verify SMTP configuration // eslint-disable-next-line no-await-in-loop const smtpStatus = await transporter.verify(); - globals.logger.debug(`SMTP BASIC: SMTP status: ${smtpStatus}`); - globals.logger.debug(`SMTP BASIC: Message=${JSON.stringify(message, null, 2)}`); + globals.logger.debug(`[QSEOW] SMTP BASIC: SMTP status: ${smtpStatus}`); + globals.logger.debug(`[QSEOW] SMTP BASIC: Message=${JSON.stringify(message, null, 2)}`); if (smtpStatus) { // eslint-disable-next-line no-await-in-loop const result = await transporter.sendMail(message); - globals.logger.debug(`SMTP BASIC: Sending email result: ${JSON.stringify(result, null, 2)}`); + globals.logger.debug(`[QSEOW] SMTP BASIC: Sending email result: ${JSON.stringify(result, null, 2)}`); } else { globals.logger.warn('SMTP BASIC: SMTP transporter not ready'); } } else { - globals.logger.warn(`SMTP BASIC: Recipient email adress not valid: ${recipientEmail}`); + globals.logger.warn(`[QSEOW] SMTP BASIC: Recipient email adress not valid: ${recipientEmail}`); } } } catch (err) { - globals.logger.error(`SMTP BASIC: ${err}`); + globals.logger.error(`[QSEOW] SMTP BASIC: ${err}`); } } @@ -321,7 +331,7 @@ export async function sendReloadTaskFailureNotificationEmail(reloadParams) { if (taskSpecificAlertEmailAddresses?.length > 0) { globals.logger.debug( - `EMAIL RELOAD TASK FAILED ALERT: Added task specific send list: ${JSON.stringify(taskSpecificAlertEmailAddresses, null, 2)}`, + `[QSEOW] EMAIL RELOAD TASK FAILED ALERT: Added task specific send list: ${JSON.stringify(taskSpecificAlertEmailAddresses, null, 2)}`, ); mainSendList = mainSendList.concat(taskSpecificAlertEmailAddresses); @@ -331,11 +341,11 @@ export async function sendReloadTaskFailureNotificationEmail(reloadParams) { // 2 Should alert emails be sent for all failed reload tasks? if (globals.config.get('Butler.emailNotification.reloadTaskFailure.alertEnableByCustomProperty.enable') === false) { // 2.1 Yes: Add system-wide list of recipients to send list - globals.logger.verbose(`EMAIL RELOAD TASK FAILED ALERT: Send alert emails for all tasks`); + globals.logger.verbose(`[QSEOW] EMAIL RELOAD TASK FAILED ALERT: Send alert emails for all tasks`); if (globalSendList?.length > 0) { globals.logger.debug( - `EMAIL RELOAD TASK FAILED ALERT: Added global send list for failed task: ${JSON.stringify(globalSendList, null, 2)}`, + `[QSEOW] EMAIL RELOAD TASK FAILED ALERT: Added global send list for failed task: ${JSON.stringify(globalSendList, null, 2)}`, ); mainSendList = mainSendList.concat(globalSendList); emailRecipientsVerbose.common = emailRecipientsVerbose.common.concat(globalSendList); @@ -344,14 +354,14 @@ export async function sendReloadTaskFailureNotificationEmail(reloadParams) { // Only send alert email if the failed task has email alerts enabled // 2.2 No : Does the failed reload task have alerts turned on (using custom property)? globals.logger.verbose( - `EMAIL RELOAD TASK FAILED ALERT: Only send alert emails for tasks with email-alert-CP "${emailAlertCpName}" set`, + `[QSEOW] EMAIL RELOAD TASK FAILED ALERT: Only send alert emails for tasks with email-alert-CP "${emailAlertCpName}" set`, ); const sendAlert = await isCustomPropertyValueSet(reloadParams.taskId, emailAlertCpName, emailAlertCpEnabledValue); if (sendAlert === true) { globals.logger.debug( - `EMAIL RELOAD TASK FAILED ALERT: Added send list based on email-alert-CP: ${JSON.stringify(globalSendList, null, 2)}`, + `[QSEOW] EMAIL RELOAD TASK FAILED ALERT: Added send list based on email-alert-CP: ${JSON.stringify(globalSendList, null, 2)}`, ); // 2.2.1 Yes: Add system-wide list of recipients to send list if (globalSendList?.length > 0) { @@ -397,7 +407,7 @@ export async function sendReloadTaskFailureNotificationEmail(reloadParams) { } else { // No app owners on include list. Warn about this. globals.logger.warn( - `EMAIL RELOAD TASK FAILED ALERT: No app owners on include list for failed task. No app owners will receive notification emails.`, + `[QSEOW] EMAIL RELOAD TASK FAILED ALERT: No app owners on include list for failed task. No app owners will receive notification emails.`, ); } } @@ -426,12 +436,12 @@ export async function sendReloadTaskFailureNotificationEmail(reloadParams) { // Does the main sendlist contain any email addresses? Warn if not if (mainSendList?.length === 0) { globals.logger.warn( - `EMAIL RELOAD TASK FAILED ALERT: No email addresses defined for app owner's alert email for app "${reloadParams.appName}", ID=${reloadParams.appId}`, + `[QSEOW] EMAIL RELOAD TASK FAILED ALERT: No email addresses defined for app owner's alert email for app "${reloadParams.appName}", ID=${reloadParams.appId}`, ); } } else { globals.logger.warn( - `EMAIL RELOAD TASK FAILED ALERT: No email address for owner of app "${reloadParams.appName}", ID=${reloadParams.appId}`, + `[QSEOW] EMAIL RELOAD TASK FAILED ALERT: No email address for owner of app "${reloadParams.appName}", ID=${reloadParams.appId}`, ); } } @@ -441,15 +451,15 @@ export async function sendReloadTaskFailureNotificationEmail(reloadParams) { // Debug globals.logger.verbose( - `EMAIL RELOAD TASK FAILED ALERT: Final send list for failed task "${reloadParams.taskName}": ${JSON.stringify( + `[QSEOW] EMAIL RELOAD TASK FAILED ALERT: Final send list for failed task "${reloadParams.taskName}": ${JSON.stringify( mainSendListUnique, null, 2, )}`, ); - globals.logger.verbose(`EMAIL RELOAD TASK FAILED ALERT: App owner recipients: ${emailRecipientsVerbose.appOwner}`); - globals.logger.verbose(`EMAIL RELOAD TASK FAILED ALERT: Shared all tasks recipients: ${emailRecipientsVerbose.shared}`); - globals.logger.verbose(`EMAIL RELOAD TASK FAILED ALERT: Task specific recipients: ${emailRecipientsVerbose.taskSpecific}`); + globals.logger.verbose(`[QSEOW] EMAIL RELOAD TASK FAILED ALERT: App owner recipients: ${emailRecipientsVerbose.appOwner}`); + globals.logger.verbose(`[QSEOW] EMAIL RELOAD TASK FAILED ALERT: Shared all tasks recipients: ${emailRecipientsVerbose.shared}`); + globals.logger.verbose(`[QSEOW] EMAIL RELOAD TASK FAILED ALERT: Task specific recipients: ${emailRecipientsVerbose.taskSpecific}`); if (isSmtpConfigOk() === false) { return 1; @@ -477,7 +487,7 @@ export async function sendReloadTaskFailureNotificationEmail(reloadParams) { scriptLogData.scriptLogTail = ''; } - globals.logger.debug(`EMAIL RELOAD TASK FAILED ALERT: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`); + globals.logger.debug(`[QSEOW] EMAIL RELOAD TASK FAILED ALERT: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`); // Get Sense URLs from config file. Can be used as template fields. const senseUrls = getQlikSenseUrls(); @@ -564,10 +574,10 @@ export async function sendReloadTaskFailureNotificationEmail(reloadParams) { .then(async (rateLimiterRes) => { try { globals.logger.info( - `EMAIL RELOAD TASK FAILED ALERT: Rate limiting check passed for failed task notification. Task name: "${reloadParams.taskName}", Recipient: "${recipientEmailAddress}"`, + `[QSEOW] EMAIL RELOAD TASK FAILED ALERT: Rate limiting check passed for failed task notification. Task name: "${reloadParams.taskName}", Recipient: "${recipientEmailAddress}"`, ); globals.logger.debug( - `EMAIL RELOAD TASK FAILED ALERT: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, + `[QSEOW] EMAIL RELOAD TASK FAILED ALERT: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); // Only send email if there is at least one recipient @@ -582,17 +592,17 @@ export async function sendReloadTaskFailureNotificationEmail(reloadParams) { templateContext, ); } else { - globals.logger.warn(`EMAIL RELOAD TASK FAILED ALERT: No recipients to send alert email to.`); + globals.logger.warn(`[QSEOW] EMAIL RELOAD TASK FAILED ALERT: No recipients to send alert email to.`); } } catch (err) { - globals.logger.error(`EMAIL RELOAD TASK FAILED ALERT: ${err}`); + globals.logger.error(`[QSEOW] EMAIL RELOAD TASK FAILED ALERT: ${err}`); } }) .catch((err) => { globals.logger.warn( - `EMAIL RELOAD TASK FAILED ALERT: Rate limiting failed. Not sending reload notification email for task "${reloadParams.taskName}" to "${recipientEmailAddress}"`, + `[QSEOW] EMAIL RELOAD TASK FAILED ALERT: Rate limiting failed. Not sending reload notification email for task "${reloadParams.taskName}" to "${recipientEmailAddress}"`, ); - globals.logger.debug(`EMAIL RELOAD TASK FAILED ALERT: Rate limiting details "${JSON.stringify(err, null, 2)}"`); + globals.logger.debug(`[QSEOW] EMAIL RELOAD TASK FAILED ALERT: Rate limiting details "${JSON.stringify(err, null, 2)}"`); }); } } @@ -642,7 +652,7 @@ export async function sendReloadTaskAbortedNotificationEmail(reloadParams) { if (taskSpecificAlertEmailAddresses?.length > 0) { globals.logger.debug( - `EMAIL RELOAD TASK ABORTED ALERT: Added task specific send list: ${JSON.stringify(taskSpecificAlertEmailAddresses, null, 2)}`, + `[QSEOW] EMAIL RELOAD TASK ABORTED ALERT: Added task specific send list: ${JSON.stringify(taskSpecificAlertEmailAddresses, null, 2)}`, ); mainSendList = mainSendList.concat(taskSpecificAlertEmailAddresses); @@ -652,11 +662,11 @@ export async function sendReloadTaskAbortedNotificationEmail(reloadParams) { // 2 Should alert emails be sent for all aborted reload tasks? if (globals.config.get('Butler.emailNotification.reloadTaskAborted.alertEnableByCustomProperty.enable') === false) { // 2.1 Yes: Add system-wide list of recipients to send list - globals.logger.verbose(`EMAIL RELOAD TASK ABORTED ALERT: Send alert emails for all tasks`); + globals.logger.verbose(`[QSEOW] EMAIL RELOAD TASK ABORTED ALERT: Send alert emails for all tasks`); if (globalSendList?.length > 0) { globals.logger.debug( - `EMAIL RELOAD TASK ABORTED ALERT: Added global send list for failed task: ${JSON.stringify(globalSendList, null, 2)}`, + `[QSEOW] EMAIL RELOAD TASK ABORTED ALERT: Added global send list for failed task: ${JSON.stringify(globalSendList, null, 2)}`, ); mainSendList = mainSendList.concat(globalSendList); emailRecipientsVerbose.common = emailRecipientsVerbose.common.concat(globalSendList); @@ -665,14 +675,14 @@ export async function sendReloadTaskAbortedNotificationEmail(reloadParams) { // Only send alert email if the aborted task has email alerts enabled // 2.2 No : Does the aborted reload task have alerts turned on (using custom property)? globals.logger.verbose( - `EMAIL RELOAD TASK ABORTED ALERT: Only send alert emails for tasks with email-alert-CP "${emailAlertCpName}" set`, + `[QSEOW] EMAIL RELOAD TASK ABORTED ALERT: Only send alert emails for tasks with email-alert-CP "${emailAlertCpName}" set`, ); const sendAlert = await isCustomPropertyValueSet(reloadParams.taskId, emailAlertCpName, emailAlertCpEnabledValue); if (sendAlert === true) { globals.logger.debug( - `EMAIL RELOAD TASK ABORTED ALERT: Added send list based on email-alert-CP: ${JSON.stringify(globalSendList, null, 2)}`, + `[QSEOW] EMAIL RELOAD TASK ABORTED ALERT: Added send list based on email-alert-CP: ${JSON.stringify(globalSendList, null, 2)}`, ); // 2.2.1 Yes: Add system-wide list of recipients to send list if (globalSendList?.length > 0) { @@ -742,12 +752,12 @@ export async function sendReloadTaskAbortedNotificationEmail(reloadParams) { // Does the main sendlist contain any email addresses? Warn if not if (mainSendList?.length === 0) { globals.logger.warn( - `EMAIL RELOAD TASK ABORTED ALERT: No email addresses defined for alert email to app "${reloadParams.appName}", ID=${reloadParams.appId}`, + `[QSEOW] EMAIL RELOAD TASK ABORTED ALERT: No email addresses defined for alert email to app "${reloadParams.appName}", ID=${reloadParams.appId}`, ); } } else { globals.logger.warn( - `EMAIL RELOAD TASK ABORTED ALERT: No email address for owner of app "${reloadParams.appName}", ID=${reloadParams.appId}`, + `[QSEOW] EMAIL RELOAD TASK ABORTED ALERT: No email address for owner of app "${reloadParams.appName}", ID=${reloadParams.appId}`, ); } } @@ -757,15 +767,15 @@ export async function sendReloadTaskAbortedNotificationEmail(reloadParams) { // Debug globals.logger.verbose( - `EMAIL RELOAD TASK ABORTED ALERT: Final send list for failed task "${reloadParams.taskName}": ${JSON.stringify( + `[QSEOW] EMAIL RELOAD TASK ABORTED ALERT: Final send list for failed task "${reloadParams.taskName}": ${JSON.stringify( mainSendListUnique, null, 2, )}`, ); - globals.logger.verbose(`EMAIL RELOAD TASK ABORTED ALERT: App owner recipients: ${emailRecipientsVerbose.appOwner}`); - globals.logger.verbose(`EMAIL RELOAD TASK ABORTED ALERT: Shared all tasks recipients: ${emailRecipientsVerbose.shared}`); - globals.logger.verbose(`EMAIL RELOAD TASK ABORTED ALERT: Task specific recipients: ${emailRecipientsVerbose.taskSpecific}`); + globals.logger.verbose(`[QSEOW] EMAIL RELOAD TASK ABORTED ALERT: App owner recipients: ${emailRecipientsVerbose.appOwner}`); + globals.logger.verbose(`[QSEOW] EMAIL RELOAD TASK ABORTED ALERT: Shared all tasks recipients: ${emailRecipientsVerbose.shared}`); + globals.logger.verbose(`[QSEOW] EMAIL RELOAD TASK ABORTED ALERT: Task specific recipients: ${emailRecipientsVerbose.taskSpecific}`); if (isSmtpConfigOk() === false) { return 1; @@ -793,7 +803,7 @@ export async function sendReloadTaskAbortedNotificationEmail(reloadParams) { scriptLogData.scriptLogTail = ''; } - globals.logger.debug(`EMAIL RELOAD TASK ABORTED ALERT: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`); + globals.logger.debug(`[QSEOW] EMAIL RELOAD TASK ABORTED ALERT: Script log data:\n${JSON.stringify(scriptLogData, null, 2)}`); // Get Sense URLs from config file. Can be used as template fields. const senseUrls = getQlikSenseUrls(); @@ -880,10 +890,10 @@ export async function sendReloadTaskAbortedNotificationEmail(reloadParams) { .then(async (rateLimiterRes) => { try { globals.logger.info( - `EMAIL RELOAD TASK ABORTED ALERT: Rate limiting check passed for aborted task notification. Task name: "${reloadParams.taskName}", Recipient: "${recipientEmailAddress}"`, + `[QSEOW] EMAIL RELOAD TASK ABORTED ALERT: Rate limiting check passed for aborted task notification. Task name: "${reloadParams.taskName}", Recipient: "${recipientEmailAddress}"`, ); globals.logger.debug( - `EMAIL RELOAD TASK ABORTED ALERT: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, + `[QSEOW] EMAIL RELOAD TASK ABORTED ALERT: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); // Only send email if there is at least one recipient @@ -898,17 +908,17 @@ export async function sendReloadTaskAbortedNotificationEmail(reloadParams) { templateContext, ); } else { - globals.logger.warn(`EMAIL RELOAD TASK ABORTED ALERT: No recipients to send alert email to.`); + globals.logger.warn(`[QSEOW] EMAIL RELOAD TASK ABORTED ALERT: No recipients to send alert email to.`); } } catch (err) { - globals.logger.error(`EMAIL RELOAD TASK ABORTED ALERT: ${err}`); + globals.logger.error(`[QSEOW] EMAIL RELOAD TASK ABORTED ALERT: ${err}`); } }) .catch((err) => { globals.logger.warn( - `EMAIL RELOAD TASK ABORTED ALERT: Rate limiting failed. Not sending reload notification email for task "${reloadParams.taskName}" to "${recipientEmailAddress}"`, + `[QSEOW] EMAIL RELOAD TASK ABORTED ALERT: Rate limiting failed. Not sending reload notification email for task "${reloadParams.taskName}" to "${recipientEmailAddress}"`, ); - globals.logger.debug(`EMAIL RELOAD TASK ABORTED ALERT: Rate limiting details "${JSON.stringify(err, null, 2)}"`); + globals.logger.debug(`[QSEOW] EMAIL RELOAD TASK ABORTED ALERT: Rate limiting details "${JSON.stringify(err, null, 2)}"`); }); } } @@ -952,7 +962,7 @@ export async function sendReloadTaskSuccessNotificationEmail(reloadParams) { if (taskSpecificAlertEmailAddresses?.length > 0) { globals.logger.debug( - `EMAIL RELOAD TASK SUCCESS ALERT: Added task specific send list: ${JSON.stringify(taskSpecificAlertEmailAddresses, null, 2)}`, + `[QSEOW] EMAIL RELOAD TASK SUCCESS ALERT: Added task specific send list: ${JSON.stringify(taskSpecificAlertEmailAddresses, null, 2)}`, ); mainSendList = mainSendList.concat(taskSpecificAlertEmailAddresses); @@ -962,11 +972,11 @@ export async function sendReloadTaskSuccessNotificationEmail(reloadParams) { // 2 Should alert emails be sent for all successful reload tasks? if (globals.config.get('Butler.emailNotification.reloadTaskSuccess.alertEnableByCustomProperty.enable') === false) { // 2.1 Yes: Add system-wide list of recipients to send list - globals.logger.verbose(`EMAIL RELOAD TASK SUCCESS ALERT: Send alert emails for all tasks`); + globals.logger.verbose(`[QSEOW] EMAIL RELOAD TASK SUCCESS ALERT: Send alert emails for all tasks`); if (globalSendList?.length > 0) { globals.logger.debug( - `EMAIL RELOAD TASK SUCCESS ALERT: Added global send list for succeesful task: ${JSON.stringify(globalSendList, null, 2)}`, + `[QSEOW] EMAIL RELOAD TASK SUCCESS ALERT: Added global send list for succeesful task: ${JSON.stringify(globalSendList, null, 2)}`, ); mainSendList = mainSendList.concat(globalSendList); emailRecipientsVerbose.common = emailRecipientsVerbose.common.concat(globalSendList); @@ -975,14 +985,14 @@ export async function sendReloadTaskSuccessNotificationEmail(reloadParams) { // Only send alert email if the successful task has email alerts enabled // 2.2 No : Does the failed reload task have alerts turned on (using custom property)? globals.logger.verbose( - `EMAIL RELOAD TASK SUCCESS ALERT: Only send alert emails for tasks with email-alert-CP "${emailAlertCpName}" set`, + `[QSEOW] EMAIL RELOAD TASK SUCCESS ALERT: Only send alert emails for tasks with email-alert-CP "${emailAlertCpName}" set`, ); const sendAlert = await isCustomPropertyValueSet(reloadParams.taskId, emailAlertCpName, emailAlertCpEnabledValue); if (sendAlert === true) { globals.logger.debug( - `EMAIL RELOAD TASK SUCCESS ALERT: Added send list based on email-alert-CP: ${JSON.stringify(globalSendList, null, 2)}`, + `[QSEOW] EMAIL RELOAD TASK SUCCESS ALERT: Added send list based on email-alert-CP: ${JSON.stringify(globalSendList, null, 2)}`, ); // 2.2.1 Yes: Add system-wide list of recipients to send list if (globalSendList?.length > 0) { @@ -999,14 +1009,14 @@ export async function sendReloadTaskSuccessNotificationEmail(reloadParams) { // Debug globals.logger.verbose( - `EMAIL RELOAD TASK SUCCESS ALERT: Final send list for successful task "${reloadParams.taskName}": ${JSON.stringify( + `[QSEOW] EMAIL RELOAD TASK SUCCESS ALERT: Final send list for successful task "${reloadParams.taskName}": ${JSON.stringify( mainSendListUnique, null, 2, )}`, ); - globals.logger.verbose(`EMAIL RELOAD TASK SUCCESS ALERT: Shared all tasks recipients: ${emailRecipientsVerbose.shared}`); - globals.logger.verbose(`EMAIL RELOAD TASK SUCCESS ALERT: Task specific recipients: ${emailRecipientsVerbose.taskSpecific}`); + globals.logger.verbose(`[QSEOW] EMAIL RELOAD TASK SUCCESS ALERT: Shared all tasks recipients: ${emailRecipientsVerbose.shared}`); + globals.logger.verbose(`[QSEOW] EMAIL RELOAD TASK SUCCESS ALERT: Task specific recipients: ${emailRecipientsVerbose.taskSpecific}`); if (isSmtpConfigOk() === false) { return 1; @@ -1034,8 +1044,8 @@ export async function sendReloadTaskSuccessNotificationEmail(reloadParams) { scriptLogData.scriptLogTail = ''; } - globals.logger.debug(`EMAIL RELOAD TASK SUCCESS ALERT: Script log head:\n${scriptLogData.scriptLogHead}`); - globals.logger.debug(`EMAIL RELOAD TASK SUCCESS ALERT: Script log tail:\n${scriptLogData.scriptLogTail}`); + globals.logger.debug(`[QSEOW] EMAIL RELOAD TASK SUCCESS ALERT: Script log head:\n${scriptLogData.scriptLogHead}`); + globals.logger.debug(`[QSEOW] EMAIL RELOAD TASK SUCCESS ALERT: Script log tail:\n${scriptLogData.scriptLogTail}`); // Get app owner const appOwner = await getAppOwner(reloadParams.appId); @@ -1125,10 +1135,10 @@ export async function sendReloadTaskSuccessNotificationEmail(reloadParams) { .then(async (rateLimiterRes) => { try { globals.logger.info( - `EMAIL RELOAD TASK SUCCESS ALERT: Rate limiting check passed for successful task notification. Task name: "${reloadParams.taskName}", Recipient: "${recipientEmailAddress}"`, + `[QSEOW] EMAIL RELOAD TASK SUCCESS ALERT: Rate limiting check passed for successful task notification. Task name: "${reloadParams.taskName}", Recipient: "${recipientEmailAddress}"`, ); globals.logger.debug( - `EMAIL RELOAD TASK SUCCESS ALERT: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, + `[QSEOW] EMAIL RELOAD TASK SUCCESS ALERT: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); // Only send email if there is at least one recipient @@ -1143,17 +1153,17 @@ export async function sendReloadTaskSuccessNotificationEmail(reloadParams) { templateContext, ); } else { - globals.logger.warn(`EMAIL RELOAD TASK SUCCESS ALERT: No recipients to send alert email to.`); + globals.logger.warn(`[QSEOW] EMAIL RELOAD TASK SUCCESS ALERT: No recipients to send alert email to.`); } } catch (err) { - globals.logger.error(`EMAIL RELOAD TASK SUCCESS ALERT: ${err}`); + globals.logger.error(`[QSEOW] EMAIL RELOAD TASK SUCCESS ALERT: ${err}`); } }) .catch((err) => { globals.logger.warn( - `EMAIL RELOAD TASK SUCCESS ALERT: Rate limiting failed. Not sending reload notification email for task "${reloadParams.taskName}" to "${recipientEmailAddress}"`, + `[QSEOW] EMAIL RELOAD TASK SUCCESS ALERT: Rate limiting failed. Not sending reload notification email for task "${reloadParams.taskName}" to "${recipientEmailAddress}"`, ); - globals.logger.debug(`EMAIL RELOAD TASK SUCCESS ALERT: Rate limiting details "${JSON.stringify(err, null, 2)}"`); + globals.logger.debug(`[QSEOW] EMAIL RELOAD TASK SUCCESS ALERT: Rate limiting details "${JSON.stringify(err, null, 2)}"`); }); } } @@ -1200,7 +1210,7 @@ export async function sendServiceMonitorNotificationEmail(serviceParams) { mainSendList = mainSendList.concat(globalSendList); } else { // Warn there are no recipients to send email to - globals.logger.warn(`EMAIL SERVICE MONITOR: No recipients to send alert email to.`); + globals.logger.warn(`[QSEOW] EMAIL SERVICE MONITOR: No recipients to send alert email to.`); } // Make sure send list does not contain any duplicate email addresses @@ -1214,9 +1224,11 @@ export async function sendServiceMonitorNotificationEmail(serviceParams) { .then(async (rateLimiterRes) => { try { globals.logger.info( - `EMAIL SERVICE MONITOR: Rate limiting check passed for service monitor notification. Host: "${serviceParams.host}", service: "${serviceParams.serviceName}", recipient: "${recipientEmailAddress}"`, + `[QSEOW] EMAIL SERVICE MONITOR: Rate limiting check passed for service monitor notification. Host: "${serviceParams.host}", service: "${serviceParams.serviceName}", recipient: "${recipientEmailAddress}"`, + ); + globals.logger.debug( + `[QSEOW] EMAIL SERVICE MONITOR: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); - globals.logger.debug(`EMAIL SERVICE MONITOR: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); // Only send email if there is at least one recipient if (recipientEmailAddress.length > 0) { @@ -1242,18 +1254,18 @@ export async function sendServiceMonitorNotificationEmail(serviceParams) { ); } } else { - globals.logger.warn(`EMAIL SERVICE MONITOR: No recipients to send alert email to.`); + globals.logger.warn(`[QSEOW] EMAIL SERVICE MONITOR: No recipients to send alert email to.`); } } catch (err) { - globals.logger.error(`EMAIL SERVICE MONITOR: ${err}`); + globals.logger.error(`[QSEOW] EMAIL SERVICE MONITOR: ${err}`); } }) // eslint-disable-next-line no-loop-func .catch((err) => { globals.logger.warn( - `EMAIL SERVICE MONITOR: Rate limiting failed. Not sending reload notification email for service service "${serviceParams.serviceName}" on host "${serviceParams.host}" to "${recipientEmailAddress}"`, + `[QSEOW] EMAIL SERVICE MONITOR: Rate limiting failed. Not sending reload notification email for service service "${serviceParams.serviceName}" on host "${serviceParams.host}" to "${recipientEmailAddress}"`, ); - globals.logger.debug(`EMAIL SERVICE MONITOR: Rate limiting details "${JSON.stringify(err, null, 2)}"`); + globals.logger.debug(`[QSEOW] EMAIL SERVICE MONITOR: Rate limiting details "${JSON.stringify(err, null, 2)}"`); }); } } diff --git a/src/lib/webhook_notification.js b/src/lib/qseow/webhook_notification.js similarity index 82% rename from src/lib/webhook_notification.js rename to src/lib/qseow/webhook_notification.js index 1a8c9841..9dad53ef 100644 --- a/src/lib/webhook_notification.js +++ b/src/lib/qseow/webhook_notification.js @@ -3,8 +3,8 @@ import axios from 'axios'; import fs from 'fs'; import https from 'https'; -import globals from '../globals.js'; -import getAppOwner from '../qrs_util/get_app_owner.js'; +import globals from '../../globals.js'; +import getAppOwner from '../../qrs_util/get_app_owner.js'; let rateLimiterMemoryFailedReloads; let rateLimiterMemoryAbortedReloads; @@ -84,7 +84,7 @@ function getOutgoingWebhookReloadFailedNotificationConfigOk() { ) { // Not enough info in config file globals.logger.error( - 'WEBHOOK OUT RELOAD TASK FAILED: Reload failure outgoing webhook config info missing in Butler config file', + '[QSEOW] WEBHOOKOUT RELOAD TASK FAILED: Reload failure outgoing webhook config info missing in Butler config file', ); return false; } @@ -97,7 +97,7 @@ function getOutgoingWebhookReloadFailedNotificationConfigOk() { webhooks: globals.config.get('Butler.webhookNotification.reloadTaskFailure.webhooks'), }; } catch (err) { - globals.logger.error(`WEBHOOK OUT RELOAD TASK FAILED: ${err}`); + globals.logger.error(`[QSEOW] WEBHOOKOUT RELOAD TASK FAILED: ${err}`); return false; } } @@ -111,7 +111,7 @@ function getOutgoingWebhookReloadAbortedNotificationConfigOk() { ) { // Not enough info in config file globals.logger.error( - 'WEBHOOK OUT RELOAD TASK ABORTED: Reload aborted outgoing webhook config info missing in Butler config file', + '[QSEOW] WEBHOOKOUT RELOAD TASK ABORTED: Reload aborted outgoing webhook config info missing in Butler config file', ); return false; } @@ -124,7 +124,7 @@ function getOutgoingWebhookReloadAbortedNotificationConfigOk() { webhooks: globals.config.get('Butler.webhookNotification.reloadTaskAborted.webhooks'), }; } catch (err) { - globals.logger.error(`WEBHOOK OUT RELOAD TASK ABORTED: ${err}`); + globals.logger.error(`[QSEOW] WEBHOOKOUT RELOAD TASK ABORTED: ${err}`); return false; } } @@ -185,7 +185,7 @@ function getOutgoingWebhookQlikSenseServerLicenseMonitorConfig() { webhooks: globals.config.get('Butler.webhookNotification.qlikSenseServerLicenseMonitor.webhooks'), }; } catch (err) { - globals.logger.error(`WEBHOOK OUT QLIK SENSE SERVER LICENSE MONITOR: ${err}`); + globals.logger.error(`[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: ${err}`); return false; } } @@ -200,7 +200,7 @@ function getOutgoingWebhookQlikSenseServerLicenseExpiryAlertConfig() { webhooks: globals.config.get('Butler.webhookNotification.qlikSenseServerLicenseExpiryAlert.webhooks'), }; } catch (err) { - globals.logger.error(`WEBHOOK OUT QLIK SENSE SERVER LICENSE EXPIRY ALERT: ${err}`); + globals.logger.error(`[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE EXPIRY ALERT: ${err}`); return false; } } @@ -216,8 +216,8 @@ async function sendOutgoingWebhook(webhookConfig, reloadParams) { if (webhookConfig.webhooks) { // eslint-disable-next-line no-restricted-syntax for (const webhook of webhookConfig.webhooks) { - globals.logger.info(`WEBHOOKOUT: Processing webhook "${webhook.description}"`); - globals.logger.debug(`WEBHOOKOUT: Webhook details ${JSON.stringify(webhook)}`); + globals.logger.info(`[QSEOW] WEBHOOKOUT: Processing webhook "${webhook.description}"`); + globals.logger.debug(`[QSEOW] WEBHOOKOUT: Webhook details ${JSON.stringify(webhook)}`); // Only process the webhook if all required info is available let lowercaseMethod = null; @@ -239,25 +239,27 @@ async function sendOutgoingWebhook(webhookConfig, reloadParams) { if (webhook.cert && webhook.cert.enable === true) { // Make sure webhook.cert.rejectUnauthorized is a boolean if (typeof webhook.cert.rejectUnauthorized !== 'boolean') { - throw new Error('WEBHOOKOUT: Webhook cert.rejectUnauthorized property should be a boolean '); + throw new Error('[QSEOW] WEBHOOKOUT: Webhook cert.rejectUnauthorized property should be a boolean '); } // Make sure CA cert file in webhook.cert.certCA is a string if (typeof webhook.cert.certCA !== 'string') { - throw new Error('WEBHOOKOUT: Webhook cert.certCA property should be a string'); + throw new Error('[QSEOW] WEBHOOKOUT: Webhook cert.certCA property should be a string'); } // Make sure the CA cert file exists if (!fs.existsSync(webhook.cert.certCA)) { - throw new Error(`WEBHOOKOUT: CA cert file not found: ${webhook.cert.certCA}`); + throw new Error(`[QSEOW] WEBHOOKOUT: CA cert file not found: ${webhook.cert.certCA}`); } } } catch (err) { - globals.logger.error(`WEBHOOKOUT: ${err}. Invalid outgoing webhook config: ${JSON.stringify(webhook, null, 2)}`); + globals.logger.error( + `[QSEOW] WEBHOOKOUT: ${err}. Invalid outgoing webhook config: ${JSON.stringify(webhook, null, 2)}`, + ); throw err; } - globals.logger.debug(`WEBHOOKOUT: Webhook config is valid: ${JSON.stringify(webhook)}`); + globals.logger.debug(`[QSEOW] WEBHOOKOUT: Webhook config is valid: ${JSON.stringify(webhook)}`); axiosRequest = { timeout: 10000, @@ -284,7 +286,7 @@ async function sendOutgoingWebhook(webhookConfig, reloadParams) { url.search = params.toString(); - globals.logger.silly(`WEBHOOKOUT: Final GET webhook URL: ${url.toString()}`); + globals.logger.silly(`[QSEOW] WEBHOOKOUT: Final GET webhook URL: ${url.toString()}`); axiosRequest.method = 'get'; axiosRequest.url = url.toString(); @@ -381,40 +383,40 @@ async function sendOutgoingWebhook(webhookConfig, reloadParams) { try { // eslint-disable-next-line no-await-in-loop const response = await axios.request(axiosRequest); - globals.logger.debug(`WEBHOOKOUT: Webhook response: ${response}`); + globals.logger.debug(`[QSEOW] WEBHOOKOUT: Webhook response: ${response}`); } catch (err) { if (err.message) { - globals.logger.error(`WEBHOOKOUT: Webhook call failed: ${err.message}`); + globals.logger.error(`[QSEOW] WEBHOOKOUT: Webhook call failed: ${err.message}`); // err.response.status 404 could mean that the webhook URL is incorrect if (err.response && err.response.status === 404) { - globals.logger.error(`WEBHOOKOUT: 404 error could mean that the webhook URL is incorrect`); + globals.logger.error(`[QSEOW] WEBHOOKOUT: 404 error could mean that the webhook URL is incorrect`); } - globals.logger.error(`WEBHOOKOUT: Webhook url: ${axiosRequest.url}`); - globals.logger.error(`WEBHOOKOUT: Webhook config: ${JSON.stringify(webhook, null, 2)}`); + globals.logger.error(`[QSEOW] WEBHOOKOUT: Webhook url: ${axiosRequest.url}`); + globals.logger.error(`[QSEOW] WEBHOOKOUT: Webhook config: ${JSON.stringify(webhook, null, 2)}`); } // If neither message nor stack is available, just log the error object if (!err.message && !err.stack) { - globals.logger.error(`WEBHOOKOUT: Webhook call failed: ${JSON.stringify(err, null, 2)}`); + globals.logger.error(`[QSEOW] WEBHOOKOUT: Webhook call failed: ${JSON.stringify(err, null, 2)}`); } } } } else { - globals.logger.info('WEBHOOKOUT: No outgoing webhooks to process'); + globals.logger.info('[QSEOW] WEBHOOKOUT: No outgoing webhooks to process'); } } catch (err) { if (err.message) { - globals.logger.error(`WEBHOOKOUT 1 message: ${err.message}`); + globals.logger.error(`[QSEOW] WEBHOOKOUT 1 message: ${err.message}`); } if (err.stack) { - globals.logger.error(`WEBHOOKOUT 1 stack: ${err.stack}`); + globals.logger.error(`[QSEOW] WEBHOOKOUT 1 stack: ${err.stack}`); } // If neither message nor stack is available, just log the error object if (!err.message && !err.stack) { - globals.logger.error(`WEBHOOKOUT 1: ${JSON.stringify(err, null, 2)}`); + globals.logger.error(`[QSEOW] WEBHOOKOUT 1: ${JSON.stringify(err, null, 2)}`); } } } @@ -450,17 +452,17 @@ async function sendOutgoingWebhookServiceMonitor(webhookConfig, serviceParams) { if (webhook.cert && webhook.cert.enable === true) { // Make sure webhook.cert.rejectUnauthorized is a boolean if (typeof webhook.cert.rejectUnauthorized !== 'boolean') { - throw new Error('WEBHOOKOUT: Webhook cert.rejectUnauthorized property should be a boolean '); + throw new Error('[QSEOW] WEBHOOKOUT: Webhook cert.rejectUnauthorized property should be a boolean '); } // Make sure CA cert file in webhook.cert.certCA is a string if (typeof webhook.cert.certCA !== 'string') { - throw new Error('WEBHOOKOUT: Webhook cert.certCA property should be a string'); + throw new Error('[QSEOW] WEBHOOKOUT: Webhook cert.certCA property should be a string'); } // Make sure the CA cert file exists if (!fs.existsSync(webhook.cert.certCA)) { - throw new Error(`WEBHOOKOUT: CA cert file not found: ${webhook.cert.certCA}`); + throw new Error(`[QSEOW] WEBHOOKOUT: CA cert file not found: ${webhook.cert.certCA}`); } } } catch (err) { @@ -603,8 +605,8 @@ async function sendOutgoingWebhookQlikSenseServerLicense(webhookConfig, serverLi if (webhookConfig.webhooks) { // eslint-disable-next-line no-restricted-syntax for (const webhook of webhookConfig.webhooks) { - globals.logger.info(`WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: Processing webhook "${webhook.description}"`); - globals.logger.debug(`WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: Webhook details ${JSON.stringify(webhook)}`); + globals.logger.info(`[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: Processing webhook "${webhook.description}"`); + globals.logger.debug(`[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: Webhook details ${JSON.stringify(webhook)}`); // Only process the webhook if all required info is available let lowercaseMethod = null; @@ -627,25 +629,27 @@ async function sendOutgoingWebhookQlikSenseServerLicense(webhookConfig, serverLi // Make sure webhook.cert.rejectUnauthorized is a boolean if (typeof webhook.cert.rejectUnauthorized !== 'boolean') { throw new Error( - 'WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: Webhook cert.rejectUnauthorized property should be a boolean ', + '[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: Webhook cert.rejectUnauthorized property should be a boolean ', ); } // Make sure CA cert file in webhook.cert.certCA is a string if (typeof webhook.cert.certCA !== 'string') { throw new Error( - 'WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: Webhook cert.certCA property should be a string', + '[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: Webhook cert.certCA property should be a string', ); } // Make sure the CA cert file exists if (!fs.existsSync(webhook.cert.certCA)) { - throw new Error(`WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: CA cert file not found: ${webhook.cert.certCA}`); + throw new Error( + `[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: CA cert file not found: ${webhook.cert.certCA}`, + ); } } } catch (err) { globals.logger.error( - `WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: ${err}. Invalid outgoing webhook config: ${JSON.stringify( + `[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: ${err}. Invalid outgoing webhook config: ${JSON.stringify( webhook, null, 2, @@ -654,7 +658,9 @@ async function sendOutgoingWebhookQlikSenseServerLicense(webhookConfig, serverLi throw err; } - globals.logger.debug(`WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: Webhook config is valid: ${JSON.stringify(webhook)}`); + globals.logger.debug( + `[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: Webhook config is valid: ${JSON.stringify(webhook)}`, + ); axiosRequest = { timeout: 10000, @@ -670,7 +676,7 @@ async function sendOutgoingWebhookQlikSenseServerLicense(webhookConfig, serverLi url.search = params.toString(); - globals.logger.silly(`WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: Final GET webhook URL: ${url.toString()}`); + globals.logger.silly(`[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: Final GET webhook URL: ${url.toString()}`); axiosRequest.method = 'get'; axiosRequest.url = url.toString(); @@ -743,23 +749,23 @@ async function sendOutgoingWebhookQlikSenseServerLicense(webhookConfig, serverLi // eslint-disable-next-line no-await-in-loop const response = await axios.request(axiosRequest); - globals.logger.debug(`WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: Webhook response: ${response}`); + globals.logger.debug(`[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: Webhook response: ${response}`); } } else { - globals.logger.info('WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: No outgoing webhooks to process'); + globals.logger.info('[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: No outgoing webhooks to process'); } } catch (err) { if (err.message) { - globals.logger.error(`WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR 1 message: ${err.message}`); + globals.logger.error(`[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR 1 message: ${err.message}`); } if (err.stack) { - globals.logger.error(`WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR 1 stack: ${err.stack}`); + globals.logger.error(`[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR 1 stack: ${err.stack}`); } // If neither message nor stack is available, just log the error object if (!err.message && !err.stack) { - globals.logger.error(`WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR 1: ${JSON.stringify(err, null, 2)}`); + globals.logger.error(`[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR 1: ${JSON.stringify(err, null, 2)}`); } } } @@ -770,10 +776,10 @@ export function sendReloadTaskFailureNotificationWebhook(reloadParams) { .then(async (rateLimiterRes) => { try { globals.logger.info( - `WEBHOOK OUT RELOAD TASK FAILED: Rate limiting check passed for failed task notification. Task name: "${reloadParams.taskName}"`, + `[QSEOW] WEBHOOKOUT RELOAD TASK FAILED: Rate limiting check passed for failed task notification. Task name: "${reloadParams.taskName}"`, ); globals.logger.verbose( - `WEBHOOK OUT RELOAD TASK FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, + `[QSEOW] WEBHOOKOUT RELOAD TASK FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); // Make sure Slack sending is enabled in the config file and that we have all required settings @@ -784,15 +790,17 @@ export function sendReloadTaskFailureNotificationWebhook(reloadParams) { sendOutgoingWebhook(webhookConfig, reloadParams); } catch (err) { - globals.logger.error(`WEBHOOK OUT RELOAD TASK FAILED: ${err}`); + globals.logger.error(`[QSEOW] WEBHOOKOUT RELOAD TASK FAILED: ${err}`); } return true; }) .catch((rateLimiterRes) => { globals.logger.verbose( - `WEBHOOK OUT RELOAD TASK FAILED: Rate limiting failed. Not sending reload failure notification via outgoing webhook for task "${reloadParams.taskName}"`, + `[QSEOW] WEBHOOKOUT RELOAD TASK FAILED: Rate limiting failed. Not sending reload failure notification via outgoing webhook for task "${reloadParams.taskName}"`, + ); + globals.logger.verbose( + `[QSEOW] WEBHOOKOUT RELOAD TASK FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); - globals.logger.verbose(`WEBHOOK OUT RELOAD TASK FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); }); } @@ -802,10 +810,10 @@ export function sendReloadTaskAbortedNotificationWebhook(reloadParams) { .then(async (rateLimiterRes) => { try { globals.logger.info( - `WEBHOOK OUT RELOAD TASK ABORTED: Rate limiting check passed for aborted task notification. Task name: "${reloadParams.taskName}"`, + `[QSEOW] WEBHOOKOUT RELOAD TASK ABORTED: Rate limiting check passed for aborted task notification. Task name: "${reloadParams.taskName}"`, ); globals.logger.verbose( - `WEBHOOK OUT RELOAD TASK ABORTED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, + `[QSEOW] WEBHOOKOUT RELOAD TASK ABORTED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); // Make sure outgoing webhooks are enabled in the config file and that we have all required settings @@ -816,15 +824,17 @@ export function sendReloadTaskAbortedNotificationWebhook(reloadParams) { sendOutgoingWebhook(webhookConfig, reloadParams); } catch (err) { - globals.logger.error(`WEBHOOK OUT RELOAD TASK ABORTED: ${err}`); + globals.logger.error(`[QSEOW] WEBHOOKOUT RELOAD TASK ABORTED: ${err}`); } return true; }) .catch((rateLimiterRes) => { globals.logger.verbose( - `WEBHOOK OUT RELOAD TASK ABORTED: Rate limiting failed. Not sending reload aborted notification via outgoing webhook for task "${reloadParams.taskName}"`, + `[QSEOW] WEBHOOKOUT RELOAD TASK ABORTED: Rate limiting failed. Not sending reload aborted notification via outgoing webhook for task "${reloadParams.taskName}"`, + ); + globals.logger.verbose( + `[QSEOW] WEBHOOKOUT RELOAD TASK ABORTED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); - globals.logger.verbose(`WEBHOOK OUT RELOAD TASK ABORTED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); }); } @@ -862,9 +872,11 @@ export function sendServiceMonitorWebhook(svc) { }) .catch((rateLimiterRes) => { globals.logger.verbose( - `WEBHOOK OUT RELOAD TASK FAILED: Rate limiting failed. Not sending service monitor notification via outgoing webhook for service "${svc.serviceName}"`, + `[QSEOW] WEBHOOKOUT RELOAD TASK FAILED: Rate limiting failed. Not sending service monitor notification via outgoing webhook for service "${svc.serviceName}"`, + ); + globals.logger.verbose( + `[QSEOW] WEBHOOKOUT RELOAD TASK FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); - globals.logger.verbose(`WEBHOOK OUT RELOAD TASK FAILED: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`); }); } @@ -887,10 +899,10 @@ export async function callQlikSenseServerLicenseWebhook(serverLicenseInfo) { .then(async (rateLimiterRes) => { try { globals.logger.info( - `WEBHOOK OUT QLIK SENSE SERVER LICENSE MONITOR: Rate limiting check passed for Qlik Sense server license monitor notification`, + `[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: Rate limiting check passed for Qlik Sense server license monitor notification`, ); globals.logger.verbose( - `WEBHOOK OUT QLIK SENSE SERVER LICENSE MONITOR: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, + `[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); // Make sure outgoing webhooks are enabled in the config file and that we have all required settings @@ -901,16 +913,16 @@ export async function callQlikSenseServerLicenseWebhook(serverLicenseInfo) { await sendOutgoingWebhookQlikSenseServerLicense(webhookConfig, serverLicenseInfoCopy); } catch (err) { - globals.logger.error(`WEBHOOK OUT QLIK SENSE SERVER LICENSE MONITOR: ${err}`); + globals.logger.error(`[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: ${err}`); } return 0; }) .catch((rateLimiterRes) => { globals.logger.verbose( - `WEBHOOK OUT QLIK SENSE SERVER LICENSE MONITOR: Rate limiting failed. Not sending Qlik Sense server license monitor notification via outgoing webhook`, + `[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: Rate limiting failed. Not sending Qlik Sense server license monitor notification via outgoing webhook`, ); globals.logger.verbose( - `WEBHOOK OUT QLIK SENSE SERVER LICENSE MONITOR: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, + `[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE MONITOR: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); }); } else if ( @@ -923,10 +935,10 @@ export async function callQlikSenseServerLicenseWebhook(serverLicenseInfo) { .then(async (rateLimiterRes) => { try { globals.logger.info( - `WEBHOOK OUT QLIK SENSE SERVER LICENSE EXPIRY ALERT: Rate limiting check passed for Qlik Sense server license expiry alert`, + `[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE EXPIRY ALERT: Rate limiting check passed for Qlik Sense server license expiry alert`, ); globals.logger.verbose( - `WEBHOOK OUT QLIK SENSE SERVER LICENSE EXPIRY ALERT: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, + `[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE EXPIRY ALERT: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); // Make sure outgoing webhooks are enabled in the config file and that we have all required settings @@ -937,16 +949,16 @@ export async function callQlikSenseServerLicenseWebhook(serverLicenseInfo) { await sendOutgoingWebhookQlikSenseServerLicense(webhookConfig, serverLicenseInfoCopy); } catch (err) { - globals.logger.error(`WEBHOOK OUT QLIK SENSE SERVER LICENSE EXPIRY ALERT: ${err}`); + globals.logger.error(`[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE EXPIRY ALERT: ${err}`); } return 0; }) .catch((rateLimiterRes) => { globals.logger.verbose( - `WEBHOOK OUT QLIK SENSE SERVER LICENSE EXPIRY ALERT: Rate limiting failed. Not sending Qlik Sense server license expiry alert via outgoing webhook`, + `[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE EXPIRY ALERT: Rate limiting failed. Not sending Qlik Sense server license expiry alert via outgoing webhook`, ); globals.logger.verbose( - `WEBHOOK OUT QLIK SENSE SERVER LICENSE EXPIRY ALERT: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, + `[QSEOW] WEBHOOKOUT QLIK SENSE SERVER LICENSE EXPIRY ALERT: Rate limiting details "${JSON.stringify(rateLimiterRes, null, 2)}"`, ); }); } diff --git a/src/lib/qseow/winsvc.js b/src/lib/qseow/winsvc.js index 8b095bae..7e18f681 100644 --- a/src/lib/qseow/winsvc.js +++ b/src/lib/qseow/winsvc.js @@ -14,22 +14,22 @@ export function all(logger, host = null) { if (host === null) { // Run command for get states of all services on local machine - logger.verbose('WINSVC ALL: Getting all services on local machine'); + logger.verbose('[QSEOW] WINSVC ALL: Getting all services on local machine'); command = 'sc.exe query state= all'; } else { // A host other that local machine is specfied - logger.verbose(`WINSVC ALL: Getting all services on host ${host}`); + logger.verbose(`[QSEOW] WINSVC ALL: Getting all services on host ${host}`); command = `sc.exe \\\\${host} query state= all`; } - logger.debug(`WINSVC ALL: Running command ${command}`); + logger.debug(`[QSEOW] WINSVC ALL: Running command ${command}`); exec(command, (err, stdout) => { // On error, reject and exit if (err) { - logger.error(`WINSVC ALL: Error while getting all services on host ${host}`); + logger.error(`[QSEOW] WINSVC ALL: Error while getting all services on host ${host}`); if (err.code) { - logger.error(`WINSVC ALL: Error code: ${err.code}`); + logger.error(`[QSEOW] WINSVC ALL: Error code: ${err.code}`); } if (stdout) { @@ -48,7 +48,7 @@ export function all(logger, host = null) { .filter((line) => line.indexOf('SERVICE_NAME') !== -1) .map((line) => line.replace('SERVICE_NAME: ', '')); - logger.verbose(`WINSVC ALL: Got all ${lines.length} services on host ${host}`); + logger.verbose(`[QSEOW] WINSVC ALL: Got all ${lines.length} services on host ${host}`); logger.debug(lines); // Resolve with array of service names @@ -70,7 +70,7 @@ export function exists(logger, serviceName, host = null) { return new Promise((resolveExists, rejectExists) => { // With invalid service name, reject if (!serviceName) { - logger.error('WINSVC EXISTS: Service name is invalid'); + logger.error('[QSEOW] WINSVC EXISTS: Service name is invalid'); rejectExists(new Error('Service name is invalid')); return; @@ -79,18 +79,18 @@ export function exists(logger, serviceName, host = null) { // Is host reachable? // Get all services - logger.verbose(`WINSVC EXISTS: Getting all services on host ${host}`); + logger.verbose(`[QSEOW] WINSVC EXISTS: Getting all services on host ${host}`); all(logger, host).then( // On success, check (allServices) => { - logger.verbose(`WINSVC EXISTS: Checking if service ${serviceName} exists on host ${host}`); + logger.verbose(`[QSEOW] WINSVC EXISTS: Checking if service ${serviceName} exists on host ${host}`); // Find provided name for (let i = 0; i < allServices.length; ) { - logger.silly(`WINSVC EXISTS: Checking if service "${serviceName}" equals "${allServices[i]}"...`); + logger.silly(`[QSEOW] WINSVC EXISTS: Checking if service "${serviceName}" equals "${allServices[i]}"...`); if (allServices[i] === serviceName) { // Found, resolve true - logger.verbose(`WINSVC EXISTS: Found! Service ${serviceName} exists on host ${host}`); + logger.verbose(`[QSEOW] WINSVC EXISTS: Found! Service ${serviceName} exists on host ${host}`); resolveExists(true); return; @@ -100,15 +100,15 @@ export function exists(logger, serviceName, host = null) { } // Not found, resolve false - logger.verbose(`WINSVC EXISTS: Not found! Service ${serviceName} does not exists on host ${host}`); + logger.verbose(`[QSEOW] WINSVC EXISTS: Not found! Service ${serviceName} does not exists on host ${host}`); resolveExists(false); }, // Reject on error (err) => { - logger.error(`WINSVC EXISTS: Error while getting all services on host ${host}`); + logger.error(`[QSEOW] WINSVC EXISTS: Error while getting all services on host ${host}`); if (err.code) { - logger.error(`WINSVC EXISTS: Error code: ${err.code}`); + logger.error(`[QSEOW] WINSVC EXISTS: Error code: ${err.code}`); } rejectExists(err); @@ -130,22 +130,22 @@ export function statusAll(logger, host = null) { if (host === null) { // Run command for get states of all services on local machine - logger.verbose('WINSVC STATUSALL: Getting status of all services on local machine'); + logger.verbose('[QSEOW] WINSVC STATUSALL: Getting status of all services on local machine'); command = 'sc.exe query state= all'; } else { // A host other that local machine is specfied - logger.verbose(`WINSVC STATUSALL: Getting status of all services on host ${host}`); + logger.verbose(`[QSEOW] WINSVC STATUSALL: Getting status of all services on host ${host}`); command = `sc.exe \\\\${host} query state= all`; } // Run command for create service with provided data - logger.debug(`WINSVC STATUSALL: Running command ${command}`); + logger.debug(`[QSEOW] WINSVC STATUSALL: Running command ${command}`); exec(command, (err, stdout) => { // On error, reject and exit if (err) { - logger.error(`WINSVC STATUSALL: Error while getting status of all services on host ${host}`); + logger.error(`[QSEOW] WINSVC STATUSALL: Error while getting status of all services on host ${host}`); if (err.code) { - logger.error(`WINSVC STATUSALL: Error code: ${err.code}`); + logger.error(`[QSEOW] WINSVC STATUSALL: Error code: ${err.code}`); } reject(err); @@ -193,7 +193,7 @@ export function statusAll(logger, host = null) { return service; }); - logger.verbose(`WINSVC STATUSALL: Got status of all services on host ${host}`); + logger.verbose(`[QSEOW] WINSVC STATUSALL: Got status of all services on host ${host}`); logger.debug(serviceStatusAll); // Resolve with array of service objects @@ -215,7 +215,7 @@ export function status(logger, serviceName, host = null) { return new Promise((resolve, reject) => { // With invalid service name, reject if (!serviceName) { - logger.error('WINSVC STATUS: Service name is invalid'); + logger.error('[QSEOW] WINSVC STATUS: Service name is invalid'); reject(new Error('Service name is invalid')); return; @@ -225,11 +225,11 @@ export function status(logger, serviceName, host = null) { // exists(logger, serviceName, host).then( // (alreadyExists) => { // // serviceName exists on host - // logger.verbose(`WINSVC STATUS: Service ${serviceName} exists on host ${host}`); + // logger.verbose(`[QSEOW] WINSVC STATUS: Service ${serviceName} exists on host ${host}`); // // If exists, reject // if (!alreadyExists) { - // logger.verbose(`WINSVC STATUS: Service ${serviceName} does not exists on host ${host}`); + // logger.verbose(`[QSEOW] WINSVC STATUS: Service ${serviceName} does not exists on host ${host}`); // reject(new Error(`Service with name '${serviceName}' does not exists`)); // return; @@ -238,22 +238,22 @@ export function status(logger, serviceName, host = null) { let command = ''; if (host === null) { // Run command for get states of all services on local machine - logger.debug(`WINSVC STATUS: Getting status of service ${serviceName} on local machine`); + logger.debug(`[QSEOW] WINSVC STATUS: Getting status of service ${serviceName} on local machine`); command = `sc.exe query "${serviceName}"`; } else { // A host other that local machine is specfied - logger.debug(`WINSVC STATUS: Getting status of service ${serviceName} on host ${host}`); + logger.debug(`[QSEOW] WINSVC STATUS: Getting status of service ${serviceName} on host ${host}`); command = `sc.exe \\\\${host} query "${serviceName}"`; } // Run command for create service with provided data - logger.debug(`WINSVC STATUS: Running command ${command}`); + logger.debug(`[QSEOW] WINSVC STATUS: Running command ${command}`); exec(command, (err, stdout) => { // On error, reject and exit if (err) { - logger.error(`WINSVC STATUS: Error while getting status of service ${serviceName} on host ${host}`); + logger.error(`[QSEOW] WINSVC STATUS: Error while getting status of service ${serviceName} on host ${host}`); if (err.code) { - logger.error(`WINSVC STATUS: Error code: ${err.code}`); + logger.error(`[QSEOW] WINSVC STATUS: Error code: ${err.code}`); } reject(err); @@ -271,16 +271,16 @@ export function status(logger, serviceName, host = null) { const stateName = lines[0].indexOf('STOPPED') !== -1 ? 'STOPPED' : 'RUNNING'; // Return state name - logger.verbose(`WINSVC STATUS: Service ${serviceName} is ${stateName} on host ${host}`); + logger.verbose(`[QSEOW] WINSVC STATUS: Service ${serviceName} is ${stateName} on host ${host}`); resolve(stateName); }); // }, // // Reject on error // (err) => { - // logger.error(`WINSVC STATUS: Error while getting status of service ${serviceName} on host ${host}`); + // logger.error(`[QSEOW] WINSVC STATUS: Error while getting status of service ${serviceName} on host ${host}`); // if (err.code) { - // logger.error(`WINSVC STATUS: Error code: ${err.code}`); + // logger.error(`[QSEOW] WINSVC STATUS: Error code: ${err.code}`); // } // reject(err); @@ -302,23 +302,23 @@ export function details(logger, serviceName, host = null) { return new Promise((resolve, reject) => { // With invalid service name, reject if (!serviceName) { - logger.error('WINSVC DETAILS: Service name is invalid'); + logger.error('[QSEOW] WINSVC DETAILS: Service name is invalid'); reject(new Error('Service name is invalid')); return; } // Run check for service existance - // logger.verbose(`WINSVC DETAILS: Checking if service ${serviceName} exists on host ${host}`); + // logger.verbose(`[QSEOW] WINSVC DETAILS: Checking if service ${serviceName} exists on host ${host}`); // exists(logger, serviceName, host).then( // // Existance check completed // (alreadyExists) => { // // Service exists - // logger.verbose(`WINSVC DETAILS: Found! Service ${serviceName} exists on host ${host}`); + // logger.verbose(`[QSEOW] WINSVC DETAILS: Found! Service ${serviceName} exists on host ${host}`); // // If exists, reject // if (!alreadyExists) { - // logger.verbose(`WINSVC DETAILS: Not found! Service ${serviceName} does not exists on host ${host}`); + // logger.verbose(`[QSEOW] WINSVC DETAILS: Not found! Service ${serviceName} does not exists on host ${host}`); // reject(new Error(`Service with name '${serviceName}' does not exists`)); // return; @@ -327,18 +327,18 @@ export function details(logger, serviceName, host = null) { let command = ''; if (host === null) { // Run command for get states of all services on local machine - logger.debug(`WINSVC DETAILS: Getting details of service ${serviceName} on local machine`); + logger.debug(`[QSEOW] WINSVC DETAILS: Getting details of service ${serviceName} on local machine`); command = `sc.exe qc "${serviceName}"`; } else { // A host other that local machine is specfied - logger.debug(`WINSVC DETAILS: Getting details of service ${serviceName} on host ${host}`); + logger.debug(`[QSEOW] WINSVC DETAILS: Getting details of service ${serviceName} on host ${host}`); command = `sc.exe \\\\${host} qc "${serviceName}"`; } // Run command to get service details with provided data - logger.debug(`WINSVC DETAILS: Running command ${command}`); + logger.debug(`[QSEOW] WINSVC DETAILS: Running command ${command}`); exec(command, (err, stdout) => { let i = 0; const startTypeRegex = /\d/; @@ -356,9 +356,9 @@ export function details(logger, serviceName, host = null) { // On error, reject and exit if (err) { - logger.error(`WINSVC DETAILS: Error while getting details of service ${serviceName} on host ${host}`); + logger.error(`[QSEOW] WINSVC DETAILS: Error while getting details of service ${serviceName} on host ${host}`); if (err.code) { - logger.error(`WINSVC DETAILS 1: Error code: ${err.code}`); + logger.error(`[QSEOW] WINSVC DETAILS 1: Error code: ${err.code}`); } reject(err); @@ -367,7 +367,7 @@ export function details(logger, serviceName, host = null) { const lines = stdout.toString().split('\r\n'); // Debug log lines - logger.debug(`WINSVC DETAILS: Lines: ${lines}`); + logger.debug(`[QSEOW] WINSVC DETAILS: Lines: ${lines}`); let startTypeName = ''; @@ -386,20 +386,20 @@ export function details(logger, serviceName, host = null) { } // Show all details that will be returned - logger.verbose(`WINSVC DETAILS: Service ${serviceName} is ${startTypeName} on host ${host}`); - logger.verbose(`WINSVC DETAILS: Service ${serviceName} has dependencies ${deps}`); + logger.verbose(`[QSEOW] WINSVC DETAILS: Service ${serviceName} is ${startTypeName} on host ${host}`); + logger.verbose(`[QSEOW] WINSVC DETAILS: Service ${serviceName} has dependencies ${deps}`); logger.verbose( - `WINSVC DETAILS: Service ${serviceName} has exe path ${lines + `[QSEOW] WINSVC DETAILS: Service ${serviceName} has exe path ${lines .find((line) => line.indexOf('BINARY_PATH_NAME') !== -1) .replace(/\s*BINARY_PATH_NAME\s*: /, '')}`, ); logger.verbose( - `WINSVC DETAILS: Service ${serviceName} has display name ${lines + `[QSEOW] WINSVC DETAILS: Service ${serviceName} has display name ${lines .find((line) => line.indexOf('DISPLAY_NAME') !== -1) .replace(/\s*DISPLAY_NAME\s*: /, '')}`, ); logger.verbose( - `WINSVC DETAILS: Service ${serviceName} has name ${lines + `[QSEOW] WINSVC DETAILS: Service ${serviceName} has name ${lines .find((line) => line.indexOf('SERVICE_NAME: ') !== -1) .replace('SERVICE_NAME: ', '')}`, ); @@ -416,9 +416,9 @@ export function details(logger, serviceName, host = null) { // // Reject on error // (err) => { - // logger.error(`WINSVC DETAILS: Error while getting details of service ${serviceName} on host ${host}`); + // logger.error(`[QSEOW] WINSVC DETAILS: Error while getting details of service ${serviceName} on host ${host}`); // if (err.code) { - // logger.error(`WINSVC DETAILS 2: Error code: ${err.code}`); + // logger.error(`[QSEOW] WINSVC DETAILS 2: Error code: ${err.code}`); // } // reject(err); diff --git a/src/udp/udp_handlers.js b/src/udp/udp_handlers.js index aa3e04f3..c9307cb5 100644 --- a/src/udp/udp_handlers.js +++ b/src/udp/udp_handlers.js @@ -6,7 +6,7 @@ import { sendReloadTaskSuccessNotificationEmail, } from '../lib/qseow/smtp.js'; import { sendReloadTaskFailureNotificationSlack, sendReloadTaskAbortedNotificationSlack } from '../lib/qseow/slack_notification.js'; -import { sendReloadTaskAbortedNotificationWebhook, sendReloadTaskFailureNotificationWebhook } from '../lib/webhook_notification.js'; +import { sendReloadTaskAbortedNotificationWebhook, sendReloadTaskFailureNotificationWebhook } from '../lib/qseow/webhook_notification.js'; import { sendReloadTaskFailureNotificationTeams, sendReloadTaskAbortedNotificationTeams } from '../lib/qseow/msteams_notification.js'; import { sendReloadTaskFailureNotification, sendReloadTaskAbortedNotification } from '../lib/incident_mgmt/signl4.js'; import {