Skip to content
Back to skills

Log Analyzer

ASecurity

Analyzes application logs, server logs, and error traces to identify root causes, patterns, and anomalies. Use when debugging production incidents, investigating error spikes, parsing crash reports, or correlating events across multiple log sources. Trigger words: logs, errors, stack trace, crash, exception, debug, incident, 500 errors, timeout, latency spike.

  • 155 stars
  • 0 votes
  • 4 copies
  • 10 views
  • Added May 29, 2026
devopsgojavabashkubernetesdebuggingapidevops

Works with

  • terminal
  • api

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 8, 2026

npx -y skills add TerminalSkills/skills --skill log-analyzer --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Log Analyzer?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Log Analyzer
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/terminalskills-log-analyzer/badge)](https://www.skillsdirectory.com/skills/terminalskills-log-analyzer)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: log-analyzer
description: >-
  Analyzes application logs, server logs, and error traces to identify root causes,
  patterns, and anomalies. Use when debugging production incidents, investigating
  error spikes, parsing crash reports, or correlating events across multiple log
  sources. Trigger words: logs, errors, stack trace, crash, exception, debug,
  incident, 500 errors, timeout, latency spike.
license: Apache-2.0
compatibility: "Works with any text-based log format (JSON, plaintext, syslog, structured)"
metadata:
  author: terminal-skills
  version: "1.1.0"
  category: devops
  tags: "logs, debugging, incident-response, observability"
---

# Log Analyzer

## Overview

Parse, filter, and analyze application and infrastructure logs to quickly identify root causes of production issues. Handles JSON structured logs, plaintext server logs, syslog format, and multi-line stack traces.

## Instructions

### 1. Identify log format

Detect whether logs are JSON (one object per line), plaintext with timestamps, syslog, or mixed format. Look for common patterns:
- JSON: `{"timestamp":"...","level":"ERROR","message":"..."}`
- Syslog: `Feb 17 14:23:01 hostname service[pid]: message`
- Plaintext: `2026-02-17 14:23:01.234 ERROR [thread] class - message`

### 2. Filter and extract relevant entries

When investigating an incident:
- Filter by time window (e.g., last 30 minutes before the alert)
- Filter by severity (ERROR, FATAL, WARN)
- Extract unique error messages and group by frequency
- Identify the first occurrence of each error type

### 3. Correlate events

Look for causal chains:
- What was the FIRST error in the time window?
- Are there upstream errors that preceded downstream failures?
- Do errors correlate with deployment events, config changes, or traffic spikes?
- Track request IDs or correlation IDs across services

### 4. Summarize findings

Present results as:
```
## Incident Timeline
- HH:MM:SS — First error: [description]
- HH:MM:SS — Error cascade begins: [description]
- HH:MM:SS — Service degradation detected

## Root Cause
[Clear explanation of what went wrong]

## Error Distribution
| Error Type | Count | First Seen | Last Seen |
|-----------|-------|------------|-----------|
| ConnectionTimeout | 1,247 | 14:02:03 | 14:31:45 |
| NullPointerException | 89 | 14:02:15 | 14:28:00 |

## Recommended Actions
1. [Immediate fix]
2. [Follow-up investigation]
```

### 5. Handle large log files

For files too large to read at once, narrow with command-line tools before reading:

```bash
# Count distinct errors: drop timestamp, thread and ids so identical failures group together
grep ' ERROR ' app.log | sed -E 's/^[^ ]+ [^ ]+ //; s/\[[^]]*\] //; s/#[0-9]+/#N/' | sort | uniq -c | sort -rn | head

# Errors per minute (spike detection) for plaintext logs
grep ' ERROR ' app.log | cut -c1-16 | uniq -c

# JSON lines: error messages grouped, then everything for one request
jq -r 'select(.level=="ERROR") | .message' app.jsonl | sort | uniq -c | sort -rn
jq -c 'select(.request_id=="r-1")' app.jsonl

# Rotated and compressed logs
zgrep -h ' ERROR ' app.log.*.gz | head

# systemd service and Kubernetes pod
journalctl -u payment-service -p err --since "30 min ago" --no-pager
kubectl logs deploy/payment-service --since=30m
kubectl logs pod/payment-service-7d9c --previous   # the crashed container
```

Also: read the last 500 lines first to see current state, and sample at intervals to see trends. `uniq -c` only merges adjacent lines, so the first command sorts before counting; the per-minute one relies on log order being chronological.

## Examples

### Example 1: API Error Spike

**Input:** "Analyze these application logs — we're seeing 500 errors spike in the last hour"

**Log content:**
```
2026-02-17 13:58:22.001 INFO  [http-8080-12] c.a.OrderService - Processing order #98712
2026-02-17 13:58:22.450 ERROR [http-8080-12] c.a.OrderService - Failed to process order #98712: Connection refused to payment-service:8443
2026-02-17 13:58:22.451 ERROR [http-8080-12] c.a.ApiController - 500 Internal Server Error: PaymentServiceUnavailable
2026-02-17 13:58:23.100 WARN  [health-check] c.a.HealthMonitor - payment-service health check failed (attempt 3/3)
2026-02-17 13:58:23.101 ERROR [health-check] c.a.HealthMonitor - Circuit breaker OPEN for payment-service
```

**Output:**
```
## Incident Timeline
- 13:58:22 — First connection refused to payment-service:8443
- 13:58:23 — Health check confirms payment-service is down
- 13:58:23 — Circuit breaker tripped

## Root Cause
payment-service became unreachable at port 8443, causing order processing
to fail with ConnectionRefused errors. The circuit breaker opened after 3
consecutive health check failures.

## Recommended Actions
1. Check payment-service pod status and recent deployments
2. Verify network policies haven't changed for port 8443
3. Review payment-service logs for OOM kills or crash loops
```

### Example 2: Memory Leak Detection

**Input:** "Our service keeps restarting every 6 hours, here are the logs around the last crash"

**Log content:**
```
2026-02-17 08:00:01.000 INFO  Heap usage: 512MB / 2048MB (25%)
2026-02-17 10:00:01.000 INFO  Heap usage: 1024MB / 2048MB (50%)
2026-02-17 12:00:01.000 INFO  Heap usage: 1720MB / 2048MB (84%)
2026-02-17 13:45:30.000 WARN  GC overhead limit exceeded, heap: 1980MB / 2048MB
2026-02-17 13:47:12.000 ERROR java.lang.OutOfMemoryError: Java heap space
2026-02-17 13:47:12.001 ERROR   at com.app.cache.SessionCache.put(SessionCache.java:142)
```

**Output:**
```
## Root Cause
Memory leak in SessionCache — heap grows from 25% to 97% over ~6 hours and the
JVM then throws OutOfMemoryError. The growth is not linear (the rate rises from
~256MB/hour to ~350MB/hour), which points to a cache whose entries are never
evicted. SessionCache.put() at line 142 is where the failed allocation happened;
confirm it is the owner of the retained memory with a heap dump.

## Error Distribution
| Metric | Value |
|--------|-------|
| Growth rate | ~256MB/hour at first, ~350MB/hour later |
| Time to OOM | ~6 hours |
| Suspected source | SessionCache.put (line 142), confirm with a heap dump |

## Recommended Actions
1. Review SessionCache eviction policy — entries may not be expiring
2. Add max-size bound to the cache (e.g., Caffeine with maximumSize)
3. Enable heap dump on OOM: -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/heapdumps/
```

## Guidelines

- Logs can contain tokens, emails and card numbers: do not paste them into external tools or reports unredacted
- A stack trace shows where an allocation or call failed, not necessarily who owns the leaked memory or caused the fault
- Always establish a timeline first — chronological order reveals causality
- Look for the FIRST error, not the most frequent — cascading failures amplify
- Correlation IDs and request IDs are your best friend for distributed systems
- Don't ignore WARN-level messages — they often precede errors
- When logs are from multiple services, group by service first, then correlate
- Be specific about line numbers, timestamps, and error counts
- Suggest concrete next steps, not generic "investigate further"

Files in this skill

  • SKILL.md5.6 KB
  • _scores.json1.9 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in devops →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.