百度智能云

All Product Document

          Time-Spatial Database

          URL Generate the Pre-Signed URL of Querying Data Points

          Pre-signed URLs can be used to query data points on front end pages. Usage: The frontend requests the server to generate a pre-signed URL and return it to the frontend, which uses the URL to initiate ajax requests to query data points.

          Basic Process

          1. Create a TsdbClient.
          2. Run the generatePresignedUrl () method or generatePresignedUrlWithSql () method, you need to provide the query list or SQL, URL timeout, timestamp, etc. built according to requirements.

          Generate the pre-signed URL of the query data points:

          // build the queryList to query
          var queryList = [
              {
          	    "metric": "cpu_idle3",
          	    "fields": [
          	        "field1",
          	        "field2"
          	    ],
          	    "tags": [
          	        "rack",
          	        "host"
          	    ],
          	    "filters": {
          	        "start": "5 hour ago",
          	        "fields": [
          	            {
          	                "field": "field1",
          	                "value": ">= 10"
          	            },
          	            {
          	                "field": "field2",
          	                "value": "<= 10"
          	            }
          	        ],
          	        "tags": {
          	            "rack": [
          	                "rack1"
          	            ],
          	            "host": [
          	                "server1"
          	            ]
          	        },
          	        
          	    },
          	    "groupBy": [
          	        {
          	            "name": "Tag",
          	            "tags": [
          	                "rack",
          	                "host"
          	            ]
          	        }
          	    ],
          	    "limit": 1000
          	}
           ];
          
          var url = client.generatePresignedUrl(queryList, 0, 1800, null, {})
          console.log(url)

          The running result is as follows:

          //  similar results return from the termination
          http://testdb.tsdb.iot.bj.baidubce.com/v1/....

          Data points can be viewed in the browser

          Previous
          Query Operation
          Next
          Gzip Compression Instruction of Writing Data Points