Clarify the warning messages when it comes to authentication in (#2334)

This commit is contained in:
Markus Liljedahl 2019-02-21 15:39:30 +01:00 committed by Peter Hedenskog
parent 3fd700adb2
commit d3c8b2ded4
1 changed files with 8 additions and 1 deletions

View File

@ -77,6 +77,7 @@ module.exports = {
};
// If Grafana is behind auth, use it!
if (options.grafana.auth) {
log.debug('Using auth for Grafana');
postOptions.headers.Authorization = 'Bearer ' + options.grafana.auth;
}
log.verbose('Send annotation to Grafana: %j', postData);
@ -88,7 +89,13 @@ module.exports = {
const e = new Error(
`Got ${res.statusCode} from Grafana when sending annotation`
);
log.warn(e.message);
if (res.statusCode === 403) {
log.warn('Authentication required.', e.message)
} else if (res.statusCode === 401) {
log.warn('No valid authentication.', e.message)
} else {
log.warn(e.message);
}
reject(e);
} else {
res.setEncoding('utf8');