查询日志流索引
功能介绍
查询日志流索引。
调用方法
请参见如何调用API。
URI
GET /v1.0/{project_id}/groups/{group_id}/stream/{stream_id}/index/config
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
项目ID,获取方式请参见:获取项目ID,获取账号ID,日志组ID、日志流ID 最小长度:32 最大长度:32 |
group_id |
是 |
String |
日志组ID,获取方式请参见:获取项目ID,获取账号ID,日志组ID、日志流ID 最小长度:36 最大长度:36 |
stream_id |
是 |
String |
日志流ID,获取方式请参见:获取项目ID,获取账号ID,日志组ID、日志流ID 最小长度:36 最大长度:36 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
参数解释: 从IAM服务获取的用户Token,获取方式请参见:获取用户Token。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
Content-Type |
是 |
String |
参数解释: 用于定义消息体的格式,该字段填为:application/json;charset=utf8。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
响应参数
状态码:200
参数 |
参数类型 |
描述 |
---|---|---|
fullTextIndex |
LTSFullTextIndexInfo object |
全文索引配置 |
fields |
Array of LTSFieldsInfo objects |
字段索引配置 |
logStreamId |
String |
日志流id |
参数 |
参数类型 |
描述 |
---|---|---|
enable |
Boolean |
参数解释: 是否开启全文索引配置。 约束限制: 不涉及。 取值范围: true:开启全文索引配置。 false:不开启全文索引配置。 默认取值: true |
caseSensitive |
Boolean |
参数解释: 开启全文索引配置时,是否区分英文字母的大小写。 约束限制: 不涉及。 取值范围: true:区分英文字母大小写。 false:不区分英文字母大小写。 默认取值: false |
includeChinese |
Boolean |
参数解释: 开启全文索引配置时,是否包含中文。 约束限制: 不涉及。 取值范围: true:包含中文。 false:不包含中文。 默认取值: false |
tokenizer |
String |
参数解释: 分词符。根据指定分词符,将日志内容拆分成多个词;当默认设置不能满足需求时,可以自定义设置分词符。 约束限制: 不涉及。 取值范围: 最小长度:0 最大长度:128 默认取值: , '";=()[]{}@&<>/:\n\t\r |
ascii |
Array of strings |
参数解释: 特殊分词符,参考ASCII码对照表输入ASCII值和控制字符。 约束限制: 不涉及。 取值范围: 最小长度:1 最大长度:3 默认取值: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
fieldType |
String |
参数解释: 字段索引配置时,日志的字段类型。 约束限制: 不涉及。 取值范围:
默认取值: string |
fieldName |
String |
参数解释: 字段索引配置时,日志的字段名称。 约束限制:
取值范围: 示例日志中的字段。 默认取值: 不涉及。 |
caseSensitive |
Boolean |
参数解释: 字段索引配置时,是否开启大小写。 约束限制: 不涉及。 取值范围:
默认取值: false |
includeChinese |
Boolean |
参数解释: 字段索引配置时,是否包含中文。 约束限制: 不涉及。 取值范围:
默认取值: false |
tokenizer |
String |
参数解释: 自定义分词符。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: , '";=()[]{}@&<>/:\?\n\t\r |
quickAnalysis |
Boolean |
参数解释: 字段索引配置时,是否开启快速分析。 约束限制:
取值范围: 默认取值: true |
ascii |
Array of strings |
参数解释: 特殊分词符。 约束限制: 不涉及。 |
ltsSubFieldsInfoList |
Array of LTSSubFieldsInfo objects |
参数解释: 字段索引配置中字段类型为json时的字段信息。 约束限制: 不涉及。 |
fieldAnalysisAlias |
String |
参数解释: 别名,设置别名后,只支持使用别名进行SQL搜索分析,不支持使用别名进行关键字搜索。 约束限制: 不涉及。 取值范围: 长度不能大于256。 默认取值: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
fieldType |
String |
参数解释: 字段索引配置时,日志的字段类型。 约束限制: 不涉及。 取值范围:
默认取值: string |
fieldName |
String |
参数解释: 字段索引配置时,日志的字段名称。 约束限制:
取值范围: 示例日志中的字段。 默认取值: 不涉及。 |
quickAnalysis |
Boolean |
参数解释: 字段索引配置时,是否开启快速分析。 约束限制:
取值范围: true:开启快速分析。 false:不开启快速分析。 默认取值: true |
fieldAnalysisAlias |
String |
参数解释: 别名,设置别名后,只支持使用别名进行SQL搜索分析,不支持使用别名进行关键字搜索。 约束限制: 不涉及。 取值范围: 长度不能大于256。 默认取值: 不涉及。 |
状态码:400
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
参数解释: 错误码,请参见:错误码。 取值范围: 不涉及。 |
error_msg |
String |
参数解释: 调用失败响应信息描述。 取值范围: 不涉及。 |
状态码:500
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
参数解释: 错误码,请参见:错误码。 取值范围: 不涉及。 |
error_msg |
String |
参数解释: 调用失败响应信息描述。 取值范围: 不涉及。 |
请求示例
查询当前租户下指定日志流下的索引配置内容。请求参数为路径参数,不提供请求示例。
响应示例
状态码:200
请求响应成功,查询索引配置成功。
{ "logStreamId" : "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "fullTextIndex" : { "ascii" : [ ], "tokenizer" : ", '\";=()[]{}@&<>/:\\n\\t\\r", "enable" : true, "caseSensitive" : true, "includeChinese" : false }, "fields" : [ { "ascii" : [ ], "tokenizer" : ", '\";=()[]{}@&<>/:\\\\?\\n\\t\\r", "fieldName" : "field1", "caseSensitive" : false, "includeChinese" : true, "quickAnalysis" : true, "fieldType" : "string", "ltsSubFieldsInfoList" : null }, { "ascii" : [ ], "tokenizer" : ", '\";=()[]{}@&<>/:\\\\?\\n\\t\\r", "fieldName" : "field2", "caseSensitive" : false, "includeChinese" : true, "quickAnalysis" : true, "fieldType" : "string", "ltsSubFieldsInfoList" : null } ] }
状态码:400
BadRequest。非法请求。 建议根据error_msg直接修改该请求,不要重试该请求。
{ "errorCode" : "SVCSTG.ALS.200201", "errorMessage" : "Query Param is error." }
状态码:500
InternalServerError。 表明服务端能被请求访问到,但是服务内部出错。
{ "error_code" : "LTS.0102", "error_msg" : "Query empty." }
SDK代码示例
SDK代码示例如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
package com.huaweicloud.sdk.test; import com.huaweicloud.sdk.core.auth.ICredential; import com.huaweicloud.sdk.core.auth.BasicCredentials; import com.huaweicloud.sdk.core.exception.ConnectionException; import com.huaweicloud.sdk.core.exception.RequestTimeoutException; import com.huaweicloud.sdk.core.exception.ServiceResponseException; import com.huaweicloud.sdk.lts.v2.region.LtsRegion; import com.huaweicloud.sdk.lts.v2.*; import com.huaweicloud.sdk.lts.v2.model.*; public class ListLogStreamIndexSolution { public static void main(String[] args) { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment String ak = System.getenv("CLOUD_SDK_AK"); String sk = System.getenv("CLOUD_SDK_SK"); String projectId = "{project_id}"; ICredential auth = new BasicCredentials() .withProjectId(projectId) .withAk(ak) .withSk(sk); LtsClient client = LtsClient.newBuilder() .withCredential(auth) .withRegion(LtsRegion.valueOf("<YOUR REGION>")) .build(); ListLogStreamIndexRequest request = new ListLogStreamIndexRequest(); request.withGroupId("{group_id}"); request.withStreamId("{stream_id}"); try { ListLogStreamIndexResponse response = client.listLogStreamIndex(request); System.out.println(response.toString()); } catch (ConnectionException e) { e.printStackTrace(); } catch (RequestTimeoutException e) { e.printStackTrace(); } catch (ServiceResponseException e) { e.printStackTrace(); System.out.println(e.getHttpStatusCode()); System.out.println(e.getRequestId()); System.out.println(e.getErrorCode()); System.out.println(e.getErrorMsg()); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# coding: utf-8 import os from huaweicloudsdkcore.auth.credentials import BasicCredentials from huaweicloudsdklts.v2.region.lts_region import LtsRegion from huaweicloudsdkcore.exceptions import exceptions from huaweicloudsdklts.v2 import * if __name__ == "__main__": # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak = os.environ["CLOUD_SDK_AK"] sk = os.environ["CLOUD_SDK_SK"] projectId = "{project_id}" credentials = BasicCredentials(ak, sk, projectId) client = LtsClient.new_builder() \ .with_credentials(credentials) \ .with_region(LtsRegion.value_of("<YOUR REGION>")) \ .build() try: request = ListLogStreamIndexRequest() request.group_id = "{group_id}" request.stream_id = "{stream_id}" response = client.list_log_stream_index(request) print(response) except exceptions.ClientRequestException as e: print(e.status_code) print(e.request_id) print(e.error_code) print(e.error_msg) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
package main import ( "fmt" "github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic" lts "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/lts/v2" "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/lts/v2/model" region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/lts/v2/region" ) func main() { // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security. // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment ak := os.Getenv("CLOUD_SDK_AK") sk := os.Getenv("CLOUD_SDK_SK") projectId := "{project_id}" auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). WithProjectId(projectId). Build() client := lts.NewLtsClient( lts.LtsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.ListLogStreamIndexRequest{} request.GroupId = "{group_id}" request.StreamId = "{stream_id}" response, err := client.ListLogStreamIndex(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
请求响应成功,查询索引配置成功。 |
400 |
BadRequest。非法请求。 建议根据error_msg直接修改该请求,不要重试该请求。 |
500 |
InternalServerError。 表明服务端能被请求访问到,但是服务内部出错。 |
错误码
请参见错误码。