Querying Application Discovery Rules¶
Function¶
This API is used to query existing application discovery rules in the system.
URI¶
GET /v1/{project_id}/inv/servicediscoveryrules
Parameter | Mandatory | Type | Description |
---|---|---|---|
project_id | Yes | String | Project ID obtained from IAM. Generally, a project ID contains 32 characters. |
Parameter | Mandatory | Type | Description |
---|---|---|---|
id | No | String | Application discovery rule ID, which corresponds to an application discovery rule. If this parameter is left blank, all application discovery rules in the project are returned. |
Request Parameters¶
Parameter | Mandatory | Type | Description |
---|---|---|---|
X-Auth-Token | Yes | String | User token obtained from IAM. |
Content-Type | Yes | String | Content type, which is application/json. |
Response Parameters¶
Status code: 200
Parameter | Type | Description |
---|---|---|
appRules | Array of AppRules objects | Rule information. |
errorCode | String | Response code. SVCSTG.INV.2000000: Success response. |
errorMessage | String | Response message. |
Parameter | Type | Description |
---|---|---|
createTime | String | Creation time. When creating an application discovery rule, leave this parameter blank. When modifying an application discovery rule, enter the returned createTime. |
enable | Boolean | Whether a rule is enabled. Value: true or false. |
eventName | String | aom_inventory_rules_event Rule event name. For application discovery, the fixed value is aom_inventory_rules_event. Enumeration values:
|
hostid | Array of strings | Host ID (not used currently and can be left empty). |
id | String | Rule ID. When creating an application discovery rule, leave this parameter blank. When modifying an application discovery rule, enter a rule ID. |
name | String | Rule name. The value can contain a maximum of 64 characters. It must start with a lowercase letter and cannot end with a hyphen (-). Only digits, lowercase letters, and hyphens are allowed. |
projectid | String | Project ID obtained from IAM. Generally, a project ID contains 32 characters. |
spec | AppRulesSpec object | Rule details. |
Parameter | Type | Description |
---|---|---|
appType | String | Service type, which is used only for rule classification and UI display. You can enter any field. For example, enter Java or Python by technology stack. You can also enter collector or database by function. |
attrList | Array of strings | Attribute list (not used currently and can be left empty). Value: cmdLine or env. |
detectLog | String | Whether to enable log collection. Value: true or false. |
discoveryRule | Array of DiscoveryRule objects | Discovery rule. When it is an array consisting of multiple conditions, only the processes that meet all the conditions are filtered.If the value of checkType is cmdLine, set the value of checkMode to contain. checkContent is in the format of ["xxx"], indicating that the process must contain the xxx parameter. If the value of checkType is env, set the value of checkMode to contain. checkContent is in the format of ["k1","v1"], indicating that the process must contain the environment variable whose name is k1 and value is v1. If the value of checkType is scope, set the value of checkMode to equals. checkContent is in the format of ["hostId1","hostId2"], indicating that the rule takes effect only on specified nodes. If no nodes are specified, the rule applies to all nodes of the project. |
isDefaultRule | String | Whether the current rule is the default one. Value: true or false. |
isDetect | String | Whether the scenario is a pre-check scenario. No rules will be saved in the pre-check scenario. This scenario is designed only to check whether a rule can detect node processes before it is delivered. Value: true or false. |
logFileFix | Array of strings | Log file suffix. Value: log, trace, or out. |
logPathRule | Array of LogPathRule objects | Log path configuration rule.If cmdLineHash is a fixed string, a log path or log file is specified. Otherwise, only the files whose names end with .log and .trace are collected. If the value of nameType is cmdLineHash, args is in the format of ["00001"] and value is in the format of ["/xxx/xx.log"], indicating that the log path is /xxx/xx.log when the startup command is 00001. |
nameRule | NameRule object | Naming rules for discovered services and applications. |
priority | String | Rule priority. An integer ranging from 1 to 9999. The default value is 9999. |
Parameter | Type | Description |
---|---|---|
checkContent | Array of strings | Matched value. |
checkMode | String | Match condition. Value: contain or equals. |
checkType | String | Match type. Value: cmdLine, env, or scope. |
Parameter | Type | Description |
---|---|---|
args | Array of strings | Command. |
nameType | String | Value type. Option: cmdLineHash. |
value | Array of strings | Log path. |
Parameter | Type | Description |
---|---|---|
appNameRule | Array of AppNameRule objects | Service name rule. If there are multiple objects in the array, the character strings extracted from these objects constitute the service name.If the value of nameType is cmdLine, args is in the format of ["start", "end"], indicating that the characters between start and end in the command are extracted.If the value of nameType is cmdLine, args is in the format of ["aa"], indicating that the environment variable named aa is extracted.If the value of nameType is str, args is in the format of ["fix"], indicating that the service name is suffixed with fix.If the value of nameType is cmdLineHash, args is in the format of ["0001"] and value is in the format of ["ser"], indicating that the service name is ser when the startup command is 0001. |
applicationNameRule | Array of ApplicationNameRule objects | Application name rule.If the value of nameType is cmdLine, args is in the format of ["start", "end"], indicating that the characters between start and end in the command are extracted.If the value of nameType is cmdLine, args is in the format of ["aa"], indicating that the environment variable named aa is extracted.If the value of nameType is str, args is in the format of ["fix"], indicating that the service name is suffixed with fix.If the value of nameType is cmdLineHash, args is in the format of ["0001"] and value is in the format of ["ser"], indicating that the application name is ser when the startup command is 0001. |
Parameter | Type | Description |
---|---|---|
nameType | String | Value type. Options: cmdLineHash, cmdLine, env, and str. |
args | Array of strings | Input value. |
value | Array of strings | Service name, which is mandatory only if the value of nameType is cmdLineHash. |
Parameter | Type | Description |
---|---|---|
nameType | String | Value type. Options: cmdLineHash, cmdLine, env, and str. |
args | Array of strings | Input value. |
value | Array of strings | Service name, which is mandatory only if the value of nameType is cmdLineHash. |
Example Requests¶
GET https://{Endpoint}/v1/{project_id}/inv/servicediscoveryrules?id=b788349e-62b2-3c7a-b597-02c611d59801
Example Responses¶
Status code: 200
OK
The request is successful.
{
"appRules" : [ {
"createTime" : "1599098476654",
"enable" : true,
"name" : "ica**nt",
"eventName" : "aom_in***tory_rules_event",
"hostid" : [ ],
"id" : "b53a5152-****-****-****-302367e04c0b",
"projectid" : "2a473356c**********be891bffc1cf",
"spec" : {
"detectLog" : "true",
"editable" : null,
"logPathRule" : [ ],
"priority" : 9999,
"attrList" : [ "cmdLine" ],
"nameRule" : {
"appNameRule" : [ {
"nameType" : "cmdLineHash",
"args" : [ "/opt/********* -DNFW=ica**nt" ],
"value" : [ "aicagentserver" ]
} ],
"applicationNameRule" : [ {
"nameType" : "cmdLineHash",
"args" : [ "/opt/*********** -DNFW=ica**nt" ],
"value" : [ "aica**nt" ]
} ]
},
"appType" : "",
"aom_metric_relabel_configs" : null,
"logFileFix" : [ "log", "trace", "out" ],
"isDetect" : "false",
"isDefaultRule" : null,
"dataSource" : null,
"discoveryRule" : [ {
"checkType" : "cmdLine",
"checkContent" : [ "-DNFW=ica**nt" ],
"checkMode" : "contain"
} ]
},
"desc" : null
} ],
"errorMessage" : null,
"errorCode" : "SVCSTG.INV.2000000",
"responseStatus" : 200
}
Status Codes¶
Status Code | Description |
---|---|
200 | OK The request is successful. |
400 | Bad Request Invalid request. The client should not repeat the request without modifications. |
401 | Unauthorized The authorization information is incorrect or invalid. |
403 | ForbiddenThe request is rejected. The server has received the request and understood it, but the server refuses to respond to it. The client should not repeat the request without modifications. |
500 | Internal Server Error The server is able to receive the request but unable to understand the request. |
503 | Service Unavailable The requested service is invalid. The client should not repeat the request without modifications. |
Error Codes¶
See Error Codes.