Summary
OpenKruise rollout currently uses klog for unstructured logging, which makes troubleshooting and observability challenging. This feature request proposes migrating to structured logging to improve developer experience and operational efficiency.
Current Challenges
- Using klog with plain text log format
- Difficult to query and filter logs programmatically
- Limited integration with modern observability tools (Loki, ELK, etc.)
- Manual parsing required for log analysis
Proposed Solution
Migrate to structured logging (JSON format) while maintaining backward compatibility:
// Current
I0118 10:30:45.123456 kruise-controller: Reconciling CloneSet default/my-cloneset, replicas: 3, ready: 2
// Proposed
{
"timestamp": "2024-01-18T10:30:45.123456Z",
"level": "INFO",
"component": "kruise-controller",
"message": "Reconciling CloneSet",
"resource": {
"kind": "CloneSet",
"namespace": "default",
"name": "my-cloneset"
},
"replicas": 3,
"ready": 2
}
Benefits
For Developers
- Faster debugging: Query specific resources, components, or error types instantly
- Better correlation: Link related logs using trace IDs or request IDs
- Automated analysis: Enable log aggregation and pattern detection
For Operations
- Enhanced monitoring: Set up precise alerts based on structured fields
- Improved observability: Seamless integration with Loki, Elasticsearch, and other log collectors
- Efficient querying: Filter by component, resource type, or custom fields
Examples of Improved Queries
kubectl logs -n kruise-rollout deployment/kruise-controller-manager | jq 'select(.level=="ERROR" and (.msg | contains("CloneSet")))'
kubectl logs -n kruise-rollout deployment/kruise-controller-manager | jq 'select(.msg | contains("my-cloneset"))'
This enhancement aligns with cloud-native best practices and significantly improves the debugging experience for both contributors and end users.
Summary
OpenKruise rollout currently uses klog for unstructured logging, which makes troubleshooting and observability challenging. This feature request proposes migrating to structured logging to improve developer experience and operational efficiency.
Current Challenges
Proposed Solution
Migrate to structured logging (JSON format) while maintaining backward compatibility:
Benefits
For Developers
For Operations
Examples of Improved Queries
This enhancement aligns with cloud-native best practices and significantly improves the debugging experience for both contributors and end users.