Added influx checkBucket

f_influx-checks
Ruakij 3 years ago
parent fc5900b0ba
commit e1b2a7e016

@ -19,8 +19,24 @@ function checkHealth(influxDb){
});
}
function checkBucket(influxDb, options){
return new Promise((resolve, reject) => {
new Influx.BucketsAPI(influxDb).getBuckets(options)
.catch((err) => { // Weirdly the influx-Api returns 404 for searches of non-existing buckets
logger.fatal("Could not get bucket:");
logger.fatal(`Error [${err.code}]:`, err.message);
reject(err);
}).then((res) => { // But an empty list when the bucket exists, but token does not have permission to get details
logger.debug("Bucket found");
resolve(res);
// Now we know the bucket exists and we have some kind of permission.. but we still dont know if we are able to write to it..
});
});
}
// Specify exports
module.exports = {
checkHealth,
checkBucket,
};

@ -26,7 +26,11 @@ if(errorMsg){
const influxDb = new InfluxDB({url: env.INFLUX_URL, token: env.INFLUX_TOKEN});
await InfluxChecks.checkHealth(influxDb)
.catch(exit(1))
.then((res) => {});
.then((res) => {return InfluxChecks.checkBucket(influxDb, {
org: env.INFLUX_ORG,
name: env.INFLUX_BUCKET
})})
.then((res) => {})
.catch(exit(1));
})();

Loading…
Cancel
Save