Adding or Modifying One or More Application Discovery Rules (Offline Soon)
Function
This API is used to add or modify one or more application discovery rules. A maximum of 100 rules can be added to a project.
URI
PUT /v1/{project_id}/inv/servicediscoveryrules
Request
Request parameters
Table 1 describes the request parameter.
Parameter |
Mandatory |
Type |
Value Range |
Description |
---|---|---|---|---|
appRules |
No |
Array |
- |
See Table 2. |
Parameter |
Mandatory |
Type |
Value Range |
Description |
---|---|---|---|---|
projectid |
Yes |
String |
- |
Project ID obtained from IAM. Generally, a project ID contains 32 characters. |
id |
Yes |
String |
- |
Rule ID. When creating a discovery rule, leave this parameter blank. When modifying a discovery rule, enter a rule ID. |
name |
Yes |
String |
The value can contain a maximum of 64 characters. It must start with a lowercase letter but cannot end with a hyphen (-). Only digits, lowercase letters, and hyphens are allowed. |
Rule name. |
createTime |
No |
String |
- |
Creation time. When creating a discovery rule, leave this parameter blank. When modifying a discovery rule, enter the returned createTime. |
enable |
Yes |
Boolean |
true or false |
Whether to enable a rule. |
hostid |
No |
Array |
- |
Host ID. Currently, this parameter is not used and can be left blank. |
eventName |
Yes |
String |
aom_inventory_rules_event |
Rule event name. For application discovery, the value is fixed to aom_inventory_rules_event. |
spec |
Yes |
Object |
- |
Rule details. See Table 3. |
Parameter |
Mandatory |
Type |
Value Range |
Description |
---|---|---|---|---|
detectLog |
Yes |
String |
true or false |
Whether to enable log collection. |
logFileFix |
Yes |
Array |
log, trace, or out |
Log file suffix. |
discoveryRule |
Yes |
Array |
|
Discovery rule. When it is an array consisting of multiple conditions, only the processes that meet all the conditions are filtered. See Table 4. |
attrList |
No |
Array |
cmdLine or env |
Attribute list. Currently, this parameter is not used and can be left blank. |
isDetect |
Yes |
String |
true or false |
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 rules before they are delivered. |
isDefaultRule |
Yes |
String |
true or false |
Whether this rule will become the default rule. |
priority |
Yes |
Integer |
An integer from 1 to 9999. Default value: 9999. |
Rule priority. |
nameRule |
Yes |
Object |
- |
Naming requirements of the application discovery rule. See Table 5. |
appType |
Yes |
String |
- |
Application type, which is used to categorize applications and is used only for rule classification and UI display. Enter any field. For example, enter Java or Python by technology stack, or enter collector or database by function. |
logPathRule |
No |
Array |
|
Log path configuration rule. See Table 8. |
Parameter |
Mandatory |
Type |
Value Range |
Description |
---|---|---|---|---|
checkType |
Yes |
String |
cmdLine, env, or scope |
Match type. |
checkMode |
Yes |
String |
contain or equals |
Match condition. |
checkContent |
Yes |
Array |
- |
Matched value. |
Parameter |
Mandatory |
Type |
Value Range |
Description |
---|---|---|---|---|
appNameRule |
Yes |
Array |
|
Application name rule. If there are multiple objects in an array, the character strings extracted from these objects constitute the application name. See Table 6. |
applicationNameRule |
Yes |
Array |
|
Application name rule. See Table 7. |
Parameter |
Mandatory |
Type |
Value Range |
Description |
---|---|---|---|---|
nameType |
Yes |
String |
cmdLineHash, cmdLine, env, or str |
Value type. |
args |
Yes |
Array |
- |
Input value. |
value |
No |
Array |
- |
Application name, which is mandatory only when the value of nameType is cmdLineHash. |
Parameter |
Mandatory |
Type |
Value Range |
Description |
---|---|---|---|---|
nameType |
Yes |
String |
cmdLineHash, cmdLine, env, or str |
Value type. |
args |
Yes |
Array |
- |
Input value. |
value |
No |
Array |
- |
Application name, which is mandatory only when the value of nameType is cmdLineHash. |
Parameter |
Mandatory |
Type |
Value Range |
Description |
---|---|---|---|---|
nameType |
Yes |
String |
cmdLineHash |
Value type. |
args |
Yes |
Array |
- |
Command. |
value |
Yes |
Array |
- |
Log path. |
Request headers
Table 9 describes the request headers.
Parameter |
Mandatory |
Description |
---|---|---|
X-Auth-Token |
Yes |
User token obtained from IAM. |
Content-Type |
Yes |
Content type, which is application/json. |
Example request
{ "appRules": [ { "id": "", "name": "bytest", "createTime": "", "projectid": "5a6036f48e954fcd84d198cb28db311a", "enable": true, "hostid": [], "eventName": "aom_inventory_rules_event", "spec": { "detectLog": "true", "logFileFix": ["log","trace"], "discoveryRule": [ { "checkType": "cmdLine", "checkMode": "contain", "checkContent": ["default"] },{ "checkType": "scope", "checkMode": "equals", "checkContent": [ "44d6c4bb-f673-4bf4-8d33-313832f37b28" ] } ], "attrList": ["cmdLine"], "isDetect": "false", "priority": "1", "nameRule": { "appNameRule": [ { "nameType":"cmdLineHash", "args":["00000000001"], "value":["serviceName1"] }, { "nameType": "cmdLine", "args": [ "/var/paas/kubernetes/","/kubeconfig" ] }, { "nameType": "env", "args": ["APP_NAME"] }, { "nameType": "str", "args": ["kube"] } ], "applicationNameRule": [ { "nameType":"cmdLineHash", "agrs":["00000000001"], "value":["applicationName1"] }, { "nameType": "str", "args": ["kubeproxy"] } ] }, "appType": "", "isDefaultRule":"false", "logPathRule": [ { "nameType":"cmdLineHash", "agrs":["00000000001"], "value":["/xx/xxx/xx.log","/xx/xxx/xx"] } ] } } ] }
Response
Response parameters
Table 10 describes the response parameters.
Parameter |
Type |
Description |
---|---|---|
errorCode |
String |
Response code. |
errorMessage |
String |
Response message. |
Example response
{ "errorCode":"SVCSTG.INV.2000000", "errorMessage":"" }
Status Code
- Success response
Table 11 describes the status code.
- Error response
Table 12 describes the status codes. For more information, see Status Codes.
Table 12 Status codes Status Code
Message
Description
400
Bad Request
Invalid request.
The client should not repeat the request without modifications.
401
Unauthorized
The authentication information is incorrect or invalid.
403
Forbidden
The 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 Code
Error Code |
Error Message |
Solution |
---|---|---|
SVCSTG.INV.4030000 |
Forbidden |
Use an authorized account. |
SVCSTG.INV.4000115 |
Invalid request parameter. |
Check the parameter. |
SVCSTG.INV.5000002 |
The Elasticsearch execution is abnormal. |
Contact technical support. |
SVCSTG.INV.5000003 |
The call ICMGR is abnormal. |
Contact technical support. |
SVCSTG.INV.5000001 |
The Elasticsearch session is null. |
Contact technical support. |
SVCSTG.INV.5000006 |
The apprule name already exists. |
Use another name. |
SVCSTG.INV.5000007 |
The maximum number of rules has been reached. |
Delete unnecessary rules and add new rules. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.