By default, Kubernetes does not retain pod logs after a pod is deleted. If you delete pods to reclaim cluster resources, you lose the log history for completed workflows. Simple Log Service integration solves this: it collects pod logs as they run and stores them durably, so you can query logs for any workflow even after the pod is gone.
How it works
When you create a workflow cluster, the system automatically creates a Simple Log Service project named k8s-log-<clusterid>. All pod logs from workflows in that cluster are collected into a Logstore named workflow-logstore.
Once log collection is enabled, you can view logs using the Argo CLI, Argo Server, or Argo UI — regardless of whether the pod is still running.
Limitations
-
If
oss-artifact-repositoryis enabled andarchiveLogs: trueis set for a workflow cluster, Simple Log Service does not collect pod logs. Logs are routed tooss-artifact-repositoryinstead. To use Simple Log Service in this case, remove thearchiveLogs: truesetting. -
After log collection is enabled, you can view workflow logs at any time before the workflow is deleted, regardless of whether the pod has been deleted.
-
If a workflow is persisted to a database, you can download its logs as a ZIP file or view them in the Simple Log Service console even after the workflow is deleted. For details, see Persist workflows.
Enable Simple Log Service
If the k8s-log-<clusterid> project was not created automatically when you created the workflow cluster, create it manually before proceeding. See Create a Simple Log Service project.
Choose one of the following methods:
| Method | Best for |
|---|---|
| Alibaba Cloud Argo CLI | Quick setup with a single interactive command |
| AliyunLogConfig | GitOps workflows or declarative configuration management |
Enable Simple Log Service by using the Alibaba Cloud Argo CLI
The Alibaba Cloud Argo CLI is fully compatible with the open-source Argo CLI and extends it with log collection support for deleted pods.
Prerequisites
-
Downloaded and installed Alibaba Cloud Argo CLI 3.4.12. For details, see Alibaba Cloud Argo CLI.
-
If you use a Resource Access Management (RAM) user, the AliyunLogReadOnlyAccess policy is attached to the RAM user. For details, see Create a RAM user and authorize the RAM user to access Simple Log Service.
Steps
Run the following command to configure Simple Log Service. When prompted, enter the number of days to retain logs (default: 7 days).
argo config sls
Please input log retention days. Default is 7 days.
10
Expected output:
Start to config SLS for your cluster.
Created AliyunLogConfig CR workflow-sls-config in default namespace.
Created SLS logstore workflow-logstore in SLS project k8s-log-<clusterid>, log retention days is 10 days
The output confirms that Simple Log Service is configured. All workflow logs in the cluster are collected to the workflow-logstore Logstore in the k8s-log-<clusterid> project.
Enable Simple Log Service by creating an AliyunLogConfig
Apply the following YAML manifest to create an AliyunLogConfig custom resource. The Log Service controller automatically creates the k8s-log-<clusterid> project and the workflow-logstore Logstore.
cat << EOF | kubectl apply -f -
apiVersion: log.alibabacloud.com/v1alpha1
kind: AliyunLogConfig
metadata:
name: workflow-sls-config
namespace: default
spec:
lifeCycle: 5 # Log retention period in days
logstore: workflow-logstore
logtailConfig:
configName: workflow-sls-config
inputType: plugin # Use the plugin-based input method
inputDetail:
plugin:
inputs:
- type: service_docker_stdout # Collect container stdout and stderr
detail:
Stdout: true
Stderr: true
EOF
Verify log collection
After enabling Simple Log Service, confirm that logs are being collected:
-
Log on to the Simple Log Service console.
-
Find the
k8s-log-<clusterid>project. -
Click workflow-logstore and check that log entries appear.
If no logs appear, run the following command to check whether the AliyunLogConfig custom resource was created successfully:
kubectl get aliyunlogconfigs -n default
The output should include workflow-sls-config with no error status. If the resource is missing or shows an error, re-run the enable steps or check that your RAM user has the required permissions.
Access logs by using the Argo CLI
The Argo CLI provides two ways to view workflow logs. The direct method (using the --sls flag) is recommended because it does not require Argo Server setup.
You can run kubectl logs <pod-name> to view the logs of an existing pod, but by default this command returns up to 2,000 rows of log data. To view more log data or to view logs for a deleted pod, use one of the following methods.
Use the Argo CLI directly (recommended)
Prerequisites
-
Downloaded and installed Alibaba Cloud Argo CLI 3.4.12. For details, see Alibaba Cloud Argo CLI.
-
If you use a RAM user, the AliyunLogReadOnlyAccess policy is attached to the RAM user.
Steps
-
Grant the Argo CLI access to your cluster:
argo config init # Follow the prompts to enter your AccessKey ID and AccessKey secret. -
Query logs:
# View logs for a specific pod argo logs <workflow-name> <pod-name> --sls # Download all logs for a workflow as a ZIP file argo logs <workflow-name> --sls
Use Argo Server
If you prefer to access Simple Log Service through Argo Server, set the following environment variables first.
To query logs collected by Simple Log Service via Argo Server, you must specify<pod-name>. To access workflows or pods in a different namespace, obtain theKUBE_TOKENfor that namespace.
-
Set the required environment variables:
export ARGO_SERVER=argo.<cluster id>.<region>.alicontainer.com:2746 export KUBE_TOKEN=$(kubectl create token default -n default --duration 24h) export ARGO_TOKEN="Bearer $KUBE_TOKEN" export ARGO_INSECURE_SKIP_VERIFY=true -
Query the logs for a specific pod:
argo logs <workflow-name> <pod-name>
View logs for workflows persisted to databases
If a workflow is persisted to a database, you can download its logs after the workflow is deleted.
-
Grant the Argo CLI access to your cluster:
argo config init # Follow the prompts to enter your AccessKey ID and AccessKey secret. -
Get the UID of the archived workflow:
argo archive listExpected output:
NAMESPACE NAME STATUS AGE DURATION PRIORITY MESSAGE P/R/C PARAMETERS UID default hello-world-l6c2r Succeeded 3d 1m 0 0/0/0 179eaef0-fde3-496f-946d-549e8f****** -
Download the workflow logs using the UID:
argo archive logs 179eaef0-fde3-496f-946d-549e8f******The logs are saved as
<workflow-name>.zipin the current directory.
Use the Argo UI to view logs
The Argo UI displays workflow pod logs directly. If a pod has been deleted, the logs collected by Simple Log Service are shown in place of the live pod output.
Disable Simple Log Service
-
Delete the
AliyunLogConfigcustom resource:kubectl delete aliyunlogconfigs.log.alibabacloud.com workflow-sls-config -n default -
Log on to the Simple Log Service console and delete the
workflow-logstoreLogstore.
What's next
-
Persist workflows — Store workflow state in a database to access logs and results after the workflow is deleted.
-
Alibaba Cloud Argo CLI — Download and configure the CLI for full log access capabilities.