文档首页/ 云日志服务 LTS/ API参考/ API说明/ 日志流管理/ 查询日志流索引 - ListLogStreamIndex
更新时间:2026-07-07 GMT+08:00
分享

查询日志流索引 - ListLogStreamIndex

功能介绍

查询日志流索引。通过该接口可查询日志流全文索引和字段索引信息。

调用方法

请参见如何调用API

授权信息

账号具备所有API的调用权限,如果使用账号下的IAM用户调用当前API,该IAM用户需具备调用API所需的权限。

  • 如果使用角色与策略授权,具体权限要求请参见权限和授权项
  • 如果使用身份策略授权,需具备如下身份策略权限。

    授权项

    访问级别

    资源类型(*为必须)

    条件键

    别名

    依赖的授权项

    lts:IndexConfig:list

    List

    logStream *

    g:ResourceTag/<tag-key>

    • lts:topics:get
    • lts:groups:get

    -

URI

GET /v1.0/{project_id}/groups/{group_id}/stream/{stream_id}/index/config

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

参数解释:

项目ID,可以从调用API处获取,也可以从控制台获取。获取方式请参见:获取项目ID

约束限制:

不涉及。

取值范围:

不涉及。

默认取值:

不涉及。

group_id

String

参数解释:

日志组ID,获取方式请参见:获取日志组ID和日志流ID

约束限制:

不涉及。

取值范围:

不涉及。

默认取值:

不涉及。

stream_id

String

参数解释:

日志流ID,获取方式请参见:获取日志组ID和日志流ID

约束限制:

不涉及。

取值范围:

不涉及。

默认取值:

不涉及。

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

参数解释:

从IAM服务获取的用户Token,获取方式请参见:获取用户Token

约束限制:

不涉及。

取值范围:

不涉及。

默认取值:

不涉及。

Content-Type

String

参数解释:

用于定义消息体的格式,该字段填为:application/json;charset=utf8。

约束限制:

不涉及。

取值范围:

不涉及。

默认取值:

不涉及。

响应参数

状态码:200

表3 响应Body参数

参数

参数类型

描述

fullTextIndex

LTSFullTextIndexInfoResp object

参数解释:

全文索引配置相关信息。

fields

Array of LTSFieldsInfoResp objects

参数解释:

字段索引配置相关信息。

logStreamId

String

参数解释:

日志流ID。

表4 LTSFullTextIndexInfoResp

参数

参数类型

描述

enable

Boolean

参数解释:

是否开启全文索引配置。

取值范围:

  • true:开启全文索引配置。

  • false:不开启全文索引配置。

caseSensitive

Boolean

参数解释:

开启全文索引配置时,是否区分英文字母的大小写。

取值范围:

  • true:区分英文字母大小写。

  • false:不区分英文字母大小写。

includeChinese

Boolean

参数解释:

开启全文索引配置时,是否包含中文。

取值范围:

  • true:包含中文。

  • false:不包含中文。

tokenizer

String

参数解释:

分词符。根据指定分词符,将日志内容拆分成多个词;当默认设置不能满足需求时,可以自定义设置分词符。

取值范围:

  • 最小长度:0

  • 最大长度:128

ascii

Array of strings

参数解释:

特殊分词符,参考ASCII码对照表输入ASCII值和控制字符。

表5 LTSFieldsInfoResp

参数

参数类型

描述

fieldType

String

参数解释:

字段索引配置时,日志的字段类型。

取值范围:

  • string

  • long

  • float

  • json

fieldName

String

参数解释:

字段索引配置时,日志的字段名称。

取值范围:

示例日志中的字段。

caseSensitive

Boolean

参数解释:

字段索引配置时,是否开启大小写。

取值范围:

  • true:开启大小写。

  • false:不开启大小写。

includeChinese

Boolean

参数解释:

字段索引配置时,是否包含中文。

取值范围:

  • true:包含中文。

  • false:不包含中文。

tokenizer

String

参数解释:

自定义分词符。

quickAnalysis

Boolean

参数解释:

字段索引配置时,是否开启快速分析。

取值范围:

  • true:开启快速分析。

  • false:不开启快速分析。

ascii

Array of strings

参数解释:

特殊分词符。

ltsSubFieldsInfoList

Array of LTSSubFieldsInfoResp objects

参数解释:

字段索引配置中字段类型为json时的字段信息。

fieldAnalysisAlias

String

参数解释:

别名,设置别名后,只支持使用别名进行SQL搜索分析,不支持使用别名进行关键字搜索。

取值范围:

长度不能大于256。

表6 LTSSubFieldsInfoResp

参数

参数类型

描述

fieldType

String

参数解释:

字段索引配置时,日志的字段类型。

取值范围:

  • string

  • long

  • float

fieldName

String

参数解释:

字段索引配置时,日志的字段名称。

取值范围:

示例日志中的字段。

quickAnalysis

Boolean

参数解释:

字段索引配置时,是否开启快速分析。

取值范围:

  • true:开启快速分析。

  • false:不开启快速分析。

fieldAnalysisAlias

String

参数解释:

别名,设置别名后,只支持使用别名进行SQL搜索分析,不支持使用别名进行关键字搜索。

取值范围:

长度不能大于256。

状态码:400

表7 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码,请参见:错误码

取值范围:

不涉及。

error_msg

String

参数解释:

调用失败响应信息描述。

取值范围:

不涉及。

状态码:500

表8 响应Body参数

参数

参数类型

描述

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

非法请求,建议根据error_msg直接修改该请求,不要重试该请求。

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

状态码:500

表明服务端能被请求访问到,但是服务内部出错。

{
  "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
40
41
42
43
44
45
46
47
48
49
50
51
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, err := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        SafeBuild()

    if err != nil {
        fmt.Println(err)
        return
    }

    hcClient, err := lts.LtsClientBuilder().
         WithRegion(region.ValueOf("<YOUR REGION>")).
         WithCredential(auth).
         SafeBuild()


    if err != nil {
        fmt.Println(err)
        return
    }

    client := lts.NewLtsClient(hcClient)

    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

非法请求,建议根据error_msg直接修改该请求,不要重试该请求。

500

表明服务端能被请求访问到,但是服务内部出错。

错误码

请参见错误码

相关文档