← Workflows

阅读中文版本

Log Aggregation Setup Workflow

Set up centralized log aggregation to collect, search, and alert on logs from all services in one place.

intermediate~90 minloggingaggregationworkflow

Objective

Centralize application logs for cross-service searching and alerting.

Environment

  • Multiple services producing logs
  • A log aggregation platform
  • Log shipping agent

Steps

1. Configure log format

Ensure all services output structured JSON logs with consistent fields.

Expected state: All services produce structured logs with common fields.

2. Set up log shipper

Install and configure the log shipping agent on each service host.

Expected state: Logs are being shipped to the aggregation platform.

3. Create indexes

Configure index patterns and retention policies in the aggregation platform.

Expected state: Logs are indexed and searchable with appropriate retention.

4. Build dashboards

Create dashboards for key log fields: error rate, latency, request volume.

Expected state: Log dashboards are available for monitoring.

5. Set up alerts

Create alerts for error spikes, specific error patterns, and log volume anomalies.

Expected state: Alerts fire when log patterns indicate problems.

Decision points

JSON or plain text logs?

  • JSON for structured querying
  • Plain text for simplicity

Use JSON for machine processing and querying; plain text is acceptable for single-service setups.

Expected outcome

All service logs are centralized, searchable, and monitored with dashboards and alerts.

Verification

Generate a test log entry and confirm it appears in the aggregation platform within 30 seconds.

Cleanup

Remove the test log entry after verification.

Central logs tell the whole story

When a request spans multiple services, only centralized logs can show the complete path and pinpoint the failure.

Implementation Notes

This workflow provides a structured approach to ensure consistent results across team members and environments.

Common Pitfalls

Skipping verification steps or rushing through the process can lead to incomplete results. Always follow each step in order and verify before proceeding.

Quick Reference

# Execute the workflow steps as documented above
echo "Workflow completed successfully"