Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ Application Operations Management/ API Reference (Kuala Lumpur Region)/ APIs/ Monitoring/ Adding or Modifying One or More Service Discovery Rules

Adding or Modifying One or More Service Discovery Rules

Function

This API is used to add or modify one or more service discovery rules. A maximum of 100 rules can be added to a project.

Calling Method

For details, see Calling APIs.

URI

PUT /v1/{project_id}/inv/servicediscoveryrules

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

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

Request Parameters

Table 2 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.

Enumeration values:

  • application/json

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

appRules

No

Array of AppRules objects

Service parameters.

Table 4 AppRules

Parameter

Mandatory

Type

Description

createTime

No

String

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

Default: 1599098476654

enable

Yes

Boolean

Whether a rule is enabled. Values: true and false.

eventName

Yes

String

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

hostid

No

Array of strings

Host ID. Currently, this parameter is not used and can be left blank.

id

Yes

String

Rule ID. When creating a service discovery rule, leave this parameter blank. When modifying a service discovery rule, enter a rule ID.

name

Yes

String

Rule name, which contains 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.

projectid

Yes

String

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

spec

Yes

AppRulesSpec object

Rule details.

desc

No

String

Custom description

Table 5 AppRulesSpec

Parameter

Mandatory

Type

Description

appType

Yes

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, or enter collector or database by function.

attrList

No

Array of strings

Attribute list. Currently, this parameter is not used and can be left blank. Values: cmdLine and env.

detectLog

Yes

String

Whether to enable log collection. Values: true and false.

discoveryRule

Yes

Array of DiscoveryRule objects

Discovery rule. If the array contains multiple conditions, only the processes that meet all the conditions will be matched. 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

Yes

String

Whether the rule is the default one. Values: true and false.

isDetect

Yes

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. Values: true and false.

logFileFix

Yes

Array of strings

Log file suffix. Values: log, trace, and out.

logPathRule

No

Array of LogPathRule objects

Log path configuration rule. If cmdLineHash is a fixed string, logs in the specified log path or log file are collected. Otherwise, only the files whose names end with .log or .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

Yes

NameRule object

Naming rules for discovered services and applications.

priority

Yes

Integer

Rule priority. Value range: 1 to 9999. Default value: 9999.

dataSource

No

String

Data source.

editable

No

String

Whether to support editing. Options: true and false.

aom_metric_relabel_configs

No

Object

Metric configuration.

Table 6 DiscoveryRule

Parameter

Mandatory

Type

Description

checkContent

Yes

Array of strings

Matched value.

checkMode

Yes

String

Match condition. Values: contain and equals.

checkType

Yes

String

Match type. Values: cmdLine, env, and scope.

Table 7 LogPathRule

Parameter

Mandatory

Type

Description

args

Yes

Array of strings

Command.

nameType

Yes

String

Value type, which can be cmdLineHash.

value

Yes

Array of strings

Log path.

Table 8 NameRule

Parameter

Mandatory

Type

Description

appNameRule

Yes

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

Yes

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.

Table 9 AppNameRule

Parameter

Mandatory

Type

Description

nameType

Yes

String

Value type. Values: cmdLineHash, cmdLine, env, and str.

args

Yes

Array of strings

Input value.

value

No

Array of strings

Service name, which is mandatory only when the value of nameType is cmdLineHash.

Table 10 ApplicationNameRule

Parameter

Mandatory

Type

Description

nameType

Yes

String

Value type. Values: cmdLineHash, cmdLine, env, and str.

args

Yes

Array of strings

Input value.

value

No

Array of strings

Service name, which is mandatory only when the value of nameType is cmdLineHash.

Response Parameters

Status code: 200

Table 11 Response body parameters

Parameter

Type

Description

errorCode

String

Response code.

errorMessage

String

Response message.

responseStatus

Integer

Response status code (no longer used).

id

Array of strings

Service discovery rule ID list. This parameter is used during cross-AZ configuration synchronization.

results

Array of Map<String,String> objects

Details about service discovery rules.

Example Requests

Add an application discovery rule whose name is aom_inventory_rules_event and project ID is 684fc87a79d7xxxx22e62a7da95b.

https://{endpoint}/v1/{project_id}/inv/servicediscoveryrules

{
  "appRules" : [ {
    "createTime" : "1694705766730",
    "enable" : true,
    "name" : "ica**nt",
    "eventName" : "aom_inventory_rules_event",
    "hostid" : [ ],
    "id" : "b53a5152-****-****-****-302367e04c0b",
    "projectid" : "684fc87a79d7xxxx22e62a7da95b",
    "spec" : {
      "detectLog" : "true",
      "editable" : null,
      "logPathRule" : [ ],
      "priority" : 9999,
      "attrList" : [ "cmdLine" ],
      "nameRule" : {
        "appNameRule" : [ {
          "args" : [ "/opt/********* -DNFW=ica**nt" ],
          "nameType" : "cmdLineHash",
          "value" : [ "aicagentserver" ]
        } ],
        "applicationNameRule" : [ {
          "args" : [ "/opt/*********** -DNFW=ica**nt" ],
          "nameType" : "cmdLineHash",
          "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" : "Custom description"
  } ]
}

Example Responses

Status code: 200

OK: The request is successful.

{
  "errorCode" : "SVCSTG.INV.2000000",
  "errorMessage" : null,
  "id" : [ ],
  "results" : [ {
    "name" : "aom_inventory_rules_event",
    "id" : "b53a5152-****-****-****-302367e04c0b"
  } ]
}

Status code: 400

Bad Request: The request is invalid. The client should not repeat the request without modifications.

{
  "errorCode" : "SVCSTG.INV.4000115",
  "errorMessage" : "Request param is invalid",
  "id" : [ ],
  "results" : [ ]
}

Status Codes

Status Code

Description

200

OK: The request is successful.

400

Bad Request: The request is invalid. 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 Codes

See Error Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback