> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devhelm.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Monitoring as Code

> Define monitors, alerts, and policies in code with DevHelm's declarative YAML, Terraform, and CI/CD workflows

Monitoring as Code (MaC) is DevHelm's approach to managing your monitoring infrastructure as version-controlled, reviewable, deployable code — just like your application.

## Why code over clicks

| Dashboard (imperative) | Monitoring as Code (declarative) |
| - | - |
| Click through UI forms | Define desired state in a file |
| Changes aren't tracked | Version-controlled in Git |
| Hard to reproduce across environments | Same config deploys to staging and production |
| Manual reviews and handoffs | Pull request review before deploy |
| One change at a time | Atomic deploys across monitors, channels, and tags |

## DevHelm's two workflows

DevHelm supports both imperative and declarative workflows. They serve different needs.

### Imperative: "Do this now"

```bash theme={null}
devhelm monitors create --name "API" --type HTTP --url https://api.example.com/health --frequency 60
devhelm incidents resolve 42
```

The CLI as a management tool. The SDKs as scripting libraries. You interact with DevHelm directly, one command or call at a time. Best for ad-hoc operations, debugging, and automation scripts.

### Declarative: "Make it look like this"

```yaml theme={null}
version: "1"
monitors:
  - name: API Health
    type: HTTP
    config:
      url: https://api.example.com/health
      method: GET
    frequencySeconds: 60
    regions: [us-east, eu-west]
```

```bash theme={null}
devhelm deploy -f devhelm.yml
```

You define what the world should look like, and DevHelm makes it so. Best for production monitoring setups, team-managed configs, and CI/CD pipelines.

## Choose your tool

| Tool | Best for | Format |
| - | - | - |
| **YAML + CLI** | Fast iteration, standalone monitoring configs | `devhelm.yml` |
| **Terraform** | Teams managing cloud infra alongside monitors | HCL (`.tf`) |
| **GitHub Action** | Automated CI/CD deploys for any of the above | Workflow YAML |

<Warning>
  Don't manage the same resource with both YAML and Terraform. Pick one source of truth per resource to avoid drift and conflicts.
</Warning>

## The deploy lifecycle

Every MaC deployment follows the same pattern:

<Steps>
  <Step title="Validate">
    Check config syntax offline — no API calls. Catches typos, missing required fields, and schema violations.
  </Step>

  <Step title="Plan">
    Compare your config against the current state. See exactly what will be created, updated, or deleted.
  </Step>

  <Step title="Deploy">
    Apply the changes. DevHelm acquires a deploy lock, executes the plan, and releases the lock.
  </Step>

  <Step title="Verify">
    Check that your monitors are running and assertions are evaluating correctly.
  </Step>
</Steps>

## Next steps

<CardGroup cols={2}>
  <Card title="YAML file format" icon="file-code" href="/mac/yaml/file-format">
    Full schema reference for devhelm.yml.
  </Card>

  <Card title="Terraform provider" icon="server" href="/mac/terraform/overview">
    Manage monitors as Terraform resources.
  </Card>

  <Card title="Deploy workflow" icon="rocket" href="/mac/yaml/workflow">
    Validate, plan, deploy in detail.
  </Card>

  <Card title="MaC tutorial" icon="book-open" href="/guides/monitoring-as-code">
    Step-by-step guide from scratch.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.