查询日志接入
功能介绍
查询日志接入列表。通过该接口可对日志接入数据进行梳理,不仅能完整展示接入日志的详细列表,还支持依据多种维度进行灵活筛选,让您快速获取所需数据,极大提高了日志接入信息的查询效率。
调用方法
请参见如何调用API。
URI
POST /v3/{project_id}/lts/access-config-list
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
参数解释: 项目ID,可以从调用API处获取,也可以从控制台获取。获取方式请参见:获取项目ID。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
参数解释: 从IAM服务获取的用户Token,获取方式请参见:获取用户Token。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
Content-Type |
是 |
String |
参数解释: 用于定义消息体的格式,该字段填为:application/json;charset=utf8。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
access_config_name_list |
否 |
Array of strings |
参数解释: 日志接入配置名称列表。 约束限制: 不涉及。 |
host_group_name_list |
否 |
Array of strings |
参数解释: 主机组名称列表。 约束限制: 不涉及。 |
log_group_name_list |
否 |
Array of strings |
参数解释: 日志组名称列表。 约束限制: 不涉及。 |
log_stream_name_list |
否 |
Array of strings |
参数解释: 日志流名称列表。 约束限制: 不涉及。 |
access_config_tag_list |
否 |
Array of accessConfigTag objects |
参数解释: 日志接入配置标签信息。以键值对(key-value)的形式表示,其中key表示标签键,标签键不能重复,value表示标签值。例如:{"env": "test"}。 约束限制: 最多支持20个标签。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
key |
否 |
String |
参数解释: 标签键。 约束限制:
取值范围:
默认取值: 不涉及。 |
value |
否 |
String |
参数解释: 标签值。 约束限制: 标签是以键值对(key-value)的形式表示,key和value为一一对应关系。 取值范围:
默认取值: 不涉及。 |
响应参数
状态码:200
参数 |
参数类型 |
描述 |
---|---|---|
result |
Array of AccessConfigInfo objects |
参数解释: 日志接入配置信息列表 取值范围: 不涉及。 |
total |
Long |
参数解释: 日志接入配置信息的数量。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
access_config_id |
String |
参数解释: 日志接入配置ID。 取值范围: 不涉及。 |
access_config_name |
String |
参数解释: 日志接入配置名称。 取值范围: 不涉及。 |
access_config_type |
String |
参数解释: 日志接入配置类型。 取值范围:
|
create_time |
Long |
参数解释: 日志接入配置的创建时间。 取值范围: 不涉及。 |
access_config_detail |
AccessConfigDeatilCreate object |
参数解释: 日志接入配置的详细信息。 |
log_info |
AccessConfigQueryLogInfo object |
参数解释: 日志接入配置的日志流详情。 |
host_group_info |
AccessConfigHostGroupIdList object |
参数解释: 日志接入配置的主机组ID列表。 |
access_config_tag |
Array of accessConfigTag objects |
参数解释: 日志接入配置的标签信息。 |
log_split |
Boolean |
参数解释: 是否拆分日志。 取值范围:
|
binary_collect |
Boolean |
参数解释: 是否采集二进制数据。 取值范围:
|
cluster_id |
String |
参数解释: CCE集群ID。 取值范围: 不涉及。 |
encoding_format |
String |
参数解释: 编码格式,默认UTF-8。 取值范围: 不涉及。 |
incremental_collect |
Boolean |
参数解释: 是否进行增量采集。 取值范围: true:采集新增日志数据。 false:采集全量日志数据。 |
processor_type |
String |
参数解释: ICAgent结构化解析类型。 取值范围:
|
demo_log |
String |
参数解释: 示例日志。 取值范围: 不涉及。 |
demo_fields |
Array of DemoFieldAccess objects |
参数解释: 示例日志解析字段。 |
processors |
Array of Processor objects |
参数解释: ICAgent结构化解析器。 |
log_split_size |
Integer |
参数解释: 拆分日志大小。 取值范围: 不涉及。 |
application_id |
String |
参数解释: ServiceStage应用ID。 取值范围: 不涉及。 |
environment_id |
String |
参数解释: ServiceStage环境ID。 取值范围: 不涉及。 |
component_id |
Array of strings |
参数解释: ServiceStage组件ID列表。 |
recursive_depth |
Integer |
参数解释: 采集路径递归最大深度。 取值范围: 不涉及。 |
access_config_type_source |
String |
参数解释: 日志接入自建软件来源。 取值范围:
|
参数 |
参数类型 |
描述 |
---|---|---|
paths |
Array of strings |
参数解释: 采集路径。
|
black_paths |
Array of strings |
参数解释: 采集黑名单路径。
|
format |
AccessConfigFormatCreate object |
参数解释: 日志格式相关信息。 |
windows_log_info |
参数解释: 日志接入配置Windows事件日志相关信息。 |
|
stdout |
Boolean |
参数解释: 云容器引擎CCE应用日志接入时,是否开启采集容器标准输出。 取值范围:
|
stderr |
Boolean |
参数解释: 云容器引擎CCE应用日志接入时,是否开启采集容器标准错误。 取值范围:
|
pathType |
String |
参数解释: 数据源类型。仅云容器引擎CCE应用日志接入支持。 取值范围:
|
namespaceRegex |
String |
参数解释: K8s Namespace正则匹配。通过Namespace名称指定采集的容器,支持正则匹配。采集名称符合正则规则的Namespace的日志,为空时采集所有Namespace的日志。 仅云容器引擎CCE应用日志接入支持。 取值范围: 不涉及。 |
podNameRegex |
String |
参数解释: K8s Pod正则匹配。通过Pod名称指定待采集的容器,支持正则匹配。采集名称符合正则规则的Pod的日志,为空时采集所有Pod的日志。 仅云容器引擎CCE应用日志接入支持。 取值范围: 不涉及。 |
containerNameRegex |
String |
参数解释: K8s容器名称正则匹配。通过容器名称指定待采集的容器(Kubernetes容器名称是定义在spec.containers中),支持正则匹配。采集名称符合正则规则的容器的日志,为空时采集所有容器的日志。 仅云容器引擎CCE应用日志接入支持。 取值范围: 不涉及。 |
includeLabels |
Map<String,String> |
参数解释: 容器Label白名单,云容器引擎CCE应用日志接入时,可通过容器Label白名单指定待采集的容器,格式为LabelKey/LabelValue键值对。最多支持创建30个。
若LabelValue为空,则容器 Label中包含LabelKey的容器都匹配;若LabelValue不为空,则容器 Label中包含LabelKey=LabelValue的容器才匹配;LabelKey需要全匹配,LabelValue支持正则匹配。 |
excludeLabels |
Map<String,String> |
参数解释: 容器Label黑名单,云容器引擎CCE应用日志接入时,可通过容器Label黑名单排除不采集的容器,格式为LabelKey/LabelValue键值对。最多支持创建30个。
若LabelValue为空,则容器 Label中包含LabelKey的容器都被排除;若LabelValue不为空,则容器 Label中包含LabelKey=LabelValue的容器才会被排除;LabelKey需要全匹配,LabelValue支持正则匹配。 |
includeEnvs |
Map<String,String> |
参数解释: 环境变量白名单,云容器引擎CCE应用日志接入时,可通过环境变量白名单指定待采集的容器,格式为LabelKey/LabelValue键值对。最多支持创建30个。
若LabelValue为空,则容器 Label中包含LabelKey的容器都匹配;若LabelValue不为空,则容器 Label中包含LabelKey=LabelValue的容器才匹配;LabelKey需要全匹配,LabelValue支持正则匹配。 |
excludeEnvs |
Map<String,String> |
参数解释: 环境变量黑名单,云容器引擎CCE应用日志接入时,可通过环境变量黑名单排除不采集的容器,格式为LabelKey/LabelValue键值对。最多支持创建30个。
若LabelValue为空,则容器 Label中包含LabelKey的容器都被排除;若LabelValue不为空,则容器 Label中包含LabelKey=LabelValue的容器才会被排除;LabelKey需要全匹配,LabelValue支持正则匹配。 |
logLabels |
Map<String,String> |
参数解释: 容器 Label日志标签,云容器引擎CCE应用日志接入时,可通过该参数在日志中新增容器Label相关字段。例如:设置LabelKey为app,设置LabelValue为app_alias,当容器中包含app=lts时,将在日志中添加内容{app_alias:lts}。 |
logEnvs |
Map<String,String> |
参数解释: 环境变量日志标签,云容器引擎CCE应用日志接入时,可通过该参数在日志中新增环境变量相关字段。例如:设置环境变量Key为app,设置环境变量Value为app_alias,当K8S中包含环境变量app=lts时,将在日志中添加的内容为{app_alias:lts}。 |
includeK8sLabels |
Map<String,String> |
参数解释: K8s Label白名单,云容器引擎CCE应用日志接入时,可通过K8s Label白名单指定待采集的容器,格式为LabelKey/LabelValue键值对。最多支持创建30个。
若LabelValue为空,则容器 Label中包含LabelKey的容器都匹配;若LabelValue不为空,则容器 Label中包含LabelKey=LabelValue的容器才匹配;LabelKey需要全匹配,LabelValue支持正则匹配。 |
excludeK8sLabels |
Map<String,String> |
参数解释: K8s Label黑名单,云容器引擎CCE应用日志接入时,可通过K8s Label黑名单排除不采集的容器,格式为LabelKey/LabelValue键值对。最多支持创建30个。
若LabelValue为空,则容器 Label中包含LabelKey的容器都被排除;若LabelValue不为空,则容器 Label中包含LabelKey=LabelValue的容器才会被排除;LabelKey需要全匹配,LabelValue支持正则匹配。 |
logK8s |
Map<String,String> |
参数解释: K8s Label日志标签,云容器引擎CCE应用日志接入时,可通过该参数在日志中新增K8s Label相关字段。例如:设置LabelKey为app,设置LabelValue为app_alias,当容器中包含app=lts时,将在日志中添加内容{app_alias:lts}。 |
repeat_collect |
Boolean |
参数解释: 是否允许多次采集。 取值范围:
|
system_fields |
Array of strings |
参数解释: 系统内置字段。配置日志接入规则时,可以配置系统内置字段,上报日志后,每条日志数据的标签数据中将会有系统字段。若修改该字段,将覆盖原有配置。
|
custom_key_value |
Map<String,String> |
参数解释: 自定义键值对,格式为Key/Value键值对。配置日志接入规则时,可以配置自定义键值对规则,上报日志后,每条日志数据的标签数据中将会有用户自定义的键值对字段。最多支持创建20个。若修改该字段,将覆盖原有配置。
|
includeLabelsLogical |
String |
参数解释: 容器 Label白名单生效逻辑,默认为OR。新增多条白名单时,支持选择AND或OR的关系,即全部满足或满足任意白名单就可以被匹配。 取值范围:
|
excludeLabelsLogical |
String |
参数解释: 容器 Label黑名单生效逻辑,默认为OR。新增多条黑名单时,支持选择AND或OR的关系,即全部满足或满足任意黑名单就可以被匹配。 取值范围:
|
includeK8sLabelsLogical |
String |
参数解释: K8S Label白名单生效逻辑,默认为OR。新增多条白名单时,支持选择AND或OR的关系,即全部满足或满足任意白名单就可以被匹配。 取值范围:
|
excludeK8sLabelsLogical |
String |
参数解释: K8S Label黑名单生效逻辑,默认为OR。新增多条黑名单时,支持选择AND或OR的关系,即全部满足或满足任意黑名单就可以被匹配。 取值范围:
|
includeEnvsLogical |
String |
参数解释: 环境变量白名单生效逻辑,默认为OR。新增多条白名单时,支持选择AND或OR的关系,即全部满足或满足任意白名单就可以被匹配。 取值范围:
|
excludeEnvsLogical |
String |
参数解释: 环境变量黑名单生效逻辑,默认为OR。新增多条黑名单时,支持选择AND或OR的关系,即全部满足或满足任意黑名单就可以被匹配。 取值范围:
|
参数 |
参数类型 |
描述 |
---|---|---|
single |
参数解释: 单行日志,每一行日志在LTS界面中都显示为一条单独的日志数据。 |
|
multi |
参数解释: 多行日志,日志在LTS界面中多行日志显示为一条日志。 |
参数 |
参数类型 |
描述 |
---|---|---|
mode |
String |
参数解释: 单行日志采集模式。 取值范围:
|
value |
String |
参数解释: 日志时间。
取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
mode |
String |
参数解释: 多行日志采集模式。 取值范围:
|
value |
String |
参数解释: 日志时间。
取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
categorys |
Array of strings |
参数解释: 采集Windows事件日志类型。有以下四种类型:
|
time_offset |
AccessConfigTimeOffset object |
参数解释: 首次采集时间偏移量信息,用于修正时间偏差或计算相对时间。例如设置为7天,表示从采集开始时间前7天内的日志(7天前的日志被忽略),该时间仅在首次配置采集生效,确保不会重复采集。 |
event_level |
Array of strings |
参数解释: 事件等级,根据Windows事件等级过滤采集。仅支持Windows Vista及以上的操作系统。有以下五种等级:
|
参数 |
参数类型 |
描述 |
---|---|---|
offset |
Long |
参数解释: 具体的偏移时间。
取值范围: 不涉及。 |
unit |
String |
参数解释: 具体的偏移时间单位。
取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
log_group_id |
String |
参数解释: 日志组ID。 取值范围: 不涉及。 |
log_stream_id |
String |
参数解释: 日志流ID。 取值范围: 不涉及。 |
log_group_name |
String |
参数解释: 日志组名称。 取值范围: 不涉及。 |
log_stream_name |
String |
参数解释: 日志流名称。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
key |
String |
参数解释: 标签键。 约束限制:
取值范围:
默认取值: 不涉及。 |
value |
String |
参数解释: 标签值。 约束限制: 标签是以键值对(key-value)的形式表示,key和value为一一对应关系。 取值范围:
默认取值: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
field_name |
String |
参数解释: 示例日志解析字段。 取值范围: 不涉及。 |
field_value |
String |
参数解释: 示例日志的字段的值。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
type |
String |
参数解释: 结构化解析类型,有以下七种:
取值范围: 不涉及。 |
detail |
Detail object |
参数解释: 结构化解析配置的相关信息。 |
参数 |
参数类型 |
描述 |
---|---|---|
source_key |
String |
参数解释: 原始字段。日志结构化解析前,用于存放日志内容的原始字段,默认值为content。 取值范围: 不涉及。 |
regex |
String |
参数解释: 正则表达式。用于匹配日志的正则表达式。 取值范围: 不涉及。 |
keys |
Array of strings |
参数解释: 已提取字段名称。为提取的日志内容设置对应的字段名。 |
multi_line_regex |
String |
参数解释: 首行正则表达式。 取值范围: 不涉及。 |
keep_source |
Boolean |
参数解释: 是否上传原始日志。 取值范围: true:保留原始日志。 false:不保留原始日志。 |
keep_source_if_parse_error |
Boolean |
参数解释: 是否上传解析失败日志。 取值范围: true:上传解析失败日志。 false:不上传解析失败日志。 |
split_sep |
String |
参数解释: 分隔符。根据日志内容选择正确的分隔符,例如竖线(|)。 取值范围: 不涉及 |
split_type |
String |
参数解释: 分隔类型,支持char-单字符、special_char-不可见字符、string-字符串。 取值范围: 不涉及。 |
fields |
Map<String,String> |
参数解释: 待添加的字段名和字段值,格式为Key/Value键值对。支持添加多个。 |
drop_keys |
Array of strings |
参数解释: 丢弃的字段列表。 |
source_keys |
Array of strings |
参数解释: 待重命名的原始字段。 |
dest_keys |
Array of strings |
参数解释: 重命名后的字段。 |
expand_depth |
Integer |
参数解释: json展开的深度。默认值为0,表示不限制。1表示当前层级,以此类推。 取值范围: 不涉及。 |
expand_connector |
String |
参数解释: json展开时的连接符,默认值为英文符号点(.)。 取值范围: 不涉及。 |
source_format |
String |
参数解释: 原始时间的格式。 取值范围: 不涉及。 |
source_value |
String |
参数解释: 原始时间字段value。 取值范围: 不涉及。 |
set_time |
Boolean |
参数解释: 是否将解析后的时间设置为日志时间。 取值范围: 不涉及。 |
include |
Map<String,String> |
参数解释: 日志过滤白名单规则,格式为Key/Value键值对。Key为日志字段,key不可以重复,长度最大为256个字符。Value为匹配的正则表达式。 |
exclude |
Map<String,String> |
参数解释: 日志过滤黑名单规则,格式为Key/Value键值对。Key为日志字段,key不可以重复,长度最大为256个字符。Value为匹配的正则表达式。 |
状态码:400
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
参数解释: 错误码,请参见:错误码。 取值范围: 不涉及。 |
error_msg |
String |
参数解释: 调用失败响应信息描述。 取值范围: 不涉及。 |
状态码:500
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
参数解释: 错误码,请参见:错误码。 取值范围: 不涉及。 |
error_msg |
String |
参数解释: 调用失败响应信息描述。 取值范围: 不涉及。 |
请求示例
查询日志接入信息,根据传入的Body体进行过滤。
POST https://{endpoint}/v3/{project_id}/lts/access-config-list
{
"access_config_name_list" : [ "采xx2", "22x", "2x", "采集Wjxxxx" ],
"host_group_name_list" : [ "wwxx" ],
"log_group_name_list" : [ "lts-grxx", "lts-xx", "lts-gxx" ],
"log_stream_name_list" : [ "lts-topixx", "lts-txx" ],
"access_config_tag_list" : [ {
"key" : "xxx",
"value" : "xxx"
}, {
"key" : "xxx1",
"value" : "xxx1"
} ]
}
响应示例
状态码:200
查询日志接入列表请求响应成功。
{
"result" : [ {
"access_config_detail" : {
"containerNameRegex" : "my",
"excludeEnvs" : {
"h" : "8"
},
"excludeK8sLabels" : {
"e" : "5"
},
"excludeLabels" : {
"b" : "2"
},
"format" : {
"single" : {
"mode" : "system",
"value" : "1678969382000"
}
},
"includeEnvs" : {
"g" : "7"
},
"includeK8sLabels" : {
"d30" : "4"
},
"includeLabels" : {
"a" : "1"
},
"logEnvs" : {
"i" : "9"
},
"logK8s" : {
"f" : "6"
},
"logLabels" : {
"c" : "3"
},
"namespaceRegex" : "default",
"pathType" : "container_stdout",
"paths" : [ ],
"podNameRegex" : "abc",
"stderr" : false,
"stdout" : true
},
"access_config_id" : "c3152f88-8b06-4f7f-bbbe-129512f49f87",
"access_config_name" : "myapinew322",
"access_config_tag" : [ {
"key" : "my01",
"value" : "001"
}, {
"key" : "my02",
"value" : "002"
} ],
"access_config_type" : "K8S_CCE",
"binary_collect" : false,
"create_time" : 1684467787996,
"host_group_info" : {
"host_group_id_list" : [ "12b0bbd1-4eda-456b-a641-647aa66bdeab" ]
},
"log_info" : {
"log_group_id" : "9575cb24-290c-478e-a5db-88d6d1dc513b",
"log_group_name" : "my-group",
"log_stream_id" : "3581bee9-8698-476e-a0ba-b0f310ed99cf",
"log_stream_name" : "lts-topic-api"
},
"log_split" : false
}, {
"access_config_detail" : {
"containerNameRegex" : "my",
"excludeEnvs" : {
"h" : "8"
},
"excludeK8sLabels" : {
"e" : "5"
},
"excludeLabels" : {
"b" : "2"
},
"format" : {
"single" : {
"mode" : "system",
"value" : "1678969382000"
}
},
"includeEnvs" : {
"g" : "7"
},
"includeK8sLabels" : {
"d10" : "4",
"d" : "4",
"d12" : "4",
"d11" : "4",
"d14" : "4",
"d13" : "4",
"d16" : "4",
"d15" : "4",
"d18" : "4",
"d17" : "4",
"d1" : "4",
"d2" : "4",
"d3" : "4",
"d4" : "4",
"d5" : "4",
"d6" : "4",
"d7" : "4",
"d8" : "4",
"d9" : "4"
},
"includeLabels" : {
"a" : "1"
},
"logEnvs" : {
"i" : "9"
},
"logK8s" : {
"f" : "6"
},
"logLabels" : {
"c" : "3"
},
"namespaceRegex" : "default",
"pathType" : "container_stdout",
"paths" : [ ],
"podNameRegex" : "abc",
"stderr" : false,
"stdout" : true
},
"access_config_id" : "550cd738-7b16-4724-9c59-aba61bf16528",
"access_config_name" : "myapinew32",
"access_config_tag" : [ {
"key" : "my01",
"value" : "001"
}, {
"key" : "my02",
"value" : "002"
} ],
"access_config_type" : "K8S_CCE",
"binary_collect" : false,
"create_time" : 1684463134956,
"host_group_info" : {
"host_group_id_list" : [ "12b0bbd1-4eda-456b-a641-647aa66bdeab" ]
},
"log_info" : {
"log_group_id" : "9575cb24-290c-478e-a5db-88d6d1dc513b",
"log_group_name" : "my-group",
"log_stream_id" : "3581bee9-8698-476e-a0ba-b0f310ed99cf",
"log_stream_name" : "lts-topic-api"
},
"log_split" : false
} ],
"total" : 2
}
状态码:400
非法请求,建议根据error_msg直接修改该请求。
{
"error_code" : "LTS.1807",
"error_msg" : "Invalid access config name"
}
状态码:500
表明服务端能被请求访问到,但是服务内部出错。
{
"error_code" : "LTS.0010",
"error_msg" : "The system encountered an internal error"
}
SDK代码示例
SDK代码示例如下。
查询日志接入信息,根据传入的Body体进行过滤。
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
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.*;
import java.util.List;
import java.util.ArrayList;
public class ListAccessConfigSolution {
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();
ListAccessConfigRequest request = new ListAccessConfigRequest();
GetAccessConfigListRequestBody body = new GetAccessConfigListRequestBody();
List<AccessConfigTag> listbodyAccessConfigTagList = new ArrayList<>();
listbodyAccessConfigTagList.add(
new AccessConfigTag()
.withKey("xxx")
.withValue("xxx")
);
listbodyAccessConfigTagList.add(
new AccessConfigTag()
.withKey("xxx1")
.withValue("xxx1")
);
List<String> listbodyLogStreamNameList = new ArrayList<>();
listbodyLogStreamNameList.add("lts-topixx");
listbodyLogStreamNameList.add("lts-txx");
List<String> listbodyLogGroupNameList = new ArrayList<>();
listbodyLogGroupNameList.add("lts-grxx");
listbodyLogGroupNameList.add("lts-xx");
listbodyLogGroupNameList.add("lts-gxx");
List<String> listbodyHostGroupNameList = new ArrayList<>();
listbodyHostGroupNameList.add("wwxx");
List<String> listbodyAccessConfigNameList = new ArrayList<>();
listbodyAccessConfigNameList.add("采xx2");
listbodyAccessConfigNameList.add("22x");
listbodyAccessConfigNameList.add("2x");
listbodyAccessConfigNameList.add("采集Wjxxxx");
body.withAccessConfigTagList(listbodyAccessConfigTagList);
body.withLogStreamNameList(listbodyLogStreamNameList);
body.withLogGroupNameList(listbodyLogGroupNameList);
body.withHostGroupNameList(listbodyHostGroupNameList);
body.withAccessConfigNameList(listbodyAccessConfigNameList);
request.withBody(body);
try {
ListAccessConfigResponse response = client.listAccessConfig(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());
}
}
}
|
查询日志接入信息,根据传入的Body体进行过滤。
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# 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 = ListAccessConfigRequest()
listAccessConfigTagListbody = [
AccessConfigTag(
key="xxx",
value="xxx"
),
AccessConfigTag(
key="xxx1",
value="xxx1"
)
]
listLogStreamNameListbody = [
"lts-topixx",
"lts-txx"
]
listLogGroupNameListbody = [
"lts-grxx",
"lts-xx",
"lts-gxx"
]
listHostGroupNameListbody = [
"wwxx"
]
listAccessConfigNameListbody = [
"采xx2",
"22x",
"2x",
"采集Wjxxxx"
]
request.body = GetAccessConfigListRequestBody(
access_config_tag_list=listAccessConfigTagListbody,
log_stream_name_list=listLogStreamNameListbody,
log_group_name_list=listLogGroupNameListbody,
host_group_name_list=listHostGroupNameListbody,
access_config_name_list=listAccessConfigNameListbody
)
response = client.list_access_config(request)
print(response)
except exceptions.ClientRequestException as e:
print(e.status_code)
print(e.request_id)
print(e.error_code)
print(e.error_msg)
|
查询日志接入信息,根据传入的Body体进行过滤。
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
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.ListAccessConfigRequest{}
keyAccessConfigTagList:= "xxx"
valueAccessConfigTagList:= "xxx"
keyAccessConfigTagList1:= "xxx1"
valueAccessConfigTagList1:= "xxx1"
var listAccessConfigTagListbody = []model.AccessConfigTag{
{
Key: &keyAccessConfigTagList,
Value: &valueAccessConfigTagList,
},
{
Key: &keyAccessConfigTagList1,
Value: &valueAccessConfigTagList1,
},
}
var listLogStreamNameListbody = []string{
"lts-topixx",
"lts-txx",
}
var listLogGroupNameListbody = []string{
"lts-grxx",
"lts-xx",
"lts-gxx",
}
var listHostGroupNameListbody = []string{
"wwxx",
}
var listAccessConfigNameListbody = []string{
"采xx2",
"22x",
"2x",
"采集Wjxxxx",
}
request.Body = &model.GetAccessConfigListRequestBody{
AccessConfigTagList: &listAccessConfigTagListbody,
LogStreamNameList: &listLogStreamNameListbody,
LogGroupNameList: &listLogGroupNameListbody,
HostGroupNameList: &listHostGroupNameListbody,
AccessConfigNameList: &listAccessConfigNameListbody,
}
response, err := client.ListAccessConfig(request)
if err == nil {
fmt.Printf("%+v\n", response)
} else {
fmt.Println(err)
}
}
|
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
查询日志接入信息,根据传入的Body体进行过滤。
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
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.*;
import java.util.List;
import java.util.ArrayList;
public class ListAccessConfigSolution {
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();
ListAccessConfigRequest request = new ListAccessConfigRequest();
GetAccessConfigListRequestBody body = new GetAccessConfigListRequestBody();
List<AccessConfigTag> listbodyAccessConfigTagList = new ArrayList<>();
listbodyAccessConfigTagList.add(
new AccessConfigTag()
.withKey("xxx")
.withValue("xxx")
);
listbodyAccessConfigTagList.add(
new AccessConfigTag()
.withKey("xxx1")
.withValue("xxx1")
);
List<String> listbodyLogStreamNameList = new ArrayList<>();
listbodyLogStreamNameList.add("lts-topixx");
listbodyLogStreamNameList.add("lts-txx");
List<String> listbodyLogGroupNameList = new ArrayList<>();
listbodyLogGroupNameList.add("lts-grxx");
listbodyLogGroupNameList.add("lts-xx");
listbodyLogGroupNameList.add("lts-gxx");
List<String> listbodyHostGroupNameList = new ArrayList<>();
listbodyHostGroupNameList.add("wwxx");
List<String> listbodyAccessConfigNameList = new ArrayList<>();
listbodyAccessConfigNameList.add("采xx2");
listbodyAccessConfigNameList.add("22x");
listbodyAccessConfigNameList.add("2x");
listbodyAccessConfigNameList.add("采集Wjxxxx");
body.withAccessConfigTagList(listbodyAccessConfigTagList);
body.withLogStreamNameList(listbodyLogStreamNameList);
body.withLogGroupNameList(listbodyLogGroupNameList);
body.withHostGroupNameList(listbodyHostGroupNameList);
body.withAccessConfigNameList(listbodyAccessConfigNameList);
request.withBody(body);
try {
ListAccessConfigResponse response = client.listAccessConfig(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());
}
}
}
|
查询日志接入信息,根据传入的Body体进行过滤。
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# 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 = ListAccessConfigRequest()
listAccessConfigTagListbody = [
AccessConfigTag(
key="xxx",
value="xxx"
),
AccessConfigTag(
key="xxx1",
value="xxx1"
)
]
listLogStreamNameListbody = [
"lts-topixx",
"lts-txx"
]
listLogGroupNameListbody = [
"lts-grxx",
"lts-xx",
"lts-gxx"
]
listHostGroupNameListbody = [
"wwxx"
]
listAccessConfigNameListbody = [
"采xx2",
"22x",
"2x",
"采集Wjxxxx"
]
request.body = GetAccessConfigListRequestBody(
access_config_tag_list=listAccessConfigTagListbody,
log_stream_name_list=listLogStreamNameListbody,
log_group_name_list=listLogGroupNameListbody,
host_group_name_list=listHostGroupNameListbody,
access_config_name_list=listAccessConfigNameListbody
)
response = client.list_access_config(request)
print(response)
except exceptions.ClientRequestException as e:
print(e.status_code)
print(e.request_id)
print(e.error_code)
print(e.error_msg)
|
查询日志接入信息,根据传入的Body体进行过滤。
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
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.ListAccessConfigRequest{}
keyAccessConfigTagList:= "xxx"
valueAccessConfigTagList:= "xxx"
keyAccessConfigTagList1:= "xxx1"
valueAccessConfigTagList1:= "xxx1"
var listAccessConfigTagListbody = []model.AccessConfigTag{
{
Key: &keyAccessConfigTagList,
Value: &valueAccessConfigTagList,
},
{
Key: &keyAccessConfigTagList1,
Value: &valueAccessConfigTagList1,
},
}
var listLogStreamNameListbody = []string{
"lts-topixx",
"lts-txx",
}
var listLogGroupNameListbody = []string{
"lts-grxx",
"lts-xx",
"lts-gxx",
}
var listHostGroupNameListbody = []string{
"wwxx",
}
var listAccessConfigNameListbody = []string{
"采xx2",
"22x",
"2x",
"采集Wjxxxx",
}
request.Body = &model.GetAccessConfigListRequestBody{
AccessConfigTagList: &listAccessConfigTagListbody,
LogStreamNameList: &listLogStreamNameListbody,
LogGroupNameList: &listLogGroupNameListbody,
HostGroupNameList: &listHostGroupNameListbody,
AccessConfigNameList: &listAccessConfigNameListbody,
}
response, err := client.ListAccessConfig(request)
if err == nil {
fmt.Printf("%+v\n", response)
} else {
fmt.Println(err)
}
}
|
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
查询日志接入列表请求响应成功。 |
400 |
非法请求,建议根据error_msg直接修改该请求。 |
500 |
表明服务端能被请求访问到,但是服务内部出错。 |
错误码
请参见错误码。