Better Stack Log Management (Logtail)
Overview
Better Stack Logs (formerly Logtail) provides centralized log management with structured log ingestion, real-time search, and log-based alerting. MSPs use it to aggregate logs from client infrastructure, investigate incidents, and set up proactive alerting on error patterns.
Anti-triggers
- Azure Log Analytics and KQL — different store, different query
language; use
azure-mcp-observability.
- Threat hunting or security event analysis — these are
application logs, not a SIEM; use
huntress-signals or blumira.
- Uptime history for a monitor — check results are not log records;
use
betterstack-monitors.
Key Concepts
Log Sources
Sources define where logs come from and how they're ingested:
- Platform sources - AWS, Azure, GCP, Heroku, Vercel, etc.
- Language sources - Node.js, Python, Ruby, Go, etc.
- Infrastructure sources - Docker, Kubernetes, syslog, HTTP
- Each source gets a unique source token for authentication
Log Structure
Logs in Better Stack are structured JSON documents:
dt - Timestamp (ISO 8601)
level - Log level (info, warn, error, debug, fatal)
message - Log message text
- Any additional custom fields (request_id, user_id, service, etc.)
Query Language
Better Stack supports SQL-like queries for log searching:
- Field-based filters:
level:error, service:api
- Text search:
"connection refused"
- Time ranges:
dt:[2026-03-27T00:00:00Z TO 2026-03-27T23:59:59Z]
- Boolean operators:
AND, OR, NOT
- Wildcards:
host:prod-*
Log-Based Alerts
Create alerts that trigger when log patterns match:
- Error rate thresholds (e.g., more than 10 errors in 5 minutes)
- Specific error message patterns
- Absence of expected log entries (heartbeat-style)
API Patterns
Query Logs
betterstack_query_logs
Parameters:
query - Search query string (required)
source_id - Filter to a specific source
from - Start time (ISO 8601)
to - End time (ISO 8601)
batch_size - Number of results to return (default 100)
order - Sort order: newest_first or oldest_first
Example response:
{
"data": [
{
"dt": "2026-03-27T10:15:30.123Z",
"level": "error",
"message": "Connection refused to database at 10.0.1.5:5432",
"service": "api-gateway",
"host": "prod-api-01",
"request_id": "req-abc-123"
},
{
"dt": "2026-03-27T10:15:29.456Z",
"level": "error",
"message": "Health check failed for postgres pool",
"service": "api-gateway",
"host": "prod-api-01"
}
]
}
List Log Sources
betterstack_list_sources
Parameters:
Example response:
{
"data": [
{
"id": "src-789",
"type": "source",
"attributes": {
"name": "Production API",
"platform": "node",
"token": "xxxx...xxxx",
"ingesting_paused": false,
"records_count": 1500000
}
}
]
}
Create Log Source
betterstack_create_source
Parameters:
name - Source name (required)
platform - Platform type: node, python, ruby, go, docker, kubernetes, syslog, http, etc.
Common Workflows
Incident Log Investigation
- Get the incident details and identify the affected monitor/service
- Call
betterstack_query_logs with the service name and time range around the incident
- Filter for error and fatal level logs
- Look for patterns: connection errors, timeout spikes, OOM events
- Trace request IDs across services for distributed issues
- Summarize findings with root cause analysis
Error Rate Monitoring
- Query logs for
level:error over the last hour
- Group by service to identify which services have elevated errors
- Compare error counts against baseline
- Drill into the highest-error services for specific error messages
- Correlate with uptime monitor incidents
Setting Up Logging for a New Client
- Create log sources for each client service (API, web, workers)
- Distribute source tokens for log ingestion configuration
- Verify logs are flowing with a test query
- Set up log-based alerts for critical error patterns
- Create saved queries for common investigation patterns
Security Log Review
- Search for authentication failures:
"authentication failed" OR "invalid token" OR "unauthorized"
- Look for unusual access patterns:
level:warn AND "rate limit"
- Check for privilege escalation attempts
- Review admin action logs
- Document findings for compliance reporting
Error Handling
Source Not Found
Cause: Invalid source ID or source was deleted
Solution: List sources to verify the correct ID
Query Syntax Error
Cause: Invalid query syntax
Solution: Verify query follows the supported syntax (field:value, boolean operators, quotes for phrases)
No Results
Cause: No logs match the query for the given time range
Solution: Broaden the time range, check source ID, verify logs are being ingested
Best Practices
- Use structured logging with consistent field names across services
- Include request IDs for distributed tracing across services
- Query with specific time ranges to improve performance
- Use source filters to scope queries to relevant services
- Create saved queries for common investigation patterns
- Set up log-based alerts for critical error patterns
- Use log levels consistently: error for failures, warn for degradation, info for operations
- Include contextual fields (user_id, tenant_id, request_id) for efficient filtering
Related Skills
1---2name: better-stack-logging3description: Better Stack log management (Logtail): log sources, structured log search and query syntax, log-based alerting, and log analysis workflows.4---56# Better Stack Log Management (Logtail)78## Overview910Better Stack Logs (formerly Logtail) provides centralized log management with structured log ingestion, real-time search, and log-based alerting. MSPs use it to aggregate logs from client infrastructure, investigate incidents, and set up proactive alerting on error patterns.1112## Anti-triggers1314- **Azure Log Analytics and KQL** — different store, different query15 language; use `azure-mcp-observability`.16- **Threat hunting or security event analysis** — these are17 application logs, not a SIEM; use `huntress-signals` or `blumira`.18- **Uptime history for a monitor** — check results are not log records;19 use `betterstack-monitors`.2021## Key Concepts2223### Log Sources2425Sources define where logs come from and how they're ingested:26- **Platform sources** - AWS, Azure, GCP, Heroku, Vercel, etc.27- **Language sources** - Node.js, Python, Ruby, Go, etc.28- **Infrastructure sources** - Docker, Kubernetes, syslog, HTTP29- Each source gets a unique source token for authentication3031### Log Structure3233Logs in Better Stack are structured JSON documents:34- `dt` - Timestamp (ISO 8601)35- `level` - Log level (info, warn, error, debug, fatal)36- `message` - Log message text37- Any additional custom fields (request_id, user_id, service, etc.)3839### Query Language4041Better Stack supports SQL-like queries for log searching:42- Field-based filters: `level:error`, `service:api`43- Text search: `"connection refused"`44- Time ranges: `dt:[2026-03-27T00:00:00Z TO 2026-03-27T23:59:59Z]`45- Boolean operators: `AND`, `OR`, `NOT`46- Wildcards: `host:prod-*`4748### Log-Based Alerts4950Create alerts that trigger when log patterns match:51- Error rate thresholds (e.g., more than 10 errors in 5 minutes)52- Specific error message patterns53- Absence of expected log entries (heartbeat-style)5455## API Patterns5657### Query Logs5859```60betterstack_query_logs61```6263Parameters:64- `query` - Search query string (required)65- `source_id` - Filter to a specific source66- `from` - Start time (ISO 8601)67- `to` - End time (ISO 8601)68- `batch_size` - Number of results to return (default 100)69- `order` - Sort order: `newest_first` or `oldest_first`7071**Example response:**7273```json74{75 "data": [76 {77 "dt": "2026-03-27T10:15:30.123Z",78 "level": "error",79 "message": "Connection refused to database at 10.0.1.5:5432",80 "service": "api-gateway",81 "host": "prod-api-01",82 "request_id": "req-abc-123"83 },84 {85 "dt": "2026-03-27T10:15:29.456Z",86 "level": "error",87 "message": "Health check failed for postgres pool",88 "service": "api-gateway",89 "host": "prod-api-01"90 }91 ]92}93```9495### List Log Sources9697```98betterstack_list_sources99```100101Parameters:102- `page` - Pagination cursor103104**Example response:**105106```json107{108 "data": [109 {110 "id": "src-789",111 "type": "source",112 "attributes": {113 "name": "Production API",114 "platform": "node",115 "token": "xxxx...xxxx",116 "ingesting_paused": false,117 "records_count": 1500000118 }119 }120 ]121}122```123124### Create Log Source125126```127betterstack_create_source128```129130Parameters:131- `name` - Source name (required)132- `platform` - Platform type: node, python, ruby, go, docker, kubernetes, syslog, http, etc.133134## Common Workflows135136### Incident Log Investigation1371381. Get the incident details and identify the affected monitor/service1392. Call `betterstack_query_logs` with the service name and time range around the incident1403. Filter for error and fatal level logs1414. Look for patterns: connection errors, timeout spikes, OOM events1425. Trace request IDs across services for distributed issues1436. Summarize findings with root cause analysis144145### Error Rate Monitoring1461471. Query logs for `level:error` over the last hour1482. Group by service to identify which services have elevated errors1493. Compare error counts against baseline1504. Drill into the highest-error services for specific error messages1515. Correlate with uptime monitor incidents152153### Setting Up Logging for a New Client1541551. Create log sources for each client service (API, web, workers)1562. Distribute source tokens for log ingestion configuration1573. Verify logs are flowing with a test query1584. Set up log-based alerts for critical error patterns1595. Create saved queries for common investigation patterns160161### Security Log Review1621631. Search for authentication failures: `"authentication failed" OR "invalid token" OR "unauthorized"`1642. Look for unusual access patterns: `level:warn AND "rate limit"`1653. Check for privilege escalation attempts1664. Review admin action logs1675. Document findings for compliance reporting168169## Error Handling170171### Source Not Found172173**Cause:** Invalid source ID or source was deleted174**Solution:** List sources to verify the correct ID175176### Query Syntax Error177178**Cause:** Invalid query syntax179**Solution:** Verify query follows the supported syntax (field:value, boolean operators, quotes for phrases)180181### No Results182183**Cause:** No logs match the query for the given time range184**Solution:** Broaden the time range, check source ID, verify logs are being ingested185186## Best Practices187188- Use structured logging with consistent field names across services189- Include request IDs for distributed tracing across services190- Query with specific time ranges to improve performance191- Use source filters to scope queries to relevant services192- Create saved queries for common investigation patterns193- Set up log-based alerts for critical error patterns194- Use log levels consistently: error for failures, warn for degradation, info for operations195- Include contextual fields (user_id, tenant_id, request_id) for efficient filtering196197## Related Skills198199- [api-patterns](../api-patterns/SKILL.md) - Pagination and error handling200- [monitors](../monitors/SKILL.md) - Monitors correlated with log data201- [incidents](../incidents/SKILL.md) - Incident investigation with logs202- [status-pages](../status-pages/SKILL.md) - Status context from log analysis