用于查询或分析 Kubernetes Pod 标准输出/标准错误日志、CCE LogConfig 采集的应用日志、华为云 LTS 日志流、CCE 审计日志...
Query and analyze Kubernetes Pod stdout logs, CCE LogConfig-collected application logs, and Huawei Cloud LTS log streams for CCE workloads.
Architecture: scripts/huawei-cloud.py dispatcher → cce.py (Pod stdout) / cce_app_logs.py (LogConfig discovery & app log stream matching) / lts.py (LTS group/stream/query) → K8s API / CCE OpenAPI / LTS API
Related Skills:
huawei-cloud-cce-pod-failure-diagnoser - Pod startup, scheduling, crash-loop diagnosishuawei-cloud-cce-workload-failure-diagnoser - Deployment/StatefulSet rollout issueshuawei-cloud-cce-node-failure-diagnoser - Node NotReady, disk pressure, network issueshuawei-cloud-cce-kubernetes-event-analyzer - Kubernetes Warning events and patternsCapabilities:
Typical Use Cases:
python3 --version to verifyValid Huawei Cloud credentials (AK/SK mode)
Security Rules:
echo $HUAWEI_CLOUD_AK or echo $HUAWEI_CLOUD_SK to check credentialsHUAWEI_CLOUD_AK, HUAWEI_CLOUD_SK, HUAWEI_CLOUD_REGIONConfiguration Method (Environment Variables):
bash
export HUAWEI_CLOUD_AK=<your-ak>
export HUAWEI_CLOUD_SK=<your-sk>
export HUAWEI_CLOUD_REGION=cn-north-4
API ActionPermissionPurposecce:cluster:getGet clusterView cluster detailscce:logConfig:listList LogConfigQuery LogConfig collection rulescce:logConfig:createCreate LogConfigCreate log collection rulescce:logConfig:deleteDelete LogConfigRemove log collection ruleslts:logs:listList LTS logsQuery log streams and log recordslts:groups:listList LTS groupsQuery log group information
This skill enforces a preview-then-confirm mechanism for all mutating operations.
OperationRisk LevelDescriptionhuawei_create_cce_logconfig🟡 MediumCreates a LogConfig collection rule; preview by default, create with confirm=true``huawei_delete_cce_logconfig🟠 HighDeletes a LogConfig collection rule; preview by default, delete with confirm=true
Process: Call without confirm=true → inspect preview output → user confirms → call with confirm=true
confirm=trueUser IntentTool(s)Reference DocumentQuery Pod stdout/stderr logshuawei_get_pod_logsreferences/workflow.mdQuery previous terminated container logshuawei_get_pod_logs (previous=true)references/workflow.mdList cluster LogConfig ruleshuawei_get_cce_logconfigsreferences/workflow.mdCreate LogConfig for stdout/file collectionhuawei_create_cce_logconfigreferences/workflow.mdDelete a LogConfig rulehuawei_delete_cce_logconfigreferences/workflow.mdDiscover app LTS stream mappinghuawei_get_application_logconfigsreferences/workflow.mdQuery audit logs for Pod deletionhuawei_query_cce_audit_logsreferences/workflow.mdQuery audit logs for workload changeshuawei_query_cce_audit_logsreferences/workflow.mdQuery recent application logshuawei_query_application_recent_logsreferences/workflow.mdQuery application logs in time windowhuawei_query_application_logsreferences/workflow.mdAnalyze logs for abnormalitieshuawei_analyze_application_logsreferences/workflow.mdRisk constraints & guardrails—references/risk-rules.mdOutput schema reference—references/output-schema.md
bash
# Query recent stdout from a Pod
python3 scripts/huawei-cloud.py huawei_get_pod_logs \
region=cn-north-4 \
cluster_id=<cluster-id> \
namespace=default \
pod_name=<pod-name> \
tail_lines=200
# Query previous terminated container logs
python3 scripts/huawei-cloud.py huawei_get_pod_logs \
region=cn-north-4 \
cluster_id=<cluster-id> \
namespace=default \
pod_name=<pod-name> \
container=<container-name> \
previous=true \
tail_lines=200
bash
# List all LogConfig resources in a cluster
python3 scripts/huawei-cloud.py huawei_get_cce_logconfigs \
region=cn-north-4 \
cluster_id=<cluster-id>
# Discover app LTS stream from LogConfig
python3 scripts/huawei-cloud.py huawei_get_application_logconfigs \
region=cn-north-4 \
cluster_id=<cluster-id> \
namespace=default \
app_name=<workload-name>
# Preview then create a workload stdout LogConfig
python3 scripts/huawei-cloud.py huawei_create_cce_logconfig \
region=cn-north-4 \
cluster_id=<cluster-id> \
logconfig_name=<policy-name> \
source_type=container_stdout \
workload_namespace=default \
workload_name=<workload-name> \
workload_kind=Deployment \
log_group_id=<lts-group-id> \
log_stream_id=<lts-stream-id>
# Then call again with confirm=true after user confirms
# Preview then create a container file LogConfig
python3 scripts/huawei-cloud.py huawei_create_cce_logconfig \
region=cn-north-4 \
cluster_id=<cluster-id> \
logconfig_name=<policy-name> \
source_type=container_file \
workload_namespace=default \
workload_name=<workload-name> \
workload_kind=Deployment \
container=<container-name> \
log_path=/var/log \
file_pattern="*.log" \
log_group_id=<lts-group-id> \
log_stream_id=<lts-stream-id>
# Then call again with confirm=true after user confirms
# Preview then delete a LogConfig
python3 scripts/huawei-cloud.py huawei_delete_cce_logconfig \
region=cn-north-4 \
cluster_id=<cluster-id> \
logconfig_name=<policy-name> \
logconfig_namespace=kube-system
# Then call again with confirm=true after user confirms
bash
# Query Pod deletion audit events
python3 scripts/huawei-cloud.py huawei_query_cce_audit_logs \
region=cn-north-4 \
cluster_id=<cluster-id> \
audit_type=pod_delete \
namespace=default \
hours=6 \
log_group_id=<audit-lts-group-id> \
log_stream_id=<audit-lts-stream-id>
# Query workload change audit events
python3 scripts/huawei-cloud.py huawei_query_cce_audit_logs \
region=cn-north-4 \
cluster_id=<cluster-id> \
audit_type=workload_change \
namespace=default \
start_time="2026-05-30 10:00:00" \
end_time="2026-05-30 11:00:00"
bash
# Query recent application logs from a specific LogConfig policy
python3 scripts/huawei-cloud.py huawei_query_application_recent_logs \
region=cn-north-4 \
cluster_id=<cluster-id> \
namespace=default \
app_name=<workload-name> \
logconfig_name=<policy-name> \
hours=1 \
keywords=ERROR \
auto_paginate=true \
max_pages=5 \
limit=100
# Analyze an application log window for abnormal logs
python3 scripts/huawei-cloud.py huawei_analyze_application_logs \
region=cn-north-4 \
cluster_id=<cluster-id> \
namespace=default \
app_name=<workload-name> \
logconfig_name=<policy-name> \
start_time="2026-05-30 10:00:00" \
end_time="2026-05-30 11:00:00" \
auto_paginate=true \
max_pages=5 \
limit=1000
ParameterRequiredDescriptionDefaultregionYesHuawei Cloud region IDcn-north-4``cluster_idYesCCE cluster ID—namespaceMost toolsKubernetes namespacedefault
ParameterToolRequiredDescriptionConstraintspod_name``huawei_get_pod_logsYesPod nameMust reference existing Podcontainer``huawei_get_pod_logsNoContainer nameRequired for multi-container Podsprevious``huawei_get_pod_logsNoPrevious terminated containertrue/ false``tail_lines``huawei_get_pod_logsNoNumber of recent linesRecommended 100-500
ParameterToolRequiredDescriptionConstraintslogconfig_namecreate/deleteYesLogConfig policy nameUnique within namespacesource_typecreateYesCollection source typecontainer_stdout or container_file``workload_namecreateYesTarget workload nameMust reference existing workloadworkload_kindcreateYesWorkload typeDeployment, StatefulSet, DaemonSet``workload_namespacecreateYesWorkload namespace—containercreate (file)NoContainer nameRequired for container_filelog_pathcreate (file)NoLog file directory pathRequired when source_type=container_filefile_patterncreate (file)NoFile name patterne.g. *.log``log_group_idcreateYesLTS log group IDMust reference existing LTS grouplog_stream_idcreateYesLTS log stream IDMust reference existing LTS streamconfirmcreate/deleteNoExecute confirmationPreview without it; true to executelogconfig_namespacedeleteYesLogConfig namespace—
ParameterToolRequiredDescriptionConstraintsaudit_type``huawei_query_cce_audit_logsNoKeyword presetpod_delete or workload_change``hoursauditNoRecent hours windowUsed when no start_time/end_timestart_timeauditNoStart timeYYYY-MM-DD HH:MM:SS formatend_timeauditNoEnd timeYYYY-MM-DD HH:MM:SS formatlog_group_idauditRecommendedAudit LTS group IDAuto-discovered if omittedlog_stream_idauditRecommendedAudit LTS stream IDAuto-discovered if omitted
ParameterToolRequiredDescriptionConstraintsapp_nameapp log toolsYesWorkload nameMust reference existing workloadlogconfig_nameapp log toolsNoSpecific LogConfig policySelects from matched streamspolicy_nameapp log toolsNoSpecific policy nameAlternative to logconfig_namekeywordsapp log toolsNoKeyword filterLTS keyword searchhoursrecent logsNoRecent hours windowDefault 1start_timetime-range logsNoStart timeYYYY-MM-DD HH:MM:SS formatend_timetime-range logsNoEnd timeYYYY-MM-DD HH:MM:SS formatauto_paginateapp log toolsNoEnable paginationtrue/ false``max_pagesapp log toolsNoMax pages to fetchCaps total work when paginatinglimitapp log toolsNoPer-page sizeRecommended 100-1000
Region NameRegion IDNorth China - Beijing 4cn-north-4North China - Beijing 1cn-north-1East China - Shanghai 1cn-east-3East China - Shanghai 2cn-east-2South China - Guangzhoucn-south-1South China - Shenzhencn-south-4Southwest China - Guiyang 1cn-southwest-2Asia Pacific - Bangkokap-southeast-2Asia Pacific - Singaporeap-southeast-1Asia Pacific - Hong Kongap-southeast-3Europe - Pariseu-west-0
hours=1 or tail_lines=100-500 before full historical querieshuawei_get_application_logconfigs first to find the right LogConfig policy, then pass logconfig_name or policy_name to query toolsconfirm=true first; only call with confirm=true after user reviews the previewauto_paginate=true with max_pages to cap total work; limit controls per-page sizePitfallSymptomQuick FixMissing LogConfig for appNo LTS stream foundCreate LogConfig with huawei_create_cce_logconfigWrong LogConfig policyLogs from wrong streamUse huawei_get_application_logconfigs to discover correct policykeywords filter skews analysis ratiosAbnormal ratio too high/lowDo not set keywords unless user explicitly wants keyword-scoped ratiosAudit type misunderstoodAudit results too broad/narrowaudit_type is keyword preset only; pod_delete adds delete+pods, workload_change adds workload-related keywordsNo confirm=true on create/deletePreview-only, no actual changeCall again with confirm=true after reviewing previewLarge time window without paginationPartial or slow resultsUse auto_paginate=true with max_pages and reasonable limitPrevious container log not found"previous" flag on running containerUse previous=true only when container has restarted; check Pod status firstAK/SK exposed in outputCredential leakRedact all credentials; summarize patterns instead of raw values
huawei_create_cce_logconfig and huawei_delete_cce_logconfig with confirm=truehuawei_query_cce_audit_logs uses pure keyword search over LTS audit content; all convenience parameters ( pod_name, resource_name, workload_name, namespace, user, verb, resource, status_code) are converted into keywords, not parsed-field filterssource_type=container_stdout for Pod standard output, source_type=container_file for application file logs collected from paths like /var/log/*.loghuawei_analyze_application_logs calculates ratios over the queried log set; adding keywords changes the denominator to only matched logs, so avoid it unless explicitly requestedAll tools return JSON with structured log data, analysis results, or LogConfig previews. See references/output-schema.md for detailed response schemas.
DocumentDescriptionworkflow.mdDetailed workflow for Pod stdout, application LTS logs, LogConfig management, and audit queriesrisk-rules.mdRisk constraints, security rules, and scope boundariesoutput-schema.mdLog query and analysis output schema reference