2021-07-16 21:23:21 +00:00
|
|
|
/**
|
|
|
|
* Create a bucket with the InfluxDB 2.x API.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const https = require('https');
|
|
|
|
|
|
|
|
function createBucket() {
|
|
|
|
|
|
|
|
const options = {
|
|
|
|
host: 'localhost:8086',
|
|
|
|
path: "/api/v2",
|
|
|
|
headers: {
|
2021-08-23 16:05:07 +00:00
|
|
|
'Authorization': 'Token YOUR_API_TOKEN',
|
2021-07-16 21:23:21 +00:00
|
|
|
'Content-type': 'application/json'
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const request = https.get(options, (response) => {
|
|
|
|
let rawData = '';
|
|
|
|
response.on('data', () => {
|
|
|
|
response.on('data', (chunk) => { rawData += chunk; });
|
|
|
|
})
|
|
|
|
response.on('end', () => {
|
|
|
|
console.log(rawData);
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
request.end();
|
|
|
|
}
|