Skip to content

Commit

Permalink
Merge pull request #800 from mountaindude/794
Browse files Browse the repository at this point in the history
fix: Add verbose logging showing which NR accounts are used
  • Loading branch information
mountaindude authored Sep 21, 2023
2 parents 05ce03f + 907b9ae commit 2dd6fa9
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ const getLoggingLevel = () => logTransports.find((transport) => transport.name =
// Are we running as standalone app or not?
logger.verbose(`Running as standalone app: ${isPkg}`);

// Verbose: Show what New Relic account names/API keys/account IDs have been defined (on command line or in config file)
logger.verbose(
`New Relic account names/API keys/account IDs (via command line or config file): ${JSON.stringify(
config.Butler.thirdPartyToolsCredentials.newRelic,
null,
2
)}`
);

// Verify correct structure of config file
configFileStructureAssert(config, logger);

Expand Down
6 changes: 6 additions & 0 deletions src/lib/incident_mgmt/new_relic.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ async function sendNewRelicEvent(incidentConfig, reloadParams, destNewRelicAccou
// Get array of all NR accounts defined in the config file
const nrAccounts = globals.config.Butler.thirdPartyToolsCredentials.newRelic;

// Verbose: Show what New Relic account names/API keys/account IDs have been defined
globals.logger.verbose(`NEWRELIC EVENT: Account names/API keys/account IDs: ${JSON.stringify(nrAccounts, null, 2)}`);

// Send to New Relic
// eslint-disable-next-line no-restricted-syntax
for (const accountName of destNewRelicAccounts) {
Expand Down Expand Up @@ -539,6 +542,9 @@ async function sendNewRelicLog(incidentConfig, reloadParams, destNewRelicAccount
// Get array of all NR accounts defined in the config file
const nrAccounts = globals.config.Butler.thirdPartyToolsCredentials.newRelic;

// Verbose: Show what New Relic account names/API keys/account IDs have been defined
globals.logger.verbose(`NEWRELIC LOG: Account names/API keys/account IDs: ${JSON.stringify(nrAccounts, null, 2)}`);

// Send to New Relic
// eslint-disable-next-line no-restricted-syntax
for (const accountName of destNewRelicAccounts) {
Expand Down
14 changes: 14 additions & 0 deletions src/lib/incident_mgmt/new_relic_service_monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,13 @@ async function sendServiceMonitorEvent(serviceStatusParams) {
// Remove duplicates
const destNewRelicAccounts = [...new Set(tmpDestNewRelicAccounts)];

// Verbose: What New Relic destination accounts will the information be sent to?
globals.logger.verbose(
`SERVICE MONITOR NEWRELIC: Sending service state event to New Relic for service "${
params.serviceName
}" to accounts: ${JSON.stringify(destNewRelicAccounts, null, 2)}`
);

sendNewRelicEvent(
serviceStateConfig,
{
Expand Down Expand Up @@ -311,6 +318,13 @@ async function sendServiceMonitorLog(serviceStatusParams) {
// Remove duplicates
const destNewRelicAccounts = [...new Set(tmpDestNewRelicAccounts)];

// Verbose: What New Relic destination accounts will the information be sent to?
globals.logger.verbose(
`SERVICE MONITOR NEWRELIC: Sending service state log to New Relic for service "${
params.serviceName
}" to accounts: ${JSON.stringify(destNewRelicAccounts, null, 2)}`
);

sendNewRelicLog(
serviceStateConfig,
{
Expand Down
4 changes: 4 additions & 0 deletions src/lib/post_to_new_relic.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,12 @@ async function postButlerUptimeToNewRelic(fields) {
const nrAccounts = globals.config.get('Butler.thirdPartyToolsCredentials.newRelic');
globals.logger.debug(`UPTIME NEW RELIC: Complete New Relic config=${JSON.stringify(nrAccounts)}`);

// Verbose: Show what New Relic account names/API keys/account IDs have been defined
globals.logger.verbose(`UPTIME NEW RELIC: Account names/API keys/account IDs: ${JSON.stringify(nrAccounts, null, 2)}`);

// Are there any NR destinations defined for uptime metrics?
const nrDestAccounts = globals.config.get('Butler.uptimeMonitor.storeNewRelic.destinationAccount');
globals.logger.verbose(`UPTIME NEW RELIC: Destination account names for uptime data: ${JSON.stringify(nrDestAccounts, null, 2)}`);

if (nrDestAccounts) {
// eslint-disable-next-line no-restricted-syntax
Expand Down
3 changes: 3 additions & 0 deletions src/routes/newrelic_event.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ async function handlerPostNewRelicEvent(request, reply) {
// Get New Relic accounts
const nrAccounts = globals.config.Butler.thirdPartyToolsCredentials.newRelic;

// Verbose: Show what New Relic account names/API keys/account IDs have been defined
globals.logger.verbose(`NEWRELIC EVENT: Account names/API keys/account IDs: ${JSON.stringify(nrAccounts, null, 2)}`);

// eslint-disable-next-line no-restricted-syntax
for (const accountName of globals.config.Butler.restServerEndpointsConfig.newRelic.postNewRelicEvent.destinationAccount) {
globals.logger.debug(`NEWRELIC EVENT: Current loop New Relic config=${JSON.stringify(accountName)}`);
Expand Down
3 changes: 3 additions & 0 deletions src/routes/newrelic_metric.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ async function handlerPostNewRelicMetric(request, reply) {
// Get New Relic accounts
const nrAccounts = globals.config.Butler.thirdPartyToolsCredentials.newRelic;

// Verbose: Show what New Relic account names/API keys/account IDs have been defined
globals.logger.verbose(`NEWRELIC METRIC: Account names/API keys/account IDs: ${JSON.stringify(nrAccounts, null, 2)}`);

// eslint-disable-next-line no-restricted-syntax
for (const accountName of globals.config.Butler.restServerEndpointsConfig.newRelic.postNewRelicMetric.destinationAccount) {
globals.logger.debug(`NEWRELIC METRIC: Current loop New Relic config=${JSON.stringify(accountName)}`);
Expand Down

0 comments on commit 2dd6fa9

Please sign in to comment.