Skip to content

Script Development / TrueWatch

The TrueWatch connector operation object mainly provides the DataWay object for data writing and the encapsulation of OpenAPI.

Parameters for DFF.CONN(...) are as follows:

Parameter Type Required / Default Value 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 TrueWatch. Its usage is the same as the directly created DataWay connector operation object.

Example
1
status_code, result = truewatch.dataway.write_by_category(category='metric', measurement='HOST Monitoring', tags={'host': 'web-01'}, fields={'cpu': 10})

For complete content, 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(truewatch.is_api_key_valid)
Output Example
1
True

.workspace

The workspace property 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"      : "rp1",
  "language"    : "en",
  "timezone"    : "",
  "bossStation" : "US",
  "billingState": "normal",
  "versionType" : "pay",
  "token"       : "tkn_xxxxx",
  "cliToken"    : "wkcli_xxxxx",
  "<Other Fields Omitted>": "..."
}

.workspace_uuid

The workspace_uuid property returns the UUID of the current workspace:

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

.workspace_token

The workspace_token property returns the Token of the current workspace:

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

.workspace_language

The workspace_language property returns the language of the current workspace:

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

.do_get(...)

Used to initiate a GET request to the TrueWatch OpenAPI. The parameters are as follows:

Parameter Type Required / Default Value 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" : "US",
  "billingState": "normal",
  "versionType" : "pay",
  "token"       : "tkn_xxxxx",
  "cliToken"    : "wkcli_xxxxx",
  "<Other Fields Omitted>": "..."
}

.do_post(...)

Used to initiate a POST request to the TrueWatch OpenAPI. The parameters are as follows:

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