Skip to content

Script Development / TrueWatch

The TrueWatch Connector primarily provides a DataWay object for data writing and an encapsulation of the OpenAPI.

This Connector's API Key Requires the Administrator Role

Because this Connector automatically retrieves sensitive information such as workspace tokens for subsequent operations like data reporting.

Therefore, the API Key needs to be assigned the Administrator role.

DFF.CONN(...) parameters are as follows:

Parameter Type Required / Default Description
connector_id str Required Connector ID

OpenAPI documentation can be found at:

.dataway

The dataway attribute is the DataWay operation object corresponding to the current TrueWatch. Its usage is the same as the DataWay Connector operation object created directly.

Example
1
status_code, result = truewatch.dataway.write_by_category(category='metric', measurement='Service Monitoring', tags={'service': 'mysql'}, fields={'mem': 10})

For full content, please refer to:

.is_api_key_valid / .is_api_key_match

The is_api_key_valid / is_api_key_match attributes return whether the current Connector's API Key is valid:

Example
1
print(truewatch.is_api_key_valid)
Output Example
1
True

.workspace

The workspace attribute returns the current workspace information:

Example
1
2
import json
print(json.dumps(truewatch.workspace, indent=2))
Output Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
{
  "uuid"        : "wksp_xxxxx",
  "name"        : "xxxxx",
  "rpName"      : "rp2",
  "language"    : "en",
  "timezone"    : "",
  "bossStation" : "HK",
  "billingState": "normal",
  "versionType" : "pay",
  "token"       : "tkn_xxxxx",
  "cliToken"    : "wkcli_xxxxx",
  "<Other fields omitted>": "..."
}

.workspace_uuid

The workspace_uuid attribute returns the current workspace UUID:

Example
1
print(truewatch.workspace_uuid)
Output Example
1
wksp_xxxxx

.workspace_token

The workspace_token attribute returns the current workspace Token:

Example
1
print(truewatch.workspace_token)
Output Example
1
tkn_xxxxx

.workspace_language

The workspace_language attribute returns the current workspace language:

Example
1
print(truewatch.workspace_language)
Output Example
1
zh

.do_get(...)

Used to make a GET request to the TrueWatch OpenAPI. Parameters are as follows:

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

result = truewatch.do_get('/api/v1/workspace/get')
print(json.dumps(result, indent=2))
Output Example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
{
  "uuid"        : "wksp_xxxxx",
  "name"        : "xxxxx",
  "rpName"      : "rp1",
  "language"    : "en",
  "timezone"    : "",
  "bossStation" : "HK",
  "billingState": "normal",
  "versionType" : "pay",
  "token"       : "tkn_xxxxx",
  "cliToken"    : "wkcli_xxxxx",
  "<Other fields omitted>": "..."
}

.do_post(...)

Used to make a POST request to the TrueWatch OpenAPI. 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 = {
    'name': 'New Name'
}
result = truewatch.do_post('/api/v1/workspace/modify', body=body)

Nodes

The TrueWatch system adopts a multi-node distributed architecture. When creating a Connector, the target node must be precisely specified to ensure normal function invocation.

DataFlux Func employs a versioned node list solidification mechanism for complete compatibility with offline usage scenarios — the latest TrueWatch node list at the time of each release is saved synchronously, ensuring stable operation in offline environments.

Due to this mechanism, if TrueWatch adds new nodes subsequently, the DataFlux Func version's node list might not be updated in time. Users are advised to pay attention to version iteration information. To use the latest node features, upgrading to the latest DataFlux Func version is recommended to obtain full support.


If encountering the above situation, new nodes can be configured through the following methods:

  1. Information Query: Visit the specified address to obtain the complete configuration parameters for the new TrueWatch nodes;
  2. Manual Deployment: Select the "Private Deployment" mode and manually enter the queried node information into the corresponding system fields to complete the configuration.

It is recommended to verify parameter accuracy before operation to ensure compatibility with the current environment and guarantee deployment effectiveness.

The currently available node list is as follows:

Node Name Address
Fetching the latest node list...