Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #111 from Financial-Times/splunk-drain
Browse files Browse the repository at this point in the history
configure heroku to log to splunk
  • Loading branch information
wheresrhys committed May 26, 2015
2 parents 0d109b2 + 1585991 commit e53da25
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bin/next-build-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,14 @@ program
.command('configure [source] [target]')
.description('downloads environment variables from next-config-vars and uploads them to the current app')
.option('-o, --overrides <abc>', 'override these values', list)
.option('-n, --no-splunk', 'configure not to drain logs to splunk')
.action(function(source, target, options) {
configure({ source: source, target: target, overrides: options.overrides }).catch(exit);
configure({
source: source,
target: target,
overrides: options.overrides,
splunk: !options.noSplunk
}).catch(exit);
});

program
Expand Down
18 changes: 18 additions & 0 deletions tasks/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,23 @@ module.exports = function(opts) {
})
.then(function() {
console.log(target + " config vars are set");
}).then(function () {
if (opts.splunk) {
if (!process.env.SPLUNK_URL) {
throw 'Either set a SPLUNK_URL environment variable or run `nbt configure --no-splunk`';
}
console.log("Setting up logging to splunk");
return fetch('https://api.heroku.com/apps/' + target + '/log-drains', {
headers: authorizedPostHeaders,
method: 'post',
body: JSON.stringify({
url: process.env.SPLUNK_URL + target
})
})
.then(function () {
console.log(target + " logging to splunk");
});
}
});

};

0 comments on commit e53da25

Please sign in to comment.