查询结构化模板
功能介绍
查询结构化模板。通过该接口可查询自定义的结构化模板信息,帮助您进行结构化配置。
单个用户每秒最多可调用50次该接口。
调用方法
请参见如何调用API。
URI
GET /v3/{project_id}/lts/struct/customtemplate
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
参数解释: 项目ID,获取方式请参见:获取项目ID、获取账号ID、日志组ID、日志流ID。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
id |
否 |
String |
参数解释: 待查询模板ID,非必填。当参数为空时,返回项目下所有自定义结构化模板。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
参数解释: 从IAM服务获取的用户Token,获取方式请参见:获取用户Token。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
Content-Type |
是 |
String |
参数解释: 该字段填为:application/json;charset=UTF-8。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
响应参数
状态码:200
参数 |
参数类型 |
描述 |
---|---|---|
results |
Array of StructTemplateModel objects |
参数解释: 查询的自定义结构化模板数组。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
project_id |
String |
参数解释: 项目ID。 取值范围: 不涉及。 |
template_name |
String |
参数解释: 模板名称。 取值范围: 不能以.和_开头或以.结尾, 只能包含字母、英文、数字、中划线、下划线(_)、小数点(.),长度最大为64。 |
template_type |
String |
参数解释: 模板类型。有regex、json、split、nginx、built_in和custom_regex。 取值范围: 不涉及。 |
demo_log |
String |
参数解释: 示例日志。 取值范围: 不涉及。 最小长度:1 最大长度:5000 |
demo_fields |
Array of DemoField objects |
参数解释: 根据结构化配置对示例日志进行解析后生成的字段信息。 取值范围: 不涉及。 |
tag_fields |
Array of TagFieldNew objects |
参数解释: 根据日志的上报渠道生成的固有字段信息。 取值范围: 不涉及。 |
rule |
TemplateRule object |
参数解释: 结构化方式。 取值范围: 不涉及。 |
demo_label |
String |
参数解释: 示例日志标签。 取值范围: 不涉及。 |
create_time |
Long |
参数解释: 创建时间。 取值范围: 不涉及。 |
id |
String |
参数解释: 项目ID,获取方式请参见:获取项目ID、获取账号ID、日志组ID、日志流ID。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
field_name |
String |
参数解释: 字段名称。 取值范围: 不能以.和_开头或以.结尾, 只能包含字母、英文、数字、中划线、下划线(_)、小数点(.),长度最大为64。 |
content |
String |
参数解释: 字段示例内容。 取值范围: 不涉及。 |
type |
String |
参数解释: 字段数据类型。 可选范围:string、long、float。 取值范围: 取String、Float、Long类型。 |
is_analysis |
Boolean |
参数解释: 是否开启快速分析。如果配置了索引配置,则以索引配置的快速分析开关为准。 取值范围: 不涉及。 |
index |
Integer |
参数解释: 正则分析以及分隔符方式中的字段序号。 取值范围: 不涉及。 |
relation |
String |
参数解释: 描述多层级json中字段间的层级关系。 取值范围: 不涉及。 |
user_defined_name |
String |
参数解释: json及nginx方式中字段的自定义别名。 取值范围: 不能以.和_开头或以.结尾, 只能包含字母、英文、数字、中划线、下划线(_)、小数点(.),长度最大为64。 |
参数 |
参数类型 |
描述 |
---|---|---|
field_name |
String |
参数解释: 字段名称。 取值范围: 不能以.和_开头或以.结尾, 只能包含字母、英文、数字、中划线、下划线(_)、小数点(.),长度最大为64。 |
content |
String |
参数解释: 字段示例内容。 取值范围: 不涉及。 |
type |
String |
参数解释: 字段类型。 取值范围: 取String、Float、Long类型。 |
is_analysis |
Boolean |
参数解释: 是否开启快速分析。如果配置了索引配置,则以索引配置的快速分析开关为准。 取值范围: 不涉及。 |
index |
Integer |
参数解释: 字段序号。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
type |
String |
参数解释: 结构化方式。 取值范围: regex、json、split、nginx、built_in或custom_regex。 |
param |
String |
参数解释: 结构化参数。 响应body体参数rule(TemplateRule)中的参数type的值为build_int时,该参数的值为系统模板名称。 |
状态码:500
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
参数解释: 错误码。 取值范围: 不涉及。 |
error_msg |
String |
参数解释: 调用失败响应信息描述。 取值范围: 不涉及。 |
请求示例
查询当前结构化模板详情。
GET https://{endpoint}/v3/{project_id}//v3/{project_id}/lts/struct/customtemplate /v3/{project_id}/lts/struct/customtemplate
响应示例
状态码:200
请求响应成功。
{
"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测试",
"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测试 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"
} ]
}
状态码:500
表明服务端能被请求访问到,但是服务内部出错。
{
"error_code" : "LTS.2017",
"error_msg" : "Find struct template failed."
}
状态码
状态码 |
描述 |
---|---|
200 |
请求响应成功。 |
500 |
表明服务端能被请求访问到,但是服务内部出错。 |
错误码
请参见错误码。