Modify¶
POST /api/v1/aggs_to_metric/{rule_uuid}/modify
Overview¶
Generate Metrics Rule Modification
Route Parameters¶
Parameter Name | Type | Required | Description |
---|---|---|---|
rule_uuid | string | Y | ID of the Aggregated Metric |
Body Request Parameters¶
Parameter Name | Type | Required | Description |
---|---|---|---|
extend | json | Y | Additional Information Allow Null: False |
jsonScript | json | Y | Rule Configuration Allow Null: False |
jsonScript.type | string | Y | Type Example: rumToMetric Allow Null: False Allow Empty String: False Optional Values: ['logToMetric', 'rumToMetric', 'apmToMetric', 'metricToMetric', 'securityToMetric', 'dialingToMetric'] |
jsonScript.query | json | Y | DQL Query Related Information Allow Null: False |
jsonScript.metricInfo | json | Y | Metrics Configuration Information Allow Null: False |
jsonScript.metricInfo.every | string | Y | Frequency Example: 5m Allow Empty String: False |
jsonScript.metricInfo.metric | string | Y | Measurement Name Example: cpu Allow Empty String: False |
jsonScript.metricInfo.metricField | string | Y | Metric Name Example: load5s Allow Empty String: False |
jsonScript.metricInfo.unit | string | Unit Example: load5s Allow Empty String: True |
|
jsonScript.metricInfo.desc | string | Description Example: xxx Allow Empty String: True |
Parameter Supplementary Notes¶
Data Description.
1. **jsonScript
Parameter Description
Parameter Name | Type | Required | Description |
---|---|---|---|
type | String | Required | Data Source Type, Enum Type |
query | Json | Required | Query Information |
metricInfo | Json | Required | Metrics Configuration Information |
2. Check Type jsonScript.type
Description
Key | Description |
---|---|
rumToMetric | RUM Generates Metrics |
apmToMetric | APM Generates Metrics |
logToMetric | Logging Generates Metrics |
metricToMetric | Metrics Generate Metrics |
securityToMetric | Security Check Generates Metrics |
3. Check Type jsonScript.metricInfo
Description
Parameter Name | Type | Required | Description |
---|---|---|---|
every | String | Required | Frequency, Options 1m, 5m, 15m, Units (minutes/m) |
metric | String | Required | Metrics Set Name |
metricField | String | Required | Metric Name |
unit | String | Unit | |
desc | String | Description |
3.1 Check Type jsonScript.metricInfo.unit
Unit Description
Unit Format: custom/["unit type","unit"], Example: custom/["time","ms"]
Custom Unit Format: custom/["custom","custom unit"], Example: custom/["custom","tt"]
Standard Unit Types, Refer to Unit Description
4. Check Type jsonScript.query
Description
Parameter Name | Type | Required | Description |
---|---|---|---|
q | String | Required | Query Statement |
qtype | String | Query Syntax Type, dql/promql | |
qmode | String | Query Type, Selector: selectorQuery , Manual: customQuery, This Field Affects Frontend Query Echo Style |
5. extend
Parameter Description
Parameter Name | Type | Required | Description |
---|---|---|---|
filters | Array[dict] | Filter Condition List for Non-Log Types | |
groupBy | Array[str] | Group Information | |
funcName | string | Required | Aggregation Function, Enum Values("count", "avg", "max", "sum", "min", "count_distinct", "p75", "p95", "p99") |
fieldKey | string | Required | Aggregation Field |
index | string | Index Name for Log Types | |
source | string | This Field Represents Different Meanings in Different Types: Log Type: Source source, Application Performance Type: Service service, User Access Type: Application app_id, Metric Type: Metrics Set, Security Check: Category category | |
filterString | string | Filter Condition for Log Types, Original Filter String, Example: 'host:hangzhou123 -service:coredns internal:true' |
Note:
All Fields in the extend
Field Are Used Only for Frontend Echo Display. The Actual Generated Metric Query Statement Follows the Query Information Configured in jsonScript.query
.
6. extend.filters
Main Structure Description
Parameter Name | Type | Required | Description |
---|---|---|---|
condition | string | Relationship with the Previous Filter Condition, Optional Values:and , or ; Default Value: and |
|
name | string | Field Name to Be Filtered | |
op | string | Operator, Optional Values: = , != , match , not match |
|
values | array | Value List | |
values[#] | string/int/boolean | Can Be String/Numeric/Boolean Type, When Comparing Data, Specific Elements Will Be Taken from values Based on the Characteristics of operation , For Example, When operation is = , Only values[0] Participates in the Operation |
6.1 extend.filters
Example:
[
{
"name": "A",
"condition": "and",
"op": "match",
"values": ["error"]
},
{
"name": "tagC",
"condition": "and",
"op": "=",
"values": ["ok"]
}
]
7. Overall Structure Example:
{
"extend": {
"filters": [],
"groupBy": ["host_ip"],
"funcName": "count",
"fieldKey": "*",
"index": "default",
"source": "*",
"filterString": "host:hangzhou123 region:guanzhou"
},
"jsonScript": {
"type": "logToMetric",
"metricInfo": {
"every": "1m",
"metric": "test",
"metricField": "001-test",
"unit": "custom/[\"timeStamp\",\"ms\"]",
"desc": ""
},
"query": {
"q": "L('default')::RE(`.*`):(count(`*`)) { `host`='hangzhou123' and `region`='guanzhou' } BY `host_ip`",
"qtype": "dql"
}
}
}
Request Example¶
curl 'https://openapi.guance.com/api/v1/objc_cfg/rul_xxxx/create' \
-H 'DF-API-KEY: <DF-API-KEY>' \
-H 'Content-Type: application/json;charset=UTF-8' \
--data-raw '{"extend":{"filters":[],"groupBy":["host_ip"],"funcName":"count","fieldKey":"*","index":"default","source":"*","filterString":"host:hangzhou123 region:guanzhou"},"jsonScript":{"type":"logToMetric","metricInfo":{"every":"1m","metric":"test","metricField":"001-test","unit":"custom/[\"timeStamp\",\"ms\"]","desc":""},"query":{"q":"L('default')::RE(`.*`):(count(`*`)) { `host`='hangzhou123' and `region`='guanzhou' } BY `host_ip`","qtype":"dql"}}}' \
--compressed
Response¶
{
"code": 200,
"content": {
"workspaceUUID": "wksp_xxxx",
"monitorUUID": "",
"updator": null,
"type": "aggs",
"refKey": "",
"secret": null,
"jsonScript": {
"type": "logToMetric",
"metricInfo": {
"every": "1m",
"metric": "test",
"metricField": "001-test",
"unit": "custom/[\"timeStamp\",\"ms\"]",
"desc": ""
},
"query": {
"q": "L('default')::RE(`.*`):(count(`*`)) { `host`='hangzhou123' and `region`='guanzhou' } BY `host_ip`",
"qtype": "dql"
}
},
"crontabInfo": {
"id": "cron-4VdviPep3oHc",
"crontab": null
},
"extend": {
"filters": [],
"groupBy": [
"host_ip"
],
"funcName": "count",
"fieldKey": "*",
"index": "default",
"source": "*",
"filterString": "host:hangzhou123 region:guanzhou"
},
"createdWay": "manual",
"isLocked": false,
"openPermissionSet": false,
"permissionSet": [],
"id": null,
"uuid": "rul_xxxx",
"status": 0,
"creator": "acnt_xxxx",
"createAt": 1734594428,
"deleteAt": -1,
"updateAt": null,
"__operation_info": {
"uuid": "rul_xxxx"
}
},
"errorCode": "",
"message": "",
"success": true,
"traceId": "1111139030457458757"
}