修改日志接入
功能介绍
修改日志接入
调用方法
请参见如何调用API。
URI
PUT /v3/{project_id}/lts/access-config
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
项目ID,获取方式请参见:获取账号租户ID、项目资源集ID、日志组ID、日志流ID。 缺省值:None 最小长度:32 最大长度:32 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
从IAM服务获取的用户Token,获取方式请参见:获取用户Token 缺省值:None 最小长度:1000 最大长度:2000 |
Content-Type |
是 |
String |
该字段填为:application/json;charset=UTF-8。 缺省值:None 最小长度:30 最大长度:30 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
access_config_id |
是 |
String |
日志接入ID 最小长度:36 最大长度:36 |
access_config_detail |
否 |
AccessConfigDeatilUpdate object |
日志接入详细信息 |
host_group_info |
否 |
AccessConfigHostGroupIdList object |
日志接入主机组ID列表 |
access_config_tag |
否 |
Array of accessConfigTag objects |
标签信息。KEY不能重复,最多20个标签 |
log_split |
否 |
Boolean |
日志拆分 |
binary_collect |
否 |
Boolean |
二进制采集 |
cluster_id |
否 |
String |
CCE集群ID,CCE类型时,为必填 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
paths |
否 |
Array of strings |
1.路径必须以/或者字母:\开头 2.不能包含特殊字符<> ' | " 且不能只输入/ 3.第一级目录不支持通配符*:不能以/** /*开头 4.**只能出现一次 5.最大数量为10 最小长度:1 最大长度:128 |
black_paths |
否 |
Array of strings |
1.路径必须以/或者字母:\开头 2.不能包含特殊字符<> ' | " 且不能只输入/ 3.第一级目录不支持通配符*:不能以/** /*开头 4.**只能出现一次 5.最大数量为10 最小长度:1 最大长度:128 |
format |
否 |
AccessConfigFormatUpdate object |
日志格式。若修改format,则single与multi必须选择一种。 |
windows_log_info |
否 |
日志接入采集Windows事件日志。当需要取消Windows日志时,只需传入一个空的windows_log_info字段。 |
|
stdout |
否 |
Boolean |
标准输出开关,仅CCE接入类型时使用 |
stderr |
否 |
Boolean |
标准输出开关标准错误开关,仅CCE接入类型时使用 |
pathType |
否 |
String |
CCE接入类型,仅CCE接入类型时使用 枚举值:
|
namespaceRegex |
否 |
String |
K8s Namespace正则匹配,仅CCE接入类型时使用 |
podNameRegex |
否 |
String |
K8s 容器名称正则匹配,仅CCE接入类型时使用 |
containerNameRegex |
否 |
String |
K8s 容器名称正则匹配,仅CCE接入类型时使用 |
includeLabels |
否 |
Map<String,String> |
容器 Label白名单,最多支持创建30个,keyname不支持重名,仅CCE接入类型时使用 |
excludeLabels |
否 |
Map<String,String> |
容器 Label黑名单,最多支持创建30个,keyname不支持重名,仅CCE接入类型时使用 |
includeEnvs |
否 |
Map<String,String> |
环境变量白名单,最多支持创建30个,keyname不支持重名,仅CCE接入类型时使用 |
excludeEnvs |
否 |
Map<String,String> |
环境变量黑名单,最多支持创建30个,keyname不支持重名,仅CCE接入类型时使用 |
logLabels |
否 |
Map<String,String> |
环境变量日志标签,最多支持创建30个,keyname不支持重名,仅CCE接入类型时使用 |
logEnvs |
否 |
Map<String,String> |
环境变量日志标签,最多支持创建30个,keyname不支持重名,仅CCE接入类型时使用 |
includeK8sLabels |
否 |
Map<String,String> |
K8s Label白名单,最多支持创建30个,keyname不支持重名,仅CCE接入类型时使用 |
excludeK8sLabels |
否 |
Map<String,String> |
K8s Label黑名单,最多支持创建30个,keyname不支持重名,仅CCE接入类型时使用 |
logK8s |
否 |
Map<String,String> |
K8s Label日志标签,最多支持创建30个,keyname不支持重名,仅CCE接入类型时使用 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
single |
否 |
AccessConfigFormatSingle object |
日志接入格式单行日志 |
multi |
否 |
AccessConfigFormatMutil object |
日志接入格式多行日志 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
mode |
是 |
String |
单行日志。system:系统时间,wildcard:时间通配符。 枚举值:
|
value |
是 |
String |
日志时间。 当mode为”system”,则填入当前时间戳。 当mode为"wildcard",则时间通配符:用日志打印时间来标识一条日志数据,通过时间通配符来匹配日志,每条日志的行首显示日志的打印时间;如果日志中的时间格式为:2019-01-01 23:59:59,时间通配符应该填写为:YYYY-MM-DD hh:mm:ss;如果日志中的时间格式为:19-1-1 23:59:59,时间通配符应该填写为:YY-M-D hh:mm:ss 最小长度:1 最大长度:64 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
mode |
是 |
String |
单行日志。time:日志时间,regular:正则模式。 枚举值:
|
value |
是 |
String |
日志时间。当mode为"regular",则输入正则表达式当mode为"time",则时间通配符:用日志打印时间来标识一条日志数据,通过时间通配符来匹配日志,每条日志的行首显示日志的打印时间;如果日志中的时间格式为:2019-01-01 23:59:59,时间通配符应该填写为:YYYY-MM-DD hh:mm:ss;如果日志中的时间格式为:19-1-1 23:59:59,时间通配符应该填写为:YY-M-D hh:mm:ss 最小长度:1 最大长度:64 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
categorys |
否 |
Array of strings |
采集Windows事件日志类型。Application:应用系统,System:系统,Security:安全,Setup:启动 枚举值:
|
time_offset |
否 |
AccessConfigTimeOffset object |
日志接入偏移时间 |
event_level |
否 |
Array of strings |
事件等级。information:info,warning:告警,error:错误,critical:关键,verbose:冗长 枚举值:
|
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
offset |
是 |
Long |
偏移时间。 当"unit"选择"day"时,范围为1~7天。 当"unit"选择"hour"时,范围为1~168小时。 当"unit"选择"sec"时,范围为1~604800秒。 最小值:1 最大值:604800 |
unit |
是 |
String |
偏移时间单位。day :天,hour:小时,sec:秒 枚举值:
|
响应参数
状态码: 200
参数 |
参数类型 |
描述 |
---|---|---|
access_config_id |
String |
日志接入ID 最小长度:36 最大长度:36 |
access_config_name |
String |
日志接入名称 最小长度:1 最大长度:64 |
access_config_type |
String |
日志接入类型。AGENT:主机接入 枚举值:
|
create_time |
Long |
创建时间 最小值:1 最大值:9999999999999 |
access_config_detail |
AccessConfigDeatilCreate object |
日志接入详细信息 |
log_info |
AccessConfigQueryLogInfo object |
日志接入日志详情 |
host_group_info |
AccessConfigHostGroupIdList object |
日志接入主机组ID列表 |
access_config_tag |
Array of accessConfigTag objects |
标签信息。KEY不能重复,最多20个标签 |
log_split |
Boolean |
日志拆分 |
binary_collect |
Boolean |
二进制收集 |
cluster_id |
String |
CCE集群ID |
参数 |
参数类型 |
描述 |
---|---|---|
paths |
Array of strings |
采集路径。
最小长度:1 最大长度:128 数组长度:1 - 9 |
black_paths |
Array of strings |
采集路径黑名单。
最小长度:1 最大长度:128 数组长度:0 - 9 |
format |
AccessConfigFormatCreate object |
日志格式。single与multi必须选择一种。 |
windows_log_info |
日志接入采集Windows事件日志 |
|
stdout |
Boolean |
标准输出开关,仅CCE接入类型时使用 |
stderr |
Boolean |
标准输出开关标准错误开关,仅CCE接入类型时使用 |
pathType |
String |
CCE接入类型,仅CCE接入类型时使用 枚举值:
|
namespaceRegex |
String |
K8s Namespace正则匹配,仅CCE接入类型时使用 |
podNameRegex |
String |
K8s Pod正则匹配,仅CCE接入类型时使用 |
containerNameRegex |
String |
K8s 容器名称正则匹配,仅CCE接入类型时使用 |
includeLabels |
Map<String,String> |
容器 Label白名单,最多支持创建30个,keyname不支持重名,仅CCE接入类型时使用 |
excludeLabels |
Map<String,String> |
容器 Label黑名单,最多支持创建30个,keyname不支持重名,仅CCE接入类型时使用 |
includeEnvs |
Map<String,String> |
环境变量白名单,最多支持创建30个,keyname不支持重名,仅CCE接入类型时使用 |
excludeEnvs |
Map<String,String> |
环境变量黑名单,最多支持创建30个,keyname不支持重名,仅CCE接入类型时使用 |
logLabels |
Map<String,String> |
容器 Label日志标签,最多支持创建30个,keyname不支持重名,仅CCE接入类型时使用 |
logEnvs |
Map<String,String> |
环境变量日志标签,最多支持创建30个,keyname不支持重名,仅CCE接入类型时使用 |
includeK8sLabels |
Map<String,String> |
K8s Label白名单,最多支持创建30个,keyname不支持重名,仅CCE接入类型时使用 |
excludeK8sLabels |
Map<String,String> |
K8s Label黑名单,最多支持创建30个,keyname不支持重名,仅CCE接入类型时使用 |
logK8s |
Map<String,String> |
K8s Label日志标签,最多支持创建30个,keyname不支持重名,仅CCE接入类型时使用 |
参数 |
参数类型 |
描述 |
---|---|---|
mode |
String |
单行日志。system:系统时间,wildcard:时间通配符。 枚举值:
|
value |
String |
日志时间。当mode为”system”,则填入当前时间戳。当mode为"wildcard",则时间通配符:用日志打印时间来标识一条日志数据,通过时间通配符来匹配日志,每条日志的行首显示日志的打印时间;如果日志中的时间格式为:2019-01-01 23:59:59,时间通配符应该填写为:YYYY-MM-DD hh:mm:ss;如果日志中的时间格式为:19-1-1 23:59:59,时间通配符应该填写为:YY-M-D hh:mm:ss 最小长度:1 最大长度:64 |
参数 |
参数类型 |
描述 |
---|---|---|
mode |
String |
单行日志。time:日志时间,regular:正则模式。 枚举值:
|
value |
String |
日志时间。当mode为"regular",则输入正则表达式当mode为"time",则时间通配符:用日志打印时间来标识一条日志数据,通过时间通配符来匹配日志,每条日志的行首显示日志的打印时间;如果日志中的时间格式为:2019-01-01 23:59:59,时间通配符应该填写为:YYYY-MM-DD hh:mm:ss;如果日志中的时间格式为:19-1-1 23:59:59,时间通配符应该填写为:YY-M-D hh:mm:ss 最小长度:1 最大长度:64 |
参数 |
参数类型 |
描述 |
---|---|---|
categorys |
Array of strings |
采集Windows事件日志类型。Application:应用系统,System:系统,Security:安全,Setup:启动 枚举值:
|
time_offset |
AccessConfigTimeOffset object |
日志接入偏移时间 |
event_level |
Array of strings |
事件等级。information:info,warning:告警,error:错误,critical:关键,verbose:冗长 数组长度:1 - 5 枚举值:
|
参数 |
参数类型 |
描述 |
---|---|---|
offset |
Long |
偏移时间。 当"unit"选择"day"时,范围为1~7天。 当"unit"选择"hour"时,范围为1~168小时。 当"unit"选择"sec"时,范围为1~604800秒。 最小值:1 最大值:604800 |
unit |
String |
偏移时间单位。day :天,hour:小时,sec:秒 枚举值:
|
参数 |
参数类型 |
描述 |
---|---|---|
log_group_id |
String |
日志组ID 最小长度:36 最大长度:36 |
log_stream_id |
String |
日志流ID 最小长度:36 最大长度:36 |
log_group_name |
String |
日志组名称 最小长度:1 最大长度:128 |
log_stream_name |
String |
日志流名称 最小长度:1 最大长度:128 |
参数 |
参数类型 |
描述 |
---|---|---|
host_group_id_list |
Array of strings |
主机组ID列表 最小长度:36 最大长度:36 |
参数 |
参数类型 |
描述 |
---|---|---|
key |
String |
标签Key 最小长度:1 最大长度:128 |
value |
String |
标签Value 最小长度:0 最大长度:255 |
状态码: 400
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误码 最小长度:8 最大长度:8 |
error_msg |
String |
错误描述 最小长度:1 最大长度:1000 |
状态码: 500
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误码 最小长度:8 最大长度:8 |
error_msg |
String |
错误描述 最小长度:1 最大长度:1000 |
请求示例
修改日志接入(ECS)
PUT https://{endpoint}/v3/{project_id}/lts/access-config { "access_config_id" : "ed90802a-8475-4702-955e-e3ee16a5dde9", "access_config_detail" : { "paths" : [ "/test/222", "/test/111" ], "black_paths" : [ ], "format" : { "multi" : { "mode" : "regular", "value" : "aaaa" } }, "windows_log_info" : { "categorys" : [ "Application", "System" ], "time_offset" : { "offset" : 7, "unit" : "day" }, "event_level" : [ "information", "warning", "error", "critical", "verbose" ] } }, "host_group_info" : { "host_group_id_list" : [ "de4dbed4-a3bc-4877-a7ee-096a2a63e036" ] }, "access_config_tag" : [ { "key" : "xxx", "value" : "xxx" }, { "key" : "xxx1", "value" : "xxx1" } ] }
响应示例
状态码: 200
修改日志接入请求响应成功
{ "access_config_detail" : { "black_paths" : [ "/wjy/hei/tesxxx", "/wjy/hei/tesxxx" ], "format" : { "single" : { "mode" : "wildcard", "value" : "1111" } }, "paths" : [ "/wjy/tesxxx" ], "windows_log_info" : { "categorys" : [ "System", "Application", "Security", "Setup" ], "event_level" : [ "information", "warning", "error", "critical", "verbose" ], "time_offset" : { "offset" : 168, "unit" : "hour" } } }, "access_config_id" : "aa58d29e-21a9-4761-ba16-8cxxxxd", "access_config_name" : "采集Wjy_xxxxt2", "access_config_tag" : [ { "key" : "xxx", "value" : "xxx" }, { "key" : "xxx1", "value" : "xxx1" } ], "access_config_type" : "AGENT", "create_time" : 163504332654, "host_group_info" : { "host_group_id_list" : [ "de4dbed4-a3bc-4877-a7ee-09xxxxxx" ] }, "log_info" : { "log_group_id" : "9a7e2183-2d6d-4732-9axxxxx49e0", "log_group_name" : "lts-groupxxxa", "log_stream_id" : "c4de0538-53e6-41fd-b951-xxxx8d7", "log_stream_name" : "lts-topixxx" } }
状态码: 400
非法请求 建议根据error_msg直接修改该请求。
{ "error_code" : "LTS.1807", "error_msg" : "Invalid access config id" }
状态码: 500
表明服务端能被请求访问到,但是服务内部出错。
{ "error_code" : "LTS.0010", "error_msg" : "The system encountered an internal error" }
SDK代码示例
SDK代码示例如下。
修改日志接入(ECS)
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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
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 UpdateAccessConfigSolution { 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"); ICredential auth = new BasicCredentials() .withAk(ak) .withSk(sk); LtsClient client = LtsClient.newBuilder() .withCredential(auth) .withRegion(LtsRegion.valueOf("<YOUR REGION>")) .build(); UpdateAccessConfigRequest request = new UpdateAccessConfigRequest(); UpdateAccessConfigRequestBody body = new UpdateAccessConfigRequestBody(); List<AccessConfigTag> listbodyAccessConfigTag = new ArrayList<>(); listbodyAccessConfigTag.add( new AccessConfigTag() .withKey("xxx") .withValue("xxx") ); listbodyAccessConfigTag.add( new AccessConfigTag() .withKey("xxx1") .withValue("xxx1") ); List<String> listHostGroupInfoHostGroupIdList = new ArrayList<>(); listHostGroupInfoHostGroupIdList.add("de4dbed4-a3bc-4877-a7ee-096a2a63e036"); AccessConfigHostGroupIdList hostGroupInfobody = new AccessConfigHostGroupIdList(); hostGroupInfobody.withHostGroupIdList(listHostGroupInfoHostGroupIdList); List<AccessConfigWindowsLogInfoUpdate.EventLevelEnum> listWindowsLogInfoEventLevel = new ArrayList<>(); listWindowsLogInfoEventLevel.add(AccessConfigWindowsLogInfoUpdate.EventLevelEnum.fromValue("information")); listWindowsLogInfoEventLevel.add(AccessConfigWindowsLogInfoUpdate.EventLevelEnum.fromValue("warning")); listWindowsLogInfoEventLevel.add(AccessConfigWindowsLogInfoUpdate.EventLevelEnum.fromValue("error")); listWindowsLogInfoEventLevel.add(AccessConfigWindowsLogInfoUpdate.EventLevelEnum.fromValue("critical")); listWindowsLogInfoEventLevel.add(AccessConfigWindowsLogInfoUpdate.EventLevelEnum.fromValue("verbose")); AccessConfigTimeOffsetCreate timeOffsetWindowsLogInfo = new AccessConfigTimeOffsetCreate(); timeOffsetWindowsLogInfo.withOffset(7L) .withUnit(AccessConfigTimeOffsetCreate.UnitEnum.fromValue("day")); List<AccessConfigWindowsLogInfoUpdate.CategorysEnum> listWindowsLogInfoCategorys = new ArrayList<>(); listWindowsLogInfoCategorys.add(AccessConfigWindowsLogInfoUpdate.CategorysEnum.fromValue("Application")); listWindowsLogInfoCategorys.add(AccessConfigWindowsLogInfoUpdate.CategorysEnum.fromValue("System")); AccessConfigWindowsLogInfoUpdate windowsLogInfoAccessConfigDetail = new AccessConfigWindowsLogInfoUpdate(); windowsLogInfoAccessConfigDetail.withCategorys(listWindowsLogInfoCategorys) .withTimeOffset(timeOffsetWindowsLogInfo) .withEventLevel(listWindowsLogInfoEventLevel); AccessConfigFormatMutil multiFormat = new AccessConfigFormatMutil(); multiFormat.withMode(AccessConfigFormatMutil.ModeEnum.fromValue("regular")) .withValue("aaaa"); AccessConfigFormatUpdate formatAccessConfigDetail = new AccessConfigFormatUpdate(); formatAccessConfigDetail.withMulti(multiFormat); List<String> listAccessConfigDetailPaths = new ArrayList<>(); listAccessConfigDetailPaths.add("/test/222"); listAccessConfigDetailPaths.add("/test/111"); AccessConfigDeatilUpdate accessConfigDetailbody = new AccessConfigDeatilUpdate(); accessConfigDetailbody.withPaths(listAccessConfigDetailPaths) .withFormat(formatAccessConfigDetail) .withWindowsLogInfo(windowsLogInfoAccessConfigDetail); body.withAccessConfigTag(listbodyAccessConfigTag); body.withHostGroupInfo(hostGroupInfobody); body.withAccessConfigDetail(accessConfigDetailbody); body.withAccessConfigId("ed90802a-8475-4702-955e-e3ee16a5dde9"); request.withBody(body); try { UpdateAccessConfigResponse response = client.updateAccessConfig(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()); } } } |
修改日志接入(ECS)
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 82 83 84 85 86 87 |
# coding: utf-8 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 = __import__('os').getenv("CLOUD_SDK_AK") sk = __import__('os').getenv("CLOUD_SDK_SK") credentials = BasicCredentials(ak, sk) \ client = LtsClient.new_builder() \ .with_credentials(credentials) \ .with_region(LtsRegion.value_of("<YOUR REGION>")) \ .build() try: request = UpdateAccessConfigRequest() listAccessConfigTagbody = [ AccessConfigTag( key="xxx", value="xxx" ), AccessConfigTag( key="xxx1", value="xxx1" ) ] listHostGroupIdListHostGroupInfo = [ "de4dbed4-a3bc-4877-a7ee-096a2a63e036" ] hostGroupInfobody = AccessConfigHostGroupIdList( host_group_id_list=listHostGroupIdListHostGroupInfo ) listEventLevelWindowsLogInfo = [ "information", "warning", "error", "critical", "verbose" ] timeOffsetWindowsLogInfo = AccessConfigTimeOffsetCreate( offset=7, unit="day" ) listCategorysWindowsLogInfo = [ "Application", "System" ] windowsLogInfoAccessConfigDetail = AccessConfigWindowsLogInfoUpdate( categorys=listCategorysWindowsLogInfo, time_offset=timeOffsetWindowsLogInfo, event_level=listEventLevelWindowsLogInfo ) multiFormat = AccessConfigFormatMutil( mode="regular", value="aaaa" ) formatAccessConfigDetail = AccessConfigFormatUpdate( multi=multiFormat ) listPathsAccessConfigDetail = [ "/test/222", "/test/111" ] accessConfigDetailbody = AccessConfigDeatilUpdate( paths=listPathsAccessConfigDetail, format=formatAccessConfigDetail, windows_log_info=windowsLogInfoAccessConfigDetail ) request.body = UpdateAccessConfigRequestBody( access_config_tag=listAccessConfigTagbody, host_group_info=hostGroupInfobody, access_config_detail=accessConfigDetailbody, access_config_id="ed90802a-8475-4702-955e-e3ee16a5dde9" ) response = client.update_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) |
修改日志接入(ECS)
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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
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") auth := basic.NewCredentialsBuilder(). WithAk(ak). WithSk(sk). Build() client := lts.NewLtsClient( lts.LtsClientBuilder(). WithRegion(region.ValueOf("<YOUR REGION>")). WithCredential(auth). Build()) request := &model.UpdateAccessConfigRequest{} keyAccessConfigTag:= "xxx" valueAccessConfigTag:= "xxx" keyAccessConfigTag1:= "xxx1" valueAccessConfigTag1:= "xxx1" var listAccessConfigTagbody = []model.AccessConfigTag{ { Key: &keyAccessConfigTag, Value: &valueAccessConfigTag, }, { Key: &keyAccessConfigTag1, Value: &valueAccessConfigTag1, }, } var listHostGroupIdListHostGroupInfo = []string{ "de4dbed4-a3bc-4877-a7ee-096a2a63e036", } hostGroupInfobody := &model.AccessConfigHostGroupIdList{ HostGroupIdList: listHostGroupIdListHostGroupInfo, } var listEventLevelWindowsLogInfo = []model.AccessConfigWindowsLogInfoUpdateEventLevel{ model.GetAccessConfigWindowsLogInfoUpdateEventLevelEnum().INFORMATION, model.GetAccessConfigWindowsLogInfoUpdateEventLevelEnum().WARNING, model.GetAccessConfigWindowsLogInfoUpdateEventLevelEnum().ERROR, model.GetAccessConfigWindowsLogInfoUpdateEventLevelEnum().CRITICAL, model.GetAccessConfigWindowsLogInfoUpdateEventLevelEnum().VERBOSE, } timeOffsetWindowsLogInfo := &model.AccessConfigTimeOffsetCreate{ Offset: int64(7), Unit: model.GetAccessConfigTimeOffsetCreateUnitEnum().DAY, } var listCategorysWindowsLogInfo = []model.AccessConfigWindowsLogInfoUpdateCategorys{ model.GetAccessConfigWindowsLogInfoUpdateCategorysEnum().APPLICATION, model.GetAccessConfigWindowsLogInfoUpdateCategorysEnum().SYSTEM, } windowsLogInfoAccessConfigDetail := &model.AccessConfigWindowsLogInfoUpdate{ Categorys: &listCategorysWindowsLogInfo, TimeOffset: timeOffsetWindowsLogInfo, EventLevel: &listEventLevelWindowsLogInfo, } multiFormat := &model.AccessConfigFormatMutil{ Mode: model.GetAccessConfigFormatMutilModeEnum().REGULAR, Value: "aaaa", } formatAccessConfigDetail := &model.AccessConfigFormatUpdate{ Multi: multiFormat, } var listPathsAccessConfigDetail = []string{ "/test/222", "/test/111", } accessConfigDetailbody := &model.AccessConfigDeatilUpdate{ Paths: &listPathsAccessConfigDetail, Format: formatAccessConfigDetail, WindowsLogInfo: windowsLogInfoAccessConfigDetail, } request.Body = &model.UpdateAccessConfigRequestBody{ AccessConfigTag: &listAccessConfigTagbody, HostGroupInfo: hostGroupInfobody, AccessConfigDetail: accessConfigDetailbody, AccessConfigId: "ed90802a-8475-4702-955e-e3ee16a5dde9", } response, err := client.UpdateAccessConfig(request) if err == nil { fmt.Printf("%+v\n", response) } else { fmt.Println(err) } } |
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
修改日志接入请求响应成功 |
400 |
非法请求 建议根据error_msg直接修改该请求。 |
500 |
表明服务端能被请求访问到,但是服务内部出错。 |
错误码
请参见错误码。