Added influx checkBucket
This commit is contained in:
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
|
// Specify exports
|
||||||
module.exports = {
|
module.exports = {
|
||||||
checkHealth,
|
checkHealth,
|
||||||
|
checkBucket,
|
||||||
};
|
};
|
@ -26,7 +26,11 @@ if(errorMsg){
|
|||||||
const influxDb = new InfluxDB({url: env.INFLUX_URL, token: env.INFLUX_TOKEN});
|
const influxDb = new InfluxDB({url: env.INFLUX_URL, token: env.INFLUX_TOKEN});
|
||||||
|
|
||||||
await InfluxChecks.checkHealth(influxDb)
|
await InfluxChecks.checkHealth(influxDb)
|
||||||
.catch(exit(1))
|
.then((res) => {return InfluxChecks.checkBucket(influxDb, {
|
||||||
.then((res) => {});
|
org: env.INFLUX_ORG,
|
||||||
|
name: env.INFLUX_BUCKET
|
||||||
|
})})
|
||||||
|
.then((res) => {})
|
||||||
|
.catch(exit(1));
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user