百度智能云

All Product Document

          Time-Spatial Database

          Gzip Compression Instruction of Writing Data Points

          Basic Process

          1. Create a TsdbClient.
          2. 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
          Previous
          URL Generate the Pre-Signed URL of Querying Data Points
          Next
          Management Interface