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

Querying Logs

Function

This API is used to query logs by different dimensions, such as by cluster, IP address, or application. Pagination queries are supported.

Calling Method

For details, see Calling APIs.

URI

POST /v1/{project_id}/als/action

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

type

Yes

String

Log API call mode. When the value is querylogs, this API is used to query logs.

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.

Enumeration values:

  • application/json
Table 4 Request body parameters

Parameter

Mandatory

Type

Description

category

Yes

String

Log type. Values: app_log: application log. node_log: node log.custom_log: log in a custom path.

endTime

Yes

Long

End time of the query (UTC, in ms).

hideSyslog

No

Integer

Whether to hide system logs during log queries. 0: Hide system logs. 1: Show system logs.

keyWord

No

String

Keyword for search.

  1. Exact search by keyword is supported. A keyword is between two adjacent delimiters.
  2. Fuzzy search by keyword is supported. Example: RROR, ERRO?, ROR, ERR*, or ER*OR.
  3. Exact search by phrase is supported. Example: Start to refresh alm Statistic.
  4. Search using AND (&&) or OR (||) is supported. Example: query&&logs or query||logs. Note: Default delimiters: , '";=()[]{}@&<>/:\n\t\r

lineNum

No

String

Sequence number of the final log in the last query result. This parameter is not required for the first query, but is required for subsequent pagination queries.

pageSize/size

No

String

Number of logs queried each time. Default value: 5000. Recommended value: 100. For the first query, pageSize is used. For subsequent pagination queries, size is used.

searchKey

Yes

SearchKey object

Log filter criteria, which vary according to log sources.

startTime

Yes

Long

Start time of the query (UTC, in ms).

type

No

String

Pagination query. This parameter is not required for the first query, but is required for subsequent pagination queries.

isDesc

No

Boolean

Whether to query logs based on lineNum in ascending or descending order. true: lineNum in descending order (from the latest time to the earliest time) false: lineNum in ascending order (from the earliest time to the latest time)

Table 5 SearchKey

Parameter

Mandatory

Type

Description

appName

No

String

Application name.

clusterId

Yes

String

CCE cluster ID.

hostIP

No

String

IP address of the VM where logs are located.

nameSpace

No

String

CCE cluster namespace.

pathFile

No

String

Log file name.

podName

No

String

Container instance name.

Response Parameters

Status code: 200

Table 6 Response body parameters

Parameter

Type

Description

errorCode

String

Response code. SVCSTG_AMS_2000000: Success response.

errorMessage

String

Response message.

result

String

Metadata, including results and the total number of returned records.

Status code: 400

Table 7 Response body parameters

Parameter

Type

Description

errorCode

String

Response code.

errorMessage

String

Response message.

Status code: 401

Table 8 Response body parameters

Parameter

Type

Description

errorCode

String

Response code.

errorMessage

String

Response message.

Status code: 403

Table 9 Response body parameters

Parameter

Type

Description

errorCode

String

Response code.

errorMessage

String

Response message.

Status code: 500

Table 10 Response body parameters

Parameter

Type

Description

errorCode

String

Response code.

errorMessage

String

Response message.

Status code: 503

Table 11 Response body parameters

Parameter

Type

Description

errorCode

String

Response code.

errorMessage

String

Response message.

Example Requests

  • Example 1: Query application logs under a cluster.
    "POST https://{endpoint}/v1/{project_id}/als/action?type=querylogs"
    
    {
      "category" : "app_log",
      "endTime" : 15389000003,
      "hideSyslog" : 0,
      "keyWord" : "",
      "searchKey" : {
        "clusterId" : "c69xxxc-5xxx-1xxx-8xxx5-02xxxxx40"
      },
      "startTime" : 15389000003
    }
  • Example 2: Perform pagination queries. Notes:
    1. For pagination queries, the lineNum (sequence number of the final log in the last query result), type (value: next), and size parameters need to be added.
    2. The values of category, searchKey, keyWord, startTime, and endTime must be the same as those in the first query.
    3. To implement another pagination query, change the value of lineNum to the sequence number of the final log in the last query result. The rest may be deduced by analogy.
    /v1/{project_id}/als/action?type=querylogs
    
    {
      "category" : "app_log",
      "searchKey" : {
        "clusterId" : "874xxx9a2-xxxf-xxx-8xxe-02xxxxx3"
      },
      "keyWord" : "",
      "startTime" : 156946300095,
      "endTime" : 15694600008895,
      "lineNum" : "1569463900000047",
      "type" : "next",
      "size" : 100,
      "hideSyslog" : 0
    }

Example Responses

Status code: 200

OK: The request is successful.

{
  "errorCode" : "SVCSTG.ALS.200.200",
  "errorMessage" : "Query data success",
  "result" : [ {
    "data" : [ {
      "appName" : "axxs0712",
      "category" : "apx",
      "clusterId" : "c6xxxx7c-54cd-11e8-8055-025xxx1e40",
      "collectTime" : 153900000983,
      "time" : 153900000983,
      "containerName" : "contsssner-0",
      "hostIP" : "1xx.xxx.0.1xxx",
      "hostId" : "c11xxxxx11-0000b-4925-bef4-d0xxxx9b0",
      "hostName" : "1x2.168.0.xxx",
      "lineNum" : "1xxx23xxxxxx2VW5xxxxxx0ZWdlcg==",
      "logContent" : "warn:2018/10/09 06:57:01 helloworld.go:108: the main processis running now.",
      "logContentSize" : null,
      "loghash" : "4xxxxx0d40a83c17f262540xxxxxxxxfeaa30eb",
      "nameSpace" : "default",
      "pathFile" : "/xxx/xxx/xxx/xxx/xxx/xxx.trxe",
      "podName" : "axxx12-7xxf884-qxxwp",
      "serviceID" : ""
    } ],
    "total" : 5000
  } ]
}

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