Skip to content

Script Development / Connector Objects with DFF.CONN / TrueWatch

The TrueWatch Connector operation object mainly provides DataWay objects for data writing and a wrapper for the OpenAPI.

The API Key of this Connector requires the Administrator role

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

Therefore, you need to assign the Administrator role to the API Key.

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

Parameter Type Required / Default Description
connector_id str Required Connector ID
timeout int/float 10 Default HTTP request timeout for the current operation object, in seconds

Please refer to the OpenAPI documentation:

.dataway

The dataway property is the DataWay operation object for the current TrueWatch, and is used in the same way as a directly created DataWay Connector operation object.

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

Please refer to the full content:

.is_api_key_valid / .is_api_key_match

The is_api_key_valid property returns whether the API Key of the current Connector is valid; is_api_key_match is a compatibility alias for the old name:

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

.workspace

The workspace property returns the current workspace information:

Example
1
2
import json
print(json.dumps(truewatch.workspace, indent=2))
Example output
 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 property returns the current workspace UUID:

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

.workspace_token

The workspace_token property returns the current workspace Token:

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

.workspace_language

The workspace_language property returns the current workspace language:

Example
1
print(truewatch.workspace_language)
Example output
1
en

.do_get(...)

Used to make GET requests to the TrueWatch OpenAPI. The parameters are as follows:

Parameter Type Required / Default Description
path str Required OpenAPI path
query dict None URL query parameters
timeout int/float None Timeout for this request; if omitted, the operation object's default is used
Example
1
2
3
4
import json

result = truewatch.do_get('/api/v1/workspace/get')
print(json.dumps(result, indent=2))
Example output
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
{
  "content": {
    "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>": "..."
  }
}

This method returns the full response object of OpenAPI and does not automatically extract content. It raises an exception when the HTTP status code is greater than or equal to 400.

.do_post(...)

Used to make POST requests to the TrueWatch OpenAPI. The parameters are as follows:

Parameter Type Required / Default Description
path str Required OpenAPI path
query dict None URL query parameters
body dict None JSON request body
timeout int/float None Timeout for this request; if omitted, the operation object's default is used
Example
1
2
3
4
body = {
    'name': 'new name'
}
result = truewatch.do_post('/api/v1/workspace/modify', body=body)

This method returns the full response object of OpenAPI. It raises an exception when the HTTP status code is greater than or equal to 400.

Nodes

The TrueWatch system is built on a multi-node distributed architecture. When creating a Connector, you must precisely specify the target node to ensure that the functionality is properly invoked.

For compatibility with fully offline usage scenarios, DataFlux Func uses a versioned node list pinning mechanism: every time a version is released, it also saves the latest TrueWatch node list at that time, ensuring stable operation in offline environments.

Due to the above mechanism, if TrueWatch subsequently adds new nodes, the node list in a DataFlux Func version may not be updated in time. Users are advised to pay attention to version update information. To use the latest node features, you can obtain full support by upgrading to the latest DataFlux Func version.


If the above situation occurs, you can complete the new node configuration in the following ways:

  1. Information query: Visit the specified address to obtain the complete configuration parameters for the newly added TrueWatch node;
  2. Manual deployment: Select the "Private Deployment" mode and manually fill the queried node information into the corresponding fields of the system to complete the configuration.

Before operation, confirm that the parameters are accurate and compatible with the current environment to ensure the deployment works properly.

The currently available node list is as follows:

Node Name Address
Fetching the latest node list...