Skip to content

Script Development / Guance

观测云连接器操作对象主要提供用于数据写入的 DataWay 对象以及 OpenAPI 的封装。

DFF.CONN(...) 参数如下:

Parameter Type Required / Default Description
connector_id str Required Connector ID

For OpenAPI documentation, please refer to:

.dataway

The dataway property is the DataWay operation object corresponding to the current Guance instance. Its usage is the same as directly created DataWay connector objects.

Example
1
status_code, result = guance.dataway.write_by_category(category='metric', measurement='主机监控', tags={'host': 'web-01'}, fields={'cpu': 10})

For complete details, please refer to:

.is_api_key_valid / .is_api_key_match

The is_api_key_valid / is_api_key_match properties return whether the API Key of the current connector is valid:

Example
1
print(guance.is_api_key_valid)
Sample Output
1
True

.workspace

The workspace property returns information about the current workspace:

Example
1
2
import json
print(json.dumps(guance.workspace, indent=2))
Sample Output
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
{
  "uuid"        : "wksp_xxxxx",
  "name"        : "xxxxx",
  "rpName"      : "rp1",
  "language"    : "zh",
  "timezone"    : "",
  "bossStation" : "CN",
  "billingState": "normal",
  "versionType" : "pay",
  "token"       : "tkn_xxxxx",
  "cliToken"    : "wkcli_xxxxx",
  "<其他字段略>": "..."
}

.workspace_uuid

The workspace_uuid property returns the UUID of the current workspace:

Example
1
print(guance.workspace_uuid)
Sample Output
1
wksp_xxxxx

.workspace_token

The workspace_token property returns the token of the current workspace:

Example
1
print(guance.workspace_token)
Sample Output
1
tkn_xxxxx

.workspace_language

The workspace_language property returns the language setting of the current workspace:

Example
1
print(guance.workspace_language)
Sample Output
1
zh

.do_get(...)

Used to send GET requests to Guance OpenAPI. The parameters are as follows:

Parameter Type Required / Default Description
path str Required Path
query dict Parameters
Example
1
2
3
4
import json

result = guance.do_get('/api/v1/workspace/get')
print(json.dumps(result, indent=2))
Sample Output
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
{
  "uuid"        : "wksp_xxxxx",
  "name"        : "xxxxx",
  "rpName"      : "rp1",
  "language"    : "zh",
  "timezone"    : "",
  "bossStation" : "CN",
  "billingState": "normal",
  "versionType" : "pay",
  "token"       : "tkn_xxxxx",
  "cliToken"    : "wkcli_xxxxx",
  "<其他字段略>": "..."
}

.do_post(...)

Used to send POST requests to Guance OpenAPI. The parameters are as follows:

Parameter Type Required / Default Description
path str Required Path
query dict Parameters
body dict JSON Request Body
Example
1
2
3
4
body = {
    'desc': '新描述'
}
result = guance.do_post('/api/v1/workspace/modify', body=body)

Nodes

Guance has multiple nodes available for use. When creating a Guance connector, you need to specify the corresponding Guance node.

To ensure full offline support, each version of DataFlux Func includes a copy of the latest Guance node list at the time of release.

Therefore, there may be cases where newly added Guance nodes do not appear in DataFlux Func in a timely manner.


If you encounter such situations, you can check the configuration of new nodes on Guance from the following address and then select "Private Deployment" to manually enter the details.

The currently available node list is as follows:

Node Name Address
Loading latest node list...