Querying a Structuring Rule

Function

This API is used to query the structuring rule of a specified log stream.

URI

GET /v2/{project_id}/lts/struct/template

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

logGroupId

Yes

String

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

Minimum: 36

Maximum: 36

logStreamId

Yes

String

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

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

demoFields

Array of StructFieldInfoReturn objects

Structured field.

tagFields

Array of tag_fields_info objects

Keyword details.

demoLog

String

Sample log event.

demoLabel

String

Attributes of the sample log event.

id

String

Structuring rule ID.

logGroupId

String

Log group ID.

rule

ShowStructTemplateRule object

Structuring method.

cluster_info

ShowStructTemplateclusterInfo object

Kafka information.

logStreamId

String

Log stream ID.

projectId

String

Project ID.

templateName

String

Template name.

regex

String

Regular expression.

Table 5 StructFieldInfoReturn

Parameter

Type

Description

fieldName

String

Field name.

type

String

Field data type.

content

String

Field content.

isAnalysis

Boolean

Whether parsing is enabled.

index

Integer

Field sequence number.

Table 6 tag_fields_info

Parameter

Type

Description

fieldName

String

Field name.

type

String

Field type.

content

String

Content.

isAnalysis

Boolean

Whether parsing is enabled.

index

Integer

Field sequence number.

Table 7 ShowStructTemplateRule

Parameter

Type

Description

param

String

Structuring parameter.

type

String

Structuring type.

Table 8 ShowStructTemplateclusterInfo

Parameter

Type

Description

cluster_name

String

Kafka cluster name.

kafka_bootstrap_servers

String

Kafka cluster server address.

kafka_ssl_enable

Boolean

Whether SSL encrypted authentication is enabled for Kafka.

Status code: 400

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 401

Table 10 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 403

Table 11 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 500

Table 12 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Example Requests

GET https://{endpoint}/v2/{project_id}/lts/struct/template?logGroupId=123456&logStreamId=654321

Example Responses

Status code: 200

Details of the structuring rule are returned.

{
  "demoFields" : [ {
    "content" : "100.19.10.178",
    "fieldName" : "authority",
    "index" : 0,
    "isAnalysis" : true,
    "type" : "string"
  }, {
    "content" : "0",
    "fieldName" : "bytes_received",
    "index" : 0,
    "isAnalysis" : true,
    "type" : "string"
  }, {
    "content" : "1127",
    "fieldName" : "bytes_sent",
    "index" : 0,
    "isAnalysis" : true,
    "type" : "string"
  } ]
}

Status code: 400

BadRequest. The request is invalid. Modify the request based on the description in error_msg before a retry.

{
  "errorCode" : "SVCSTG.ALS.200201",
  "errorMessage" : "Query Param is error."
}

Status code: 401

AuthFailed. Authentication failed. Check the token and try again.

{
  "error_code" : "LTS.0414",
  "error_msg" : "Invalid token"
}

Status code: 403

Forbidden.The request has been rejected.The server has received the request and understood it, but refuses to respond to it. The client should not repeat the request without modifications.

{
  "error_code" : "LTS.0001",
  "error_msg" : "Invalid projectId"
}

Status code: 500

InternalServerError.

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

{
  "error_code" : "LTS.0102",
  "error_msg" : "Query empty."
}

Status Codes

Status Code

Description

200

Details of the structuring rule are returned.

400

BadRequest. The request is invalid. Modify the request based on the description in error_msg before a retry.

401

AuthFailed. Authentication failed. Check the token and try again.

403

Forbidden.The request has been rejected.The server has received the request and understood it, but refuses to respond to it. The client should not repeat the request without modifications.

500

InternalServerError.

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

503

ServiceUnavailable. The requested service is unavailable.

Error Codes

See Error Codes.