π Log Analysis Pattern
Salah satu use case paling powerful Claude untuk DevOps adalah analyze logs yang kompleks dan cari root cause
Ketika ada error di production, biasanya log-nya besar dan susah dibaca. Claude bisa:
- Cari error pattern: Dari 10,000 baris log, find anomalies
- Root cause analysis: Error ini disebabkan apa? Database timeout? Memory leak?
- Generate fix: Berdasarkan error, Claude suggest specific fixes
π Workflow: Log Analysis
π― Template untuk Log Analysis:
"Analyze these Kubernetes pod logs from a crash:
[PASTE LOGS HERE]
Answer these questions:
1. What is the root cause of the crash?
2. What evidence in the logs supports this?
3. What's the immediate fix?
4. What's the long-term solution?
5. What monitoring should prevent this?
Be specific with line numbers and error codes."
π Config Generation Pattern
Claude sangat bagus untuk generate configs dari requirements
Apa yang Claude bisa generate?
- Dockerfile dengan best practices
- Kubernetes manifests (Deployment, Service, Ingress, etc)
- Terraform modules dan states
- Docker Compose files
- CI/CD pipeline configs (GitHub Actions, GitLab CI)
- Nginx/Apache configs
- Prometheus scrape configs + alerts
π³ Contoh: Generate Dockerfile
"Generate production-grade Dockerfile untuk:
- App: Python FastAPI dengan requirements.txt
- Base image: python:3.11-slim
- Requirements: non-root user, health checks, multi-stage build
- Port: 8000
- Include .dockerignore dengan best practices
Format: Valid Dockerfile dengan comments explaining security choices"
# Claude Output:
FROM python:3.11-slim as builder
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
FROM python:3.11-slim
RUN useradd -m -u 1000 appuser && \
apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY --chown=appuser:appuser . .
USER appuser
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s \
CMD curl -f http://localhost:8000/health || exit 1
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
π Deployment Strategy Pattern
Claude bisa generate deployment strategies dan plans
β
Bagus untuk:
- Blue-green deployment planning
- Canary rollout strategy
- Rollback procedures
- Zero-downtime deployment
β οΈ Batasan:
- Claude generate plan, tapi execution tetap manual
- Perlu domain knowledge untuk validate
- Setiap app punya unique constraints