Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/DevOps & cloud

Monitoring and Observability: Know Your Application Inside Out

Implement the three pillars of observability — metrics, logs, and traces — using Prometheus, Grafana, and structured logging.

22 February 20261 min readDevOps & cloudاقرأ بالعربية

On this page

  1. Metrics with Prometheus
  2. Key Metrics to Track
  3. Structured Logging in Laravel
  4. Grafana Dashboards
  5. Alerting Rules

The three pillars of observability — Metrics, Logs, and Traces — give complete visibility into your app's health. Companies with mature observability resolve incidents 69% faster (Splunk, 2024).

Metrics with Prometheus

yaml
scrape_configs:
  - job_name: "laravel"
    scrape_interval: 15s
    static_configs:
      - targets: ["app:9090"]
  - job_name: "mysql"
    static_configs:
      - targets: ["mysql-exporter:9104"]

Key Metrics to Track

Application:
  - Request rate (requests/second)
  - Error rate (5xx responses / total)
  - Response time (p50, p95, p99)
  - Queue depth and processing time

Infrastructure:
  - CPU and memory usage per container
  - Disk I/O and space
  - Network throughput

Structured Logging in Laravel

php
// JSON format for log aggregation
'channels' => [
    'structured' => [
        'driver' => 'single',
        'path' => storage_path('logs/app.json'),
        'formatter' => Monolog\Formatter\JsonFormatter::class,
    ],
],

Log::channel('structured')->info('Order placed', [
    'order_id' => $order->id,
    'user_id' => $user->id,
    'total' => $order->total,
    'duration_ms' => $elapsed,
]);

Grafana Dashboards

  • RED Method — Rate, Errors, Duration for services
  • USE Method — Utilization, Saturation, Errors for resources

Alerting Rules

yaml
groups:
  - name: app_alerts
    rules:
      - alert: HighErrorRate
        expr: rate(http_errors_total[5m]) / rate(http_requests_total[5m]) > 0.05
        for: 5m
        labels:
          severity: critical
        annotations:
          summary: "Error rate above 5%"

Observability turns "our site is down" into "we detected and fixed the issue before users noticed."

All articles

Keep reading

  • Docker for Developers: From Zero to Containerized Applications28 February 20261 min read
  • CI/CD Pipelines with GitHub Actions: Automate Everything22 February 20261 min read
  • Clean Code Principles: Write Code That Humans Can Read22 February 20261 min read