Sub topic 17
Where to Go Next: Log Shippers and Search Backends
This chapter assumes that you can use the Linux command line, edit files with sudo, manage systemd services, and understand TCP networking. It also assumes that you know the difference between local log files, the systemd journal, and an rsyslog receiver.
A central rsyslog server is useful for collecting messages into files. As the number of servers grows, searching those files with grep and awk becomes slow and difficult. A log shipper is an agent that reads logs, adds metadata, transforms records, and sends them to a storage or search system. A search backend stores indexed log records so that you can query them by time, host, service, severity, or message content.
The role of a log shipper
A shipper usually runs on each client server. It may read one or more of these sources:
- Plain files such as
/var/log/app/*.log - The systemd journal
- Container output
- Application-specific event streams
The shipper tracks its reading position. If it restarts, it can continue from the last known position instead of sending every record again. Many shippers also provide:
- Parsing for JSON, CSV, or common web-log formats
- Fields such as hostname, environment, application, and version
- Local memory or disk queues
- TLS connections to the destination
- Rate limits and filtering
The shipper is separate from the backend. Replacing Elasticsearch with another backend may require changing the shipper output, but it does not necessarily require changing the applications that produce logs.
Choosing a backend
A backend should match the questions you need to answer. Search systems index fields and timestamps, while object storage is cheaper for long-term retention but slower for interactive searches.
| Backend type | Good fit | Main trade-off |
|---|---|---|
| Search cluster | Interactive queries, dashboards, alerts | More memory, storage, and operational work |
| Managed log service | Fast setup and hosted operations | Usage and retention costs |
| Object storage | Archive, compliance, and cheap long retention | Queries are slower and need separate tools |
| Relational database | Small structured event sets | Usually a poor fit for high-volume text logs |
Use a search backend for recent operational data and a lower-cost archive for older records when policy allows. Define retention before deployment. Indexing every debug message forever can cost more than expected.
Important design decisions
Preserve useful context
A record should include at least a timestamp, host identity, service name, severity, and message. Prefer structured JSON when you control the application. Structured fields are easier to query than text extracted with regular expressions.
Plan for failure
A backend outage should not stop the application. Configure bounded local queues and decide what happens when the queue fills. Dropping low-value debug messages may be acceptable. Dropping audit or security records may not be.
Protect sensitive data
Logs can contain passwords, tokens, personal data, and request bodies. Filter secrets before transmission, restrict backend access, encrypt connections, and limit retention. Treat log access as production access.
> callout warning > A central search system is not automatically a backup. Keep an independent archive if the logs must survive deletion, corruption, or compromise of the search cluster.
A practical migration path
Keep the existing rsyslog pipeline while introducing a shipper for one service. Compare record counts, timestamps, fields, and delivery delay. Then add parsing and dashboards. Migrate more services only after queue behavior and retention costs are understood.
Exercise
You need fast searches for the last 30 days and inexpensive storage for two years. Which design is suitable?
Show answer
Send recent records to a search backend for interactive queries, and archive older records in object storage with a documented retention and retrieval process.