-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(new-relic): Allow per-reload-task control of to which New Relic …
…account failed/aborted reload alerts are sent Implements #475
- Loading branch information
Göran Sander
committed
Sep 29, 2022
1 parent
eb1de8c
commit aa81ceb
Showing
3 changed files
with
624 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,282 @@ | ||
const QrsInteract = require('qrs-interact'); | ||
|
||
/** | ||
* Verify settings in the config file | ||
*/ | ||
const configFileNewRelicAssert = async (config, configQRS, logger) => { | ||
// Set up shared Sense repository service configuration | ||
const cfg = { | ||
hostname: config.get('Butler.configQRS.host'), | ||
portNumber: 4242, | ||
certificates: { | ||
certFile: configQRS.certPaths.certPath, | ||
keyFile: configQRS.certPaths.keyPath, | ||
}, | ||
}; | ||
|
||
cfg.headers = { | ||
'X-Qlik-User': 'UserDirectory=Internal; UserId=sa_repository', | ||
}; | ||
|
||
const qrsInstance = new QrsInteract(cfg); | ||
|
||
// ------------------------------------------ | ||
// The custom property specified by | ||
// Butler.incidentToo.newRelic.reloadTaskFailure.destination.event.sendToAccount.byCustomProperty.customPropertyName | ||
// should only include values present in the Butler.thirdPartyToolsCredentials.newRelic array | ||
|
||
// Only test if the feature in question is enabled in the config file | ||
if ( | ||
config.has('Butler.incidentTool.newRelic.reloadTaskFailure.destination.event.sendToAccount.byCustomProperty.enable') && | ||
config.get('Butler.incidentTool.newRelic.reloadTaskFailure.destination.event.sendToAccount.byCustomProperty.enable') && | ||
config.has('Butler.incidentTool.newRelic.reloadTaskFailure.destination.event.sendToAccount.byCustomProperty.customPropertyName') | ||
) { | ||
// Get custom property values | ||
try { | ||
logger.debug( | ||
`ASSERT CONFIG NEW RELIC 1: Custom property name: ${config.get( | ||
'Butler.incidentTool.newRelic.reloadTaskFailure.destination.event.sendToAccount.byCustomProperty.customPropertyName' | ||
)}` | ||
); | ||
logger.debug( | ||
`ASSERT CONFIG NEW RELIC 1: custompropertydefinition/full?filter=name eq '${config.get( | ||
'Butler.incidentTool.newRelic.reloadTaskFailure.destination.event.sendToAccount.byCustomProperty.customPropertyName' | ||
)}` | ||
); | ||
qrsInstance | ||
.Get( | ||
`custompropertydefinition/full?filter=name eq '${config.get( | ||
'Butler.incidentTool.newRelic.reloadTaskFailure.destination.event.sendToAccount.byCustomProperty.customPropertyName' | ||
)}'` | ||
) | ||
.then((result1) => { | ||
// The choice values of the custom property should match the values in Butler.thirdPartyToolsCredentials.newRelic | ||
|
||
// Test each custom property choice value for existence in Butler config file | ||
const availableNewRelicAccounts = config.get('Butler.thirdPartyToolsCredentials.newRelic'); | ||
|
||
// eslint-disable-next-line no-restricted-syntax | ||
for (const value of result1.body[0].choiceValues) { | ||
if (availableNewRelicAccounts.findIndex((account) => value === account.accountName) === -1) { | ||
logger.warn( | ||
`ASSERT CONFIG NEW RELIC: New Relic account name '${value}' of custom property '${config.get( | ||
'Butler.incidentTool.newRelic.reloadTaskFailure.destination.event.sendToAccount.byCustomProperty.customPropertyName' | ||
)}' not found in Butler's config file` | ||
); | ||
} | ||
} | ||
}); | ||
} catch (err) { | ||
logger.error(`SCRIPTLOG: ${err}`); | ||
} | ||
} else { | ||
// eslint-disable-next-line no-lonely-if | ||
if ( | ||
config.has('Butler.incidentTool.newRelic.reloadTaskFailure.destination.event.sendToAccount.byCustomProperty.enable') && | ||
config.get('Butler.incidentTool.newRelic.reloadTaskFailure.destination.event.sendToAccount.byCustomProperty.enable') && | ||
!config.has( | ||
'Butler.incidentTool.newRelic.reloadTaskFailure.destination.event.sendToAccount.byCustomProperty.customPropertyName' | ||
) | ||
) { | ||
logger.error( | ||
`ASSERT CONFIG NEW RELIC: Missing config file entry "Butler.incidentTool.newRelic.reloadTaskFailure.destination.event.sendToAccount.byCustomProperty.customPropertyName"` | ||
); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
// ------------------------------------------ | ||
// The custom property specified by | ||
// Butler.incidentToo.newRelic.reloadTaskFailure.destination.log.sendToAccount.byCustomProperty.customPropertyName | ||
// should only include values present in the Butler.thirdPartyToolsCredentials.newRelic array | ||
|
||
// Only test if the feature in question is enabled in the config file | ||
if ( | ||
config.has('Butler.incidentTool.newRelic.reloadTaskFailure.destination.log.sendToAccount.byCustomProperty.enable') && | ||
config.get('Butler.incidentTool.newRelic.reloadTaskFailure.destination.log.sendToAccount.byCustomProperty.enable') && | ||
config.has('Butler.incidentTool.newRelic.reloadTaskFailure.destination.log.sendToAccount.byCustomProperty.customPropertyName') | ||
) { | ||
// Get custom property values | ||
try { | ||
logger.debug( | ||
`ASSERT CONFIG NEW RELIC 1: Custom property name: ${config.get( | ||
'Butler.incidentTool.newRelic.reloadTaskFailure.destination.log.sendToAccount.byCustomProperty.customPropertyName' | ||
)}` | ||
); | ||
logger.debug( | ||
`ASSERT CONFIG NEW RELIC 1: custompropertydefinition/full?filter=name eq '${config.get( | ||
'Butler.incidentTool.newRelic.reloadTaskFailure.destination.log.sendToAccount.byCustomProperty.customPropertyName' | ||
)}` | ||
); | ||
qrsInstance | ||
.Get( | ||
`custompropertydefinition/full?filter=name eq '${config.get( | ||
'Butler.incidentTool.newRelic.reloadTaskFailure.destination.log.sendToAccount.byCustomProperty.customPropertyName' | ||
)}'` | ||
) | ||
.then((result1) => { | ||
// The choice values of the custom property should match the values in Butler.thirdPartyToolsCredentials.newRelic | ||
|
||
// Test each custom property choice value for existence in Butler config file | ||
const availableNewRelicAccounts = config.get('Butler.thirdPartyToolsCredentials.newRelic'); | ||
|
||
// eslint-disable-next-line no-restricted-syntax | ||
for (const value of result1.body[0].choiceValues) { | ||
if (availableNewRelicAccounts.findIndex((account) => value === account.accountName) === -1) { | ||
logger.warn( | ||
`ASSERT CONFIG NEW RELIC: New Relic account name '${value}' of custom property '${config.get( | ||
'Butler.incidentTool.newRelic.reloadTaskFailure.destination.log.sendToAccount.byCustomProperty.customPropertyName' | ||
)}' not found in Butler's config file` | ||
); | ||
} | ||
} | ||
}); | ||
} catch (err) { | ||
logger.error(`SCRIPTLOG: ${err}`); | ||
} | ||
} else { | ||
// eslint-disable-next-line no-lonely-if | ||
if ( | ||
config.has('Butler.incidentTool.newRelic.reloadTaskFailure.destination.log.sendToAccount.byCustomProperty.enable') && | ||
config.get('Butler.incidentTool.newRelic.reloadTaskFailure.destination.log.sendToAccount.byCustomProperty.enable') && | ||
!config.has('Butler.incidentTool.newRelic.reloadTaskFailure.destination.log.sendToAccount.byCustomProperty.customPropertyName') | ||
) { | ||
logger.error( | ||
`ASSERT CONFIG NEW RELIC: Missing config file entry "Butler.incidentTool.newRelic.reloadTaskFailure.destination.log.sendToAccount.byCustomProperty.customPropertyName"` | ||
); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
// ------------------------------------------ | ||
// The custom property specified by | ||
// Butler.incidentToo.newRelic.reloadTaskAborted.destination.event.sendToAccount.byCustomProperty.customPropertyName | ||
// should only include values present in the Butler.thirdPartyToolsCredentials.newRelic array | ||
|
||
// Only test if the feature in question is enabled in the config file | ||
if ( | ||
config.has('Butler.incidentTool.newRelic.reloadTaskAborted.destination.event.sendToAccount.byCustomProperty.enable') && | ||
config.get('Butler.incidentTool.newRelic.reloadTaskAborted.destination.event.sendToAccount.byCustomProperty.enable') && | ||
config.has('Butler.incidentTool.newRelic.reloadTaskAborted.destination.event.sendToAccount.byCustomProperty.customPropertyName') | ||
) { | ||
// Get custom property values | ||
try { | ||
logger.debug( | ||
`ASSERT CONFIG NEW RELIC 1: Custom property name: ${config.get( | ||
'Butler.incidentTool.newRelic.reloadTaskAborted.destination.event.sendToAccount.byCustomProperty.customPropertyName' | ||
)}` | ||
); | ||
logger.debug( | ||
`ASSERT CONFIG NEW RELIC 1: custompropertydefinition/full?filter=name eq '${config.get( | ||
'Butler.incidentTool.newRelic.reloadTaskAborted.destination.event.sendToAccount.byCustomProperty.customPropertyName' | ||
)}` | ||
); | ||
qrsInstance | ||
.Get( | ||
`custompropertydefinition/full?filter=name eq '${config.get( | ||
'Butler.incidentTool.newRelic.reloadTaskAborted.destination.event.sendToAccount.byCustomProperty.customPropertyName' | ||
)}'` | ||
) | ||
.then((result1) => { | ||
// The choice values of the custom property should match the values in Butler.thirdPartyToolsCredentials.newRelic | ||
|
||
// Test each custom property choice value for existence in Butler config file | ||
const availableNewRelicAccounts = config.get('Butler.thirdPartyToolsCredentials.newRelic'); | ||
|
||
// eslint-disable-next-line no-restricted-syntax | ||
for (const value of result1.body[0].choiceValues) { | ||
if (availableNewRelicAccounts.findIndex((account) => value === account.accountName) === -1) { | ||
logger.warn( | ||
`ASSERT CONFIG NEW RELIC: New Relic account name '${value}' of custom property '${config.get( | ||
'Butler.incidentTool.newRelic.reloadTaskAborted.destination.event.sendToAccount.byCustomProperty.customPropertyName' | ||
)}' not found in Butler's config file` | ||
); | ||
} | ||
} | ||
}); | ||
} catch (err) { | ||
logger.error(`SCRIPTLOG: ${err}`); | ||
} | ||
} else { | ||
// eslint-disable-next-line no-lonely-if | ||
if ( | ||
config.has('Butler.incidentTool.newRelic.reloadTaskAborted.destination.event.sendToAccount.byCustomProperty.enable') && | ||
config.get('Butler.incidentTool.newRelic.reloadTaskAborted.destination.event.sendToAccount.byCustomProperty.enable') && | ||
!config.has( | ||
'Butler.incidentTool.newRelic.reloadTaskAborted.destination.event.sendToAccount.byCustomProperty.customPropertyName' | ||
) | ||
) { | ||
logger.error( | ||
`ASSERT CONFIG NEW RELIC: Missing config file entry "Butler.incidentTool.newRelic.reloadTaskAborted.destination.event.sendToAccount.byCustomProperty.customPropertyName"` | ||
); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
// ------------------------------------------ | ||
// The custom property specified by | ||
// Butler.incidentToo.newRelic.reloadTaskAborted.destination.log.sendToAccount.byCustomProperty.customPropertyName | ||
// should only include values present in the Butler.thirdPartyToolsCredentials.newRelic array | ||
|
||
// Only test if the feature in question is enabled in the config file | ||
if ( | ||
config.has('Butler.incidentTool.newRelic.reloadTaskAborted.destination.log.sendToAccount.byCustomProperty.enable') && | ||
config.get('Butler.incidentTool.newRelic.reloadTaskAborted.destination.log.sendToAccount.byCustomProperty.enable') && | ||
config.has('Butler.incidentTool.newRelic.reloadTaskAborted.destination.log.sendToAccount.byCustomProperty.customPropertyName') | ||
) { | ||
// Get custom property values | ||
try { | ||
logger.debug( | ||
`ASSERT CONFIG NEW RELIC 1: Custom property name: ${config.get( | ||
'Butler.incidentTool.newRelic.reloadTaskAborted.destination.log.sendToAccount.byCustomProperty.customPropertyName' | ||
)}` | ||
); | ||
logger.debug( | ||
`ASSERT CONFIG NEW RELIC 1: custompropertydefinition/full?filter=name eq '${config.get( | ||
'Butler.incidentTool.newRelic.reloadTaskAborted.destination.log.sendToAccount.byCustomProperty.customPropertyName' | ||
)}` | ||
); | ||
qrsInstance | ||
.Get( | ||
`custompropertydefinition/full?filter=name eq '${config.get( | ||
'Butler.incidentTool.newRelic.reloadTaskAborted.destination.log.sendToAccount.byCustomProperty.customPropertyName' | ||
)}'` | ||
) | ||
.then((result1) => { | ||
// The choice values of the custom property should match the values in Butler.thirdPartyToolsCredentials.newRelic | ||
|
||
// Test each custom property choice value for existence in Butler config file | ||
const availableNewRelicAccounts = config.get('Butler.thirdPartyToolsCredentials.newRelic'); | ||
|
||
// eslint-disable-next-line no-restricted-syntax | ||
for (const value of result1.body[0].choiceValues) { | ||
if (availableNewRelicAccounts.findIndex((account) => value === account.accountName) === -1) { | ||
logger.warn( | ||
`ASSERT CONFIG NEW RELIC: New Relic account name '${value}' of custom property '${config.get( | ||
'Butler.incidentTool.newRelic.reloadTaskAborted.destination.log.sendToAccount.byCustomProperty.customPropertyName' | ||
)}' not found in Butler's config file` | ||
); | ||
} | ||
} | ||
}); | ||
} catch (err) { | ||
logger.error(`SCRIPTLOG: ${err}`); | ||
} | ||
} else { | ||
// eslint-disable-next-line no-lonely-if | ||
if ( | ||
config.has('Butler.incidentTool.newRelic.reloadTaskAborted.destination.log.sendToAccount.byCustomProperty.enable') && | ||
config.get('Butler.incidentTool.newRelic.reloadTaskAborted.destination.log.sendToAccount.byCustomProperty.enable') && | ||
!config.has('Butler.incidentTool.newRelic.reloadTaskAborted.destination.log.sendToAccount.byCustomProperty.customPropertyName') | ||
) { | ||
logger.error( | ||
`ASSERT CONFIG NEW RELIC: Missing config file entry "Butler.incidentTool.newRelic.reloadTaskAborted.destination.log.sendToAccount.byCustomProperty.customPropertyName"` | ||
); | ||
process.exit(1); | ||
} | ||
} | ||
}; | ||
|
||
module.exports = { | ||
configFileNewRelicAssert, | ||
}; |
Oops, something went wrong.