Resource Diff Viewer & Log Aggregation
Advanced debugging with diff viewer and log aggregation.
Table of contents
- Resource Diff Viewer & Log Aggregation
- Overview
- Resource Diff Viewer
- Description
- Features
- Usage
- From UI
- API Endpoints
- Implementation Details
- Log Aggregation
- Description
- Features
- Usage
- From UI
- API Endpoint
- Implementation Details
- Common Use Cases
- Debugging Reconciliation Failures
- Monitoring Controller Health
- Investigating Multi-Cluster Issues
- Security Considerations
- RBAC Integration
- Sensitive Data
- Troubleshooting
- Diff Viewer Shows “No Differences”
- Diff Viewer Modal Won’t Open
- Log Aggregation Returns Empty Results
- Logs Not Auto-Refreshing
- Performance Considerations
- Resource Diff Viewer
- Log Aggregation
- Future Enhancements
- Planned Features
- Integration Ideas
- Related Documentation
- Support
Resource Diff Viewer & Log Aggregation
Overview
Flux Orchestrator provides powerful debugging and observability capabilities:
- Resource Diff Viewer: Compare desired vs actual state for Flux resources
- Log Aggregation: Centralized multi-cluster log collection and viewing
Resource Diff Viewer
Description
The Resource Diff Viewer provides a visual comparison between the desired state (from Git/Helm) and the actual state (in the cluster) for any Flux resource. This helps quickly identify configuration drift, reconciliation issues, and resource mismatches.
Features
- Split View: Side-by-side comparison of desired vs actual state
- Unified View: Combined diff with additions/deletions highlighted
- Status Conditions: Display resource conditions (Ready, Reconciling, Stalled)
- YAML Formatting: Clean, readable YAML output with managed fields removed
- Syntax Highlighting: Color-coded diff for easy identification
Usage
From UI
- Navigate to a cluster detail page
- Find any resource (Kustomization, HelmRelease, GitRepository, etc.)
- Click the 🔍 View Diff button next to the resource
- The diff viewer modal opens showing:
- Current view toggle (Split/Unified)
- Desired state (left/green)
- Actual state (right/red)
- Status conditions at the bottom
API Endpoints
Get Resource Manifest:
GET /api/clusters/{clusterId}/resources/{kind}/{namespace}/{name}/manifest
Get Resource Diff:
GET /api/clusters/{clusterId}/resources/{kind}/{namespace}/{name}/diff
Response:
{
"desired": "apiVersion: kustomize.toolkit.fluxcd.io/v1\nkind: Kustomization\n...",
"actual": "apiVersion: kustomize.toolkit.fluxcd.io/v1\nkind: Kustomization\n...",
"conditions": [
{
"type": "Ready",
"status": "True",
"reason": "ReconciliationSucceeded",
"message": "Applied revision: main/abc123"
}
]
}
Implementation Details
Backend (Go):
k8s.Client.GetResourceManifest(): Fetches full resource YAML using dynamic client
k8s.Client.GetResourceDiff(): Retrieves both desired and actual state, includes status conditions
- Handles all Flux resource types via Group-Version-Resource (GVR) mapping
Frontend (React):
ResourceDiffViewer.tsx: Modal component with split/unified diff views
- Uses
diff npm package for generating line-by-line diffs
- Cleans YAML by removing managedFields and resourceVersion
- Responsive design with scrollable content areas
Log Aggregation
Description
Log Aggregation provides a centralized interface to collect, filter, and view logs from multiple pods across multiple clusters. Ideal for debugging Flux controllers and application workloads.
Features
- Multi-Cluster Support: View logs from all connected clusters simultaneously
- Namespace Filtering: Filter by specific namespaces (e.g., flux-system)
- Label Selector: Target specific pods using Kubernetes label selectors
- Log Search: Full-text search across aggregated logs
- Log Level Detection: Automatically highlights ERROR, WARN, INFO, DEBUG levels
- Auto-Refresh: Toggle automatic log updates (10-second interval)
- Tail Logs: Limit to last N lines (default: 100)
- Download Logs: Export logs as text file for offline analysis
- Dark Terminal Theme: Easy-to-read monospace font with syntax highlighting
Usage
From UI
- Navigate to Logs page from the main menu (or
/logs route)
- Configure filters:
- Clusters: Select one or more clusters (default: all)
- Namespaces: Comma-separated namespaces (default: flux-system)
- Label Selector: K8s label query (e.g.,
app=controller)
- Tail Lines: Number of recent lines to show (default: 100)
- Click Fetch Logs to retrieve logs
- Use the search box to filter log lines
- Enable Auto-refresh for live updates
- Click Download Logs to save as text file
API Endpoint
Get Aggregated Logs:
POST /api/logs/aggregated
{
"cluster_ids": ["cluster-1", "cluster-2"],
"namespaces": ["flux-system", "default"],
"label_selector": "app=source-controller",
"tail_lines": 100
}
Response:
{
"logs": [
{
"cluster_id": "cluster-1",
"cluster_name": "production",
"pod_name": "source-controller-7d6c9d4f8-abc12",
"namespace": "flux-system",
"container": "manager",
"timestamp": "2025-01-15T10:30:45Z",
"message": "INFO: Successfully fetched artifact"
}
]
}
Implementation Details
Backend (Go):
k8s.Client.GetAggregatedLogs(): Collects logs from multiple clusters/pods
- Filters pods by namespace and label selector using typed clientset
- Retrieves container logs via PodLogOptions with tail support
- Returns structured
AggregatedLogEntry with cluster context
Frontend (React):
LogAggregation.tsx: Full-page log viewer component
- Real-time filtering with JavaScript array methods
- Log level detection using regex patterns
- Auto-refresh using setInterval with cleanup
- Download functionality using Blob API and data URLs
- Responsive grid layout for filters and log display
Common Use Cases
Debugging Reconciliation Failures
- Go to cluster detail page
- Find the failing Kustomization/HelmRelease
- Click View Diff to see configuration drift
- Navigate to Logs page
- Filter by
flux-system namespace
- Search for the resource name to see reconciliation errors
Monitoring Controller Health
- Open Logs page
- Set namespace to
flux-system
- Use label selectors:
app=source-controller - Git/Helm source logs
app=kustomize-controller - Kustomization logs
app=helm-controller - HelmRelease logs
- Enable Auto-refresh for live monitoring
- Watch for ERROR/WARN level messages
Investigating Multi-Cluster Issues
- Select multiple clusters in Logs page
- Use same namespace/label filters across clusters
- Compare log outputs to identify cluster-specific issues
- Download logs for offline analysis
Security Considerations
RBAC Integration
Both features respect RBAC permissions:
- Diff Viewer: Requires
resources.read permission
- Log Aggregation: Requires
logs.read permission
Users without proper permissions will receive 403 Forbidden errors.
Sensitive Data
- Logs may contain sensitive information (secrets, credentials)
- Diff viewer shows full resource specs (may include secret references)
- Ensure proper RBAC configuration to restrict access
- Consider implementing log redaction for sensitive patterns
Troubleshooting
Diff Viewer Shows “No Differences”
- Resource may be perfectly reconciled
- Check if resource exists in cluster (actual state should not be empty)
- Verify Flux has successfully applied the resource
Diff Viewer Modal Won’t Open
- Check browser console for JavaScript errors
- Verify cluster is connected and healthy
- Ensure resource kind/namespace/name are correct
Log Aggregation Returns Empty Results
- Verify namespace exists in selected clusters
- Check label selector syntax (use
kubectl get pods -l <selector> to test)
- Ensure pods are running (logs only available from active pods)
- Increase tail_lines if logs are too old
Logs Not Auto-Refreshing
- Check if Auto-refresh toggle is enabled
- Verify browser tab is active (some browsers throttle background tabs)
- Look for API errors in browser console
- Ensure backend API is responsive
Resource Diff Viewer
- Diff generation is lightweight (single resource fetch)
- No performance impact on cluster operations
- Modal is lazy-loaded (only fetches data when opened)
Log Aggregation
- Multi-cluster queries can be expensive: Limit clusters when possible
- Tail lines impacts performance: Start with 100 lines, increase if needed
- Auto-refresh adds load: Use sparingly on production clusters
- Label selectors reduce load: Target specific pods instead of all pods
Recommendations:
- Start with single cluster + specific namespace
- Use label selectors to limit pod count
- Set reasonable tail_lines (100-500)
- Disable auto-refresh when not actively monitoring
Future Enhancements
Planned Features
- Diff History: View historical diffs to track changes over time
- Diff Export: Download diff as patch file
- Log Streaming: WebSocket-based real-time log streaming
- Log Filters: Pre-built filters for common log patterns
- Log Alerts: Configure alerts for specific log patterns
- Syntax Highlighting: Better YAML/JSON diff highlighting
Integration Ideas
- Link from diff viewer to logs for same resource
- Show recent logs in resource detail pages
- Diff viewer in dashboard for at-a-glance status
- Log aggregation widget in dashboard
Support
For issues or questions:
- Check this documentation first
- Review related documentation links above
- Check GitHub issues: https://github.com/forcebyte/flux-orchestrator/issues
- Open a new issue with detailed reproduction steps