Updated on 2024-04-15 GMT+08:00

Querying Application Discovery Rules

Function

This API is used to query existing application discovery rules in the system.

URI

GET /v1/{project_id}/aom/application-discovery-rules

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID obtained from IAM. Generally, a project ID contains 32 characters.

Table 2 Query Parameters

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

Table 3 Request header 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

Table 4 Response body parameters

Parameter

Type

Description

app_rules

Array of AppRuleV1 objects

Application Discovery Rules

Table 5 AppRuleV1

Parameter

Type

Description

project_id

String

Project ID obtained from IAM. Generally, a project ID contains 32 characters.

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.

enable

Boolean

Whether a rule is enabled. Value: true or false.

host_id

Array of strings

Host ID (not used currently and can be left empty).

event_name

String

aom_inventory_rules_event Rule event name. For service discovery, the fixed name is aom_inventory_rules_event.

spec

AppRulesSpecV1 object

Additional information.

create_time

String

Creation time. When creating an application discovery rule, leave this parameter blank. When modifying an application discovery rule, enter the returned createTime.

desc

String

Rule description.

Table 6 AppRulesSpecV1

Parameter

Type

Description

app_type

String

Service type, which is used only for rule classification and UI display. You can enter any field. For example, enter Java or Python to specify a technology stack. You can also enter collector or database to specify a function.

attr_list

Array of strings

Attribute list (not used currently and can be left empty).

discovery_rule

Array of DiscoveryRuleV1 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.

name_rule

NameRuleV1 object

Naming rules for discovered services and applications.

detect_log

String

Whether to enable log collection. Value: true or false

log_file_fix

Array of strings

Log file suffix. Value: log, trace, or out

priority

Integer

Rule priority. Value: 1–9999 (default)

is_detect

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. true or false

data_source

String

Data source.

editable

String

Whether a rule can be modified. If editable is set to "false", the rule is a system rule and cannot be deleted.

is_default_rule

String

Whether the current rule is the default one. Value: true or false

log_path_rule

Array of NameRuleContent 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.

aom_metric_relabel_configs

Array of Map<String,String> objects

Metric configuration.

Table 7 DiscoveryRuleV1

Parameter

Type

Description

check_type

String

Match type. Value: cmdLine, env, or scope

check_mode

String

Match condition. Value: contain or equals

check_content

Array of strings

Matched value.

Table 8 NameRuleV1

Parameter

Type

Description

app_name_rule

Array of NameRuleContent objects

Component naming rule.

application_name_rule

Array of NameRuleContent objects

Application naming rule.

environment

Array of NameRuleContent objects

Environment information.

Table 9 NameRuleContent

Parameter

Type

Description

name_type

String

Value type.

args

Array of strings

Command.

value

Array of strings

Log path.

Example Requests

Query application discovery rules.

GET https://{Endpoint}/v1/{project_id}/aom/application-discovery-rules

Example Responses

Status code: 200

OK

The request is successful.

{
  "app_rules" : [ {
    "create_time" : "1599098476654",
    "enable" : true,
    "name" : "ica**nt",
    "event_name" : "aom_in***tory_rules_event",
    "host_id" : [ ],
    "id" : "b53a5152-****-****-****-302367e04c0b",
    "project_id" : "2a473356c**********be891bffc1cf",
    "spec" : {
      "detect_log" : "true",
      "editable" : null,
      "log_path_rule" : [ ],
      "priority" : 9999,
      "attr_list" : [ "cmdLine" ],
      "name_rule" : {
        "app_name_rule" : [ {
          "name_type" : "cmdLineHash",
          "args" : [ "/opt/********* -DNFW=ica**nt" ],
          "value" : [ "aicagentserver" ]
        } ],
        "application_name_rule" : [ {
          "name_type" : "cmdLineHash",
          "args" : [ "/opt/*********** -DNFW=ica**nt" ],
          "value" : [ "aica**nt" ]
        } ]
      },
      "app_type" : "",
      "aom_metric_relabel_configs" : null,
      "log_file_fix" : [ "log", "trace", "out" ],
      "is_detect" : "false",
      "is_default_rule" : null,
      "data_source" : null,
      "discovery_rule" : [ {
        "check_type" : "cmdLine",
        "check_content" : [ "-DNFW=ica**nt" ],
        "check_mode" : "contain"
      } ]
    },
    "desc" : null
  } ]
}

Status Codes

Status Code

Description

200

OK

The request is successful.

400

Bad Request

The client should not repeat the request without modifications.

401

Unauthorized

The authentication information is incorrect or invalid.

403

ForbiddenThe server has received the request and understood it, but the server is refusing to respond to it. The client should not repeat the request without modifications.

500

Internal Server Error

The server has received the request but could not understand it.

503

Service Unavailable

The client should not repeat the request without modifications.

Error Codes

See Error Codes.