Script Development / DataKit, DataWay
The operation objects of the DataKit and DataWay connectors mainly provide data writing methods.
DFF.CONN(...)
parameters are as follows:
Parameter | Type | Required / Default Value | Description |
---|---|---|---|
connector_id |
str | Required | Connector ID |
source |
str | None |
Specifies Source Note: Do not fill in "mysql" etc., to avoid conflicts with other collectors |
Parameter | Type | Required / Default Value | Description |
---|---|---|---|
connector_id |
str | Required | Connector ID |
token |
str | None |
Specifies Token |
- For general data reporting, please use
.write_by_category(...)
and.write_by_category_many(...)
methods. - For executing general DQL statements, please use the
.query(...)
method. - To directly send a GET request, use the
.get(...)
method. - To directly send a POST request, use the
.post_json(...)
method. - To directly send line protocol data, use the
.post_line_protocol(...)
method.
This connector is essentially an encapsulation of HTTP requests
The vast majority of interfaces between DataKit and DataWay are completely identical.
Due to frequent changes in the interfaces of DataKit and DataWay, this connector does not fully encapsulate all the interfaces one-to-one.
Since different versions of DataKit and DataWay may have different requirements or constraints for data reporting, please use this connector based on reading the relevant documentation.
Detailed documentation can be found at:
.write_by_category(...)
Write specific types of data to DataKit or DataWay. Parameters are as follows:
Parameter | Type | Required / Default Value | Description |
---|---|---|---|
category |
str | Required | Data type, see: Guance Documentation / DataKit API: TrueWatch Documentation / DataKit API |
measurement |
str | Required | Measurement name |
tags |
dict | Required | Tags. Both key names and values must be strings |
fields |
dict | Required | Metrics. Key names must be strings, values can be strings/integers/floating-point numbers/booleans |
timestamp |
int/long/float | {Current Time} | Timestamp, supports seconds/milliseconds/microseconds/nanoseconds |
headers |
dict | None |
Request Header parameters |
The parameter
headers
was added in version 3.3.0
Example | |
---|---|
1 2 3 |
|
.write_by_category_many(...)
Batch version of write_by_category(...)
. Parameters are as follows:
Parameter | Type | Required / Default Value | Description |
---|---|---|---|
category |
str | Required | Data type, see: Guance Documentation / DataKit API: TrueWatch Documentation / DataKit API |
data |
list | Required | List of data points |
data[#].measurement |
str | Required | Measurement name |
data[#].tags |
dict | Required | Tags. Both key names and values must be strings |
data[#].fields |
dict | Required | Metrics. Key names must be strings, values can be strings/integers/floating-point numbers/booleans |
data[#].timestamp |
int/long/float | {Current Time} | Timestamp, supports seconds/milliseconds/microseconds/nanoseconds |
headers |
dict | None |
Request Header parameters |
The parameter
headers
was added in version 3.3.0
Example | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
.write_metric(...)
/ .write_point(...)
Old method, equivalent to
.write_by_category(category='metric', ...)
.
Example | |
---|---|
1 |
|
.write_metrics(...)
/ .write_metric_many(...)
/ .write_points(...)
Old method, equivalent to
.write_by_category_many(category='metric', ...)
.
Example | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
.write_logging(...)
/ .write_logging_many(...)
Old method, equivalent to
.write_by_category_many(category='logging', ...)
.
.query(...)
This method supports the parameters from the DataKit API DQL query interface
Detailed documentation can be found at:
Execute DQL statements via DataKit or DataWay. Parameters are as follows:
Parameter | Type | Required / Default Value | Description |
---|---|---|---|
dql |
str | Required | DQL statement |
dict_output |
bool | False |
Whether to automatically convert data to dict . |
raw |
bool | False |
Whether to return the raw response. If enabled, the dict_output parameter becomes invalid. |
all_series |
bool | False |
Whether to automatically paginate through slimit and soffset to retrieve all time series. |
{DataKit, DataWay native parameters} |
- | - | Passed through to queries[0].{DataKit, DataWay native parameters} |
Example | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
Output Example | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
|
Example | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
Output Example | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
.get(...)
This method is a general processing method
Specific parameter formats and content should refer to:
Send a GET request to DataKit or DataWay. Parameters are as follows:
Parameter | Type | Required / Default Value | Description |
---|---|---|---|
path |
str | Required | Request path |
query |
dict | None |
Request URL parameters |
headers |
dict | None |
Request Header parameters |
.post_json(...)
This method is a general processing method
Specific parameter formats and content should refer to:
Send a POST request with JSON format to DataKit or DataWay. Parameters are as follows:
Parameter | Type | Required / Default Value | Description |
---|---|---|---|
path |
str | Required | Request path |
json_obj |
dict/list | Required | JSON object to be sent |
query |
dict | None |
Request URL parameters |
headers |
dict | None |
Request Header parameters |
Parameter
path
was adjusted to the first parameter in version 1.6.8
.post_line_protocol(...)
This method is a general processing method
Specific parameter formats and content should refer to:
Send a POST request with line protocol format to DataKit or DataWay. Parameters are as follows:
Parameter | Type | Required / Default Value | Description |
---|---|---|---|
path |
str | Required | Request path |
points |
list | Required | List of data points in data point format |
points[#].measurement |
str | Required | Measurement name |
points[#].tags |
dict | Required | Tags. Both key names and values must be strings |
points[#].fields |
dict | Required | Metrics. Key names must be strings, values can be strings/integers/floats/booleans |
points[#].timestamp |
int/long/float | {Current Time} | Timestamp, supports seconds/milliseconds/microseconds/nanoseconds |
query |
dict | None |
Request URL parameters |
headers |
dict | None |
Request Header parameters |
Parameter
path
was adjusted to the first parameter in version 1.6.8