Updated on 2025-08-21 GMT+08:00

Querying Structuring Templates

Function

This API is used to query details about custom structuring templates, which are essential for structuring configuration.

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

Definition

Project ID. It can be obtained by calling an API or from the console. For details, see Obtaining a Project ID.

Constraints

N/A

Range

N/A

Default Value

N/A

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

id

No

String

Definition

ID of the structuring template to be queried. If this parameter is left empty, all custom structuring templates in the project are returned.

Constraints

N/A

Range

N/A

Default Value

N/A

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

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

Constraints:

N/A

Range

N/A

Default Value

N/A

Content-Type

Yes

String

Definition

Message body format. Set this parameter to application/json;charset=utf8.

Constraints

N/A

Range

N/A

Default Value

N/A

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

results

Array of StructTemplateModel objects

Definition

Information about the queried custom structuring template.

Table 5 StructTemplateModel

Parameter

Type

Description

project_id

String

Definition

Project ID.

Range

N/A

template_name

String

Definition

Structuring template name.

Range

N/A

template_type

String

Definition

Structuring template type.

Range

  • regex

  • json

  • split

  • nginx

  • built_in

  • custom_regex

  • regex_auto

demo_log

String

Definition

Sample log event.

Range

N/A

demo_fields

Array of DemoField objects

Definition

Fields generated after the sample log event is parsed based on the structuring configuration.

tag_fields

Array of TagFieldNew objects

Definition

Fixed fields generated based on the log reporting channel or static fields manually configured by the user.

rule

TemplateRule object

Definition

Structuring method.

demo_label

String

Definition

Complete JSON structure example of the sample log and system fields.

Range

N/A

create_time

Long

Definition

Time when the structuring template was created.

Range

N/A

id

String

Definition

Unique ID of the custom structuring template.

Range

N/A

Table 6 DemoField

Parameter

Type

Description

field_name

String

Definition

Name of an extracted field.

Range

N/A

content

String

Definition

Sample content of the extracted field.

Range

N/A

type

String

Definition

Field data type.

Range

  • string

  • long

  • float

is_analysis

Boolean

Definition

Whether quick analysis is enabled. If indexing is configured, the quick analysis setting specified on the Index Settings tab page is applied.

Range

  • true: enables quick analysis.

  • false: disables quick analysis.

index

Integer

Definition

Field sequence number in regular expression and delimiter methods.

Range

N/A

relation

String

Definition

Hierarchical relationship between fields in a multi-level JSON file.

Range

N/A

user_defined_name

String

Definition

Custom field alias in JSON and Nginx modes.

Range

N/A

Table 7 TagFieldNew

Parameter

Type

Description

field_name

String

Definition

Tag field name.

Range

N/A

content

String

Definition

Sample content of the tag field.

Range

N/A

type

String

Definition

Tag field type.

Range

  • string

  • float

  • long

is_analysis

Boolean

Definition

Whether quick analysis is enabled. If indexing is configured, the quick analysis setting specified on the Index Settings tab page is applied.

Range

  • true: enables quick analysis.

  • false: disables quick analysis.

index

Integer

Definition

Field sequence number.

Range

N/A

Table 8 TemplateRule

Parameter

Type

Description

type

String

Definition

Structuring method of the structuring template.

Range

  • regex

  • json

  • split

  • nginx

  • built_in

  • custom_regex

  • regex_auto

param

String

Definition

Structuring parameter. It contains configuration parameters required for the corresponding structuring type. For example, if type is set to split, the param field returns a JSON string containing delimiters. If type is set to regex, the param field returns the configured regular expression.

Range

N/A

Status code: 500

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Definition

Error code. For details, see Error Codes.

Range

N/A

error_msg

String

Definition

Error message.

Range

N/A

Example Requests

Query the structuring template details.

GET https://{endpoint}/v3/{project_id}/lts/struct/customtemplate 

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

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.