Gzip Compression Instruction of Writing Data Points
Last Updated:2020-07-20
Basic Process
- Create a TsdbClient.
- If desired to run the writeDataPoints () method, you need to provide with the data points to be written.
Gzip compression is enabled by default for writing data points. If you do not need to use it, you can refer to the following code:
var useGzip = false;
// build the queryList to query
var datapoints = [
{
"metric": "cpu_idle",
"field": "test",
"tags": {
"host": "server1",
"rack": "rack1"
},
"timestamp": Math.round(newDate().getTime()/1000),
"value": 51
}
];
// get and print the query results
client.writeDatapoints(<datapoints>,Gzip)
.then(response => console.log(response.body)) // wrote successfully
.catch(error => console.error(error)); // failed to write and return the error type