URL Generate the Pre-Signed URL of Querying Data Points
Last Updated:2020-07-20
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
- Create a TsdbClient.
- 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