Skip to content

DevOps & Observability

Get the code for this lesson

Every file this lesson builds is on GitHub. Type it out as you read, because that's where the learning happens. Then use the repo to check your work when something won't run, or to grab the data files and templates so you can focus on the Python.

DevOps and Observability for Network Automation: CI/CD, GitOps, and Monitoring

Published: March 1, 2026
Author: Nautomation Prime Team

Why This Tutorial Exists

Enterprise automation is more than scriptsβ€”it requires production-grade pipelines, version control, safe rollouts, and comprehensive observability. This tutorial covers CI/CD, GitOps, observability architecture, structured logging, metrics, and alerting, aligned with the PRIME Framework.


Prerequisites

  • Advanced Python and networking knowledge
  • Familiarity with Git, Docker, and container concepts
  • Understanding of CI/CD tools (GitHub Actions, GitLab CI, Jenkins)
  • Basic knowledge of monitoring tools (Prometheus, Grafana)

DevOps Architecture: Multi-Stage Pipeline

Source Control (Git)
    ↓
CI: Lint, Test, Build
    ↓
CD: Stage β†’ Approve β†’ Production
    ↓
Observability: Logs, Metrics, Alerts

Part 1: GitHub Actions Multi-Stage CI/CD

name: Network Automation CI/CD
on:
  push:
    branches: [ main ]

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v4
        with:
          python-version: '3.11'
      - run: pip install -r requirements-dev.txt
      - run: flake8 src/
      - run: black src/ --check
      - run: mypy src/ --strict

  test:
    runs-on: ubuntu-latest
    needs: lint
    steps:
      - uses: actions/checkout@v4
      - run: pip install -r requirements-dev.txt
      - run: pytest tests/unit/ --cov=src

  deploy:
    runs-on: ubuntu-latest
    needs: test
    if: github.ref == 'refs/heads/main'
    environment: production
    steps:
      - uses: actions/checkout@v4
      - run: python scripts/deploy.py

Part 2: Structured Logging

import logging
import structlog

# structlog hands records to the standard logging module, which drops
# everything below WARNING until it's configured
logging.basicConfig(level=logging.INFO, format="%(message)s")

structlog.configure(
    processors=[
        structlog.stdlib.filter_by_level,
        structlog.stdlib.add_logger_name,
        structlog.processors.TimeStamper(fmt="iso"),
        structlog.processors.JSONRenderer()
    ],
    logger_factory=structlog.stdlib.LoggerFactory(),
)

logger = structlog.get_logger()
logger.info("automation_started", change_id="CHG0001", devices=5)

Part 3: Prometheus Metrics

import os

from prometheus_client import Counter, Histogram, start_http_server

automation_runs = Counter(
    'network_automation_runs_total',
    'Total automation runs',
    ['status']
)

automation_duration = Histogram(
    'network_automation_duration_seconds',
    'Automation execution time',
    buckets=(1, 5, 10, 30, 60, 300)
)

metrics_port = int(os.environ.get("METRICS_PORT", "8000"))
start_http_server(metrics_port)
automation_runs.labels(status='success').inc()
automation_duration.observe(15.5)

Part 4: Alerting Rules

groups:
  - name: network_automation
    rules:
      - alert: HighErrorRate
        expr: rate(network_automation_runs_total{status="failed"}[5m]) > 0.1
        annotations:
          summary: "High automation error rate"

      - alert: JobTimeout
        expr: increase(network_automation_runs_total{status="timeout"}[1h]) > 5
        annotations:
          summary: "Multiple timeouts detected"

Key Takeaways

βœ… Multi-stage CI/CD prevents errors - Lint, test, then deploy
βœ… Structured logging enables investigation - JSON format for searching
βœ… Metrics provide visibility - Performance and error tracking
βœ… Alerts enable proactive response - Early problem detection
βœ… Audit trails ensure compliance - Complete change history


The PRIME Philosophy in Action

  • βœ… Safety: Multi-stage gates prevent production incidents
  • βœ… Measurability: Metrics track automation performance
  • βœ… Empowerment: Teams manage deployments via GitOps

πŸ“£ Want More?


Get notified when the book ships

Christopher is writing a book on production-grade Cisco network automation: one script, followed from twelve lines to a system that upgrades hundreds of devices, and every failure along the way. Join the list to hear when it ships and when new Academy material goes up.

One list, occasional emails, unsubscribe any time. Sign-up is handled by Kit; see the Privacy Policy.

Need this applied in a live Cisco environment?

This guide is part of the Nautomation Prime Academy and stays free to read, share, and reuse. If you want the pattern built, governed, or adapted for your estate, I'm available for contract engagements, and I take on smaller fixed-scope projects by enquiry. If you are a registered UK charity or CIC, there is a free and low-cost route instead.