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 a Structuring Template

Function

This API is used to query a structuring template.

Note:

A user can call this API for up to 50 times per second.

Calling Method

For details, see Calling APIs.

URI

GET /v3/{project_id}/lts/struct/customtemplate

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID. For details about how to obtain a project ID, see Obtaining the Project ID, Account ID, Log Group ID, and Log Stream ID.

Minimum: 32

Maximum: 32

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

id

No

String

ID of the template to be queried. This parameter is optional. If this parameter is not specified, all custom structuring templates used in the project are returned.

Minimum: 36

Maximum: 36

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token obtained from IAM. For details about how to obtain a user token, see Obtaining a User Token.

Minimum: 1000

Maximum: 2000

Content-Type

Yes

String

Set this parameter to application/json;charset=UTF-8.

Minimum: 30

Maximum: 30

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

results

Array of StructTemplateModel objects

Array of queried customized structuring templates.

Table 5 StructTemplateModel

Parameter

Type

Description

project_id

String

Project ID.

Minimum: 32

Maximum: 32

template_name

String

Template name.

Minimum: 1

Maximum: 64

template_type

String

Template type. The options are regular expression, JSON, delimiter, and Nginx.

Enumeration values:

  • regex

  • json

  • split

  • nginx

demo_log

String

Sample log event.

Minimum: 1

Maximum: 5000

demo_fields

Array of DemoField objects

Example field array.

tag_fields

Array of TagFieldNew objects

Tag field array.

rule

TemplateRule object

Structuring rule object.

demo_label

String

Example log tag.

Minimum: 0

Maximum: 5000

create_time

Long

Creation time.

Minimum: 0

Maximum: 20000000000000

id

String

Template ID.

Minimum: 36

Maximum: 36

Table 6 DemoField

Parameter

Type

Description

field_name

String

Field name.

Minimum: 1

Maximum: 64

content

String

Field example.

Minimum: 1

Maximum: 5000

type

String

Field data type.

Value: string, long, or float

Enumeration values:

  • string

  • long

  • float

is_analysis

Boolean

Whether to enable quick analysis.

index

Integer

Field number in manual regular expression and delimiter modes.

Minimum: 0

Maximum: 200

relation

String

Describes the hierarchical relationship between fields in a multi-level JSON file.

Minimum: 0

Maximum: 1000

user_defined_name

String

Custom field alias in JSON and Nginx modes.

Minimum: 1

Maximum: 64

Table 7 TagFieldNew

Parameter

Type

Description

field_name

String

Field name.

Minimum: 1

Maximum: 64

content

String

Field example.

Minimum: 0

Maximum: 5000

type

String

Field data type.

Value: string, long, or float

Enumeration values:

  • string

  • long

  • float

is_analysis

Boolean

Whether to enable quick analysis.

index

Integer

Sequence number (starting from 0).

Minimum: 0

Maximum: 200

Table 8 TemplateRule

Parameter

Type

Description

type

String

Structuring type. Currently, regular expression, JSON, delimiters, and Nginx are supported.

Enumeration values:

  • custom_regex

  • json

  • split

  • nginx

param

String

Specific structuring rule. Each structuring type has a unique structure:

A manual regular expression is a JSON string that contains the keyObject and regex_rules objects. keyObject contains key-value pairs, where a key indicates the index of an element in the demo_fields array, and a value indicates field_name. regex_rules is a regular expression. Example:

{\"keyObject\":{\"1\":\"date\",\"2\":\"num\"},\"regex_rules\":\"^(?<date>[^/]+)(?:[^]* ){8}(?<num>\\\\d+)\"}

In JSON mode, param is a JSON string that contains the keyObject and layers objects. keyObject contains key-value pairs, where a key indicates the field_name of an element in the demo_fields array, and a value indicates user_defined_name. layers indicates the maximum number of parsing layers. Its maximum value is 4. Example:

{\"keyObject\":{\"metadata.dimension\":\"dimension\",\"metadata.value\":\"\",\"metadata.unit\":\"\",\"collectionTime\":\"\"},\"layers\":3}

The delimiter mode uses a JSON string that contains the keyObject and tokenizer objects. keyObject contains key-value pairs, where a key indicates the index of an element in the demo_fields array, and a value indicates field_name. tokenizer indicates delimiters. Example:

{\"keyObject\":{\"0\":\"field1\",\"1\":\"field2\",\"2\":\"field3\",\"3\":\"field4\",\"4\":\"field5\",\"5\":\"field6\",\"6\":\"field7\",\"7\":\"field8\",\"8\":\"field9\"},\"tokenizer\":\"\"}

The Nginx mode uses a JSON string that contains the keyObject, regex, field_names, and log_format objects. keyObject contains key-value pairs, where a key indicates the field_name of an element in the demo_fields array, and a value indicates user_defined_name. regex is a regular expression, where the field_names object is the combination of field_name of each element in the demo_fields array. field_names are separated by commas (,). The log_format object indicates the Nginx log formatting mode. Example:

{\"keyObject\":{\"http_host\":\"host\",\"remote_addr\":\"\",\"request_method\":\"\",\"request_uri\":\"\",\"time_local\":\"\"},\"regex\":\"(\\\\d+/\\\\S+/\\\\d+:\\\\d+:\\\\d+:\\\\d+)\\\\s+\\\\S+\\\\s+(\\\\S*)\\\\s+(\\\\S*)\\\\s+(\\\\S*)\\\\s+\\\"([^\\\"]*)\\\".*\",\"fieldNames\":\"time_local,remote_addr,request_method,http_host,request_uri\",\"log_format\":\"log_format
upstreaminfo '$time_local $remote_addr  $request_method $http_host
\\\"$request_uri\\\"';\"}

Minimum: 1

Maximum: 5000

Status code: 500

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

Minimum: 8

Maximum: 8

error_msg

String

Error message.

Enumeration values:

  • Internal Server Error

Example Requests

Querying Details About the Current Structuring Template

GET https://{endpoint}/v3/{project_id}/lts/struct/customtemplate?id=bc8e3f2c-87fe-4acd-8439-69cdf29251c1

/v3/{project_id}/lts/struct/customtemplate?id=bc8e3f2c-87fe-4acd-8439-69cdf29251c1

Example Responses

Status code: 200

The request is successful.

{
  "results" : [ {
    "create_time" : 1641258099551,
    "demo_fields" : [ {
      "content" : "2022-01-03/14:52:28",
      "field_name" : "field1",
      "index" : 0,
      "is_analysis" : true,
      "type" : "string"
    }, {
      "content" : "this",
      "field_name" : "field2",
      "index" : 1,
      "is_analysis" : true,
      "type" : "string"
    }, {
      "content" : "log",
      "field_name" : "field3",
      "index" : 2,
      "is_analysis" : false,
      "type" : "string"
    }, {
      "content" : "is",
      "field_name" : "field4",
      "index" : 3,
      "is_analysis" : false,
      "type" : "string"
    }, {
      "content" : "Error",
      "field_name" : "field5",
      "index" : 4,
      "is_analysis" : false,
      "type" : "string"
    }, {
      "content" : "NO",
      "field_name" : "field6",
      "index" : 5,
      "is_analysis" : false,
      "type" : "string"
    }, {
      "content" : "13 testing.",
      "field_name" : "field7",
      "index" : 6,
      "is_analysis" : false,
      "type" : "string"
    }, {
      "content" : "286",
      "field_name" : "field8",
      "index" : 7,
      "is_analysis" : false,
      "type" : "long"
    } ],
    "demo_log" : "2022-01-03/14:52:28 this log is Error NO 13 testing 286.",
    "id" : "43a8cc7b-b632-4c36-a65d-8150e98219f1",
    "project_id" : "2a473356cca5487f8373be89xxxxxxxx",
    "rule" : {
      "param" : "{\"keyObject\":{\"0\":\"field1\",\"1\":\"field2\",\"2\":\"field3\",\"3\":\"field4\",\"4\":\"field5\",\"5\":\"field6\",\"6\":\"field7\",\"7\":\"field8\"},\"tokenizer\":\" \"}",
      "type" : "split"
    },
    "demo_label" : "{}",
    "tag_fields" : [ {
      "content" : "172.16.10.69",
      "field_name" : "hostIP",
      "index" : 0,
      "is_analysis" : true,
      "type" : "string"
    } ],
    "template_name" : "testSplit13",
    "template_type" : "split"
  } ]
}

Status code: 500

The server has received the request but encountered an internal error.

{
  "error_code" : "LTS.2017",
  "error_msg" : "Find struct template failed."
}

Status Codes

Status Code

Description

200

The request is successful.

500

The server has received the request but encountered an internal error.

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