Skip to content

Commit

Permalink
Merge pull request #1268 from mountaindude/1265
Browse files Browse the repository at this point in the history
1265
  • Loading branch information
mountaindude authored Oct 14, 2024
2 parents ae1256f + 30e6a37 commit e299ae6
Show file tree
Hide file tree
Showing 10 changed files with 560 additions and 636 deletions.
11 changes: 8 additions & 3 deletions src/config/config-gen-api-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,14 @@ Butler:
# NOTE: Use an absolute path when running Butler as a standalone executable!
scriptLog:
storeOnDisk:
reloadTaskFailure:
enable: false
logDirectory: ...
clientManaged:
reloadTaskFailure:
enable: false
logDirectory: /path/to/scriptlogs/qseow
qsCloud:
appReloadFailure:
enable: false
logDirectory: /path/to/scriptlogs/qscloud

# Qlik Sense related links used in notification messages
qlikSenseUrls:
Expand Down
31 changes: 18 additions & 13 deletions src/config/production_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,22 @@ Butler:
# NOTE: Use an absolute path when running Butler as a standalone executable!
scriptLog:
storeOnDisk:
reloadTaskFailure:
enable: false
logDirectory: /path/to/scriptlogs
clientManaged:
reloadTaskFailure:
enable: false
logDirectory: /path/to/scriptlogs/qseow
qsCloud:
appReloadFailure:
enable: false
logDirectory: /path/to/scriptlogs/qscloud

# Qlik Sense related links used in notification messages
# Qlik Sense (client-managed) related links used in notification messages
qlikSenseUrls:
qmc: <URL to Qlik Sense QMC>
hub: <URL to Qlik Sense Hub>
appBaseUrl: <URL to Qlik Sense hub>/<virtual proxy, if any>/sense/app # Base URL for Qlik Sense apps, for example http://sense.mycompany.net/sense/app. App ID will be appended to this URL.

# Links available as template variables in notification messages
genericUrls:
- id: ptarmiganlabs_com
linkText: Ptarmigan Labs home page
Expand Down Expand Up @@ -365,7 +371,7 @@ Butler:
# These alerts will be sent irrespective of the alertEnableByCustomProperty.enable setting.
alertEnabledByEmailAddress:
customPropertyName: 'Butler_SuccessAlertSendToEmail'
rateLimit: 60 # Min seconds between emails for a given taskID. Defaults to 5 minutes.
rateLimit: 60 # Min seconds between emails for a given taskID/recipient combo. Defaults to 5 minutes.
headScriptLogLines: 15
tailScriptLogLines: 25
priority: high # high/normal/low
Expand Down Expand Up @@ -975,14 +981,14 @@ Butler:
qlikSenseCloud: # Settings for Qlik Sense Cloud integration
enable: false
event:
mqtt: # Which QS Cloud tenant should Butler SOS receive events from, in the form of MQTT messages?
mqtt: # Which QS Cloud tenant should Butler receive events from, in the form of MQTT messages?
tenant:
id: tenant.region.qlikcloud.com
tenantUrl: https://tenant.region.qlikcloud.com
authType: jwt # Authentication type used to connect to the tenant. Valid options are "jwt"
auth:
jwt:
token: <JWT token> # JWT token used to authenticate Butler SOS when connecting to the tenant
token: <JWT token> # JWT token used to authenticate Butler when connecting to the tenant
# Qlik Sense Cloud related links used in notification messages
qlikSenseUrls:
qmc: <URL to QMC in Qlik Sense Cloud>
Expand All @@ -998,10 +1004,9 @@ Butler:
tag: Butler - Send Teams alert if app reload fails
basicContentOnly: false
webhookURL: <URL to MS Teams webhook>

messageType: formatted # formatted / basic
basicMsgTemplate: 'Qlik Sense Cloud app reload failed: "{{appName}}"' # Only needed if message type = basic
rateLimit: 15 # Min seconds between emails for a given taskID. Defaults to 5 minutes.
rateLimit: 15 # Min seconds between emails for a given appId. Defaults to 5 minutes.
headScriptLogLines: 15
tailScriptLogLines: 15
templateFile: /path/to/teams_templates/failed-reload-qscloud-workflow.handlebars
Expand All @@ -1018,7 +1023,7 @@ Butler:
channel: sense-task-failure # Slack channel to which task failure notifications are sent
messageType: formatted # formatted / basic. Formatted means that template file below will be used to create the message.
basicMsgTemplate: 'Qlik Sense Cloud app reload failed: "{{appName}}"' # Only needed if message type = basic
rateLimit: 60 # Min seconds between emails for a given taskID. Defaults to 5 minutes.
rateLimit: 60 # Min seconds between emails for a given appId. Defaults to 5 minutes.
headScriptLogLines: 10
tailScriptLogLines: 20
templateFile: /path/to/slack_templates/failed-reload-qscloud.handlebars
Expand All @@ -1044,7 +1049,7 @@ Butler:
excludeOwner:
user:
# - email: daniel@somecompany.com
rateLimit: 60 # Min seconds between emails for a given taskID. Defaults to 5 minutes.
rateLimit: 60 # Min seconds between emails for a given appId/recipient combo. Defaults to 5 minutes.
headScriptLogLines: 15
tailScriptLogLines: 25
priority: high # high/normal/low
Expand Down Expand Up @@ -1076,7 +1081,7 @@ Butler:
- name: X-Qlik-User # Header used to identify what user connection to QRS is made as
value: UserDirectory=Internal;UserId=sa_repository # What user connection to QRS is made as
rejectUnauthorized: false # Set to false to ignore warnings/errors caused by Qlik Sense's self-signed certificates.
# Set to true if the Qlik Sense root CA is available on the computer where Butler SOS is running.
# Set to true if the Qlik Sense root CA is available on the computer where Butler is running.

configQRS:
authentication: certificates
Expand All @@ -1088,7 +1093,7 @@ Butler:
- name: X-Qlik-User # Header used to identify what user connection to QRS is made as
value: UserDirectory=Internal;UserId=sa_repository # What user connection to QRS is made as
rejectUnauthorized: false # Set to false to ignore warnings/errors caused by Qlik Sense's self-signed certificates.
# Set to true if the Qlik Sense root CA is available on the computer where Butler SOS is running.
# Set to true if the Qlik Sense root CA is available on the computer where Butler is running.

configDirectories:
qvdPath: <Path to folder under which QVDs are stored>
32 changes: 27 additions & 5 deletions src/lib/assert/config-file-schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,17 +347,39 @@ export const confifgFileSchema = {
storeOnDisk: {
type: 'object',
properties: {
reloadTaskFailure: {
clientManaged: {
type: 'object',
properties: {
enable: { type: 'boolean' },
logDirectory: { type: 'string' },
reloadTaskFailure: {
type: 'object',
properties: {
enable: { type: 'boolean' },
logDirectory: { type: 'string' },
},
required: ['enable', 'logDirectory'],
additionalProperties: false,
},
},
required: ['enable', 'logDirectory'],
required: ['reloadTaskFailure'],
additionalProperties: false,
},
qsCloud: {
type: 'object',
properties: {
appReloadFailure: {
type: 'object',
properties: {
enable: { type: 'boolean' },
logDirectory: { type: 'string' },
},
required: ['enable', 'logDirectory'],
additionalProperties: false,
},
},
required: ['appReloadFailure'],
},
},
required: ['reloadTaskFailure'],
required: ['clientManaged', 'qsCloud'],
additionalProperties: false,
},
},
Expand Down
50 changes: 31 additions & 19 deletions src/lib/qscloud/api/appreloadinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import globals from '../../../globals.js';
// Parameters:
// - appId: Qlik Sense Cloud app ID
// - reloadId: Qlik Sense Cloud reload ID
export async function getQlikSenseCloudAppReloadScriptLog(appId, reloadId, headLineCount, tailLineCount) {
export async function getQlikSenseCloudAppReloadScriptLog(appId, reloadId) {
try {
// Set up Qlik Sense Cloud API configuration
const axiosConfig = {
Expand All @@ -26,36 +26,48 @@ export async function getQlikSenseCloudAppReloadScriptLog(appId, reloadId, headL
// Get number of lines in scriptLogFull
const scriptLogLineCount = scriptLogFull.length;

let scriptLogHead = '';
let scriptLogTail = '';

if (headLineCount > 0) {
scriptLogHead = scriptLogFull.slice(0, headLineCount).join('\r\n');
}

if (tailLineCount > 0) {
scriptLogTail = scriptLogFull.slice(Math.max(scriptLogFull.length - tailLineCount, 0)).join('\r\n');
}

globals.logger.debug(`QLIK SENSE CLOUD GET SCRIPT LOG: Script log head:\n${scriptLogHead}`);
globals.logger.debug(`QLIK SENSE CLOUD GET SCRIPT LOG: Script log tails:\n${scriptLogTail}`);

globals.logger.verbose('QLIK SENSE CLOUD GET SCRIPT LOG: Done getting script log');

return {
scriptLogFull,
scriptLogSize: scriptLogLineCount,
scriptLogHead,
scriptLogHeadCount: headLineCount,
scriptLogTail,
scriptLogTailCount: tailLineCount,
};
} catch (err) {
globals.logger.error(`QLIK SENSE CLOUD GET SCRIPT LOG: ${err}`);
return false;
}
}

// Function to get script log head lines
// Parameters:
// - scriptLogFull: Full script log as array
// - headLineCount: Number of lines to get from head
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}`);

return scriptLogHead;
} else {
return '';
}
}

// Function to get script log tail lines
// Parameters:
// - scriptLogFull: Full script log as array
// - tailLineCount: Number of lines to get from tail
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}`);

return scriptLogTail;
} else {
return '';
}
}

// Function to get general info/status/result for a specific Qlik Sense Cloud reload
// Parameters:
// - reloadId: Qlik Sense Cloud reload ID
Expand Down
Loading

0 comments on commit e299ae6

Please sign in to comment.