Logstreem
Dashboards as code

Dashboards as code

Version a dashboard, review it in a pull request, apply it in CI.

A dashboard is JSON. GET it, commit it, review changes as a diff, and apply it from CI — the same lifecycle as the code it observes.

  1. 1

    Export what exists

    Build it in the console first — that is faster than writing JSON blind — then pull it down.

    CLI
    logstreem dashboards get dsh_4a81e0c3f6a5b2d1e0c9 > dashboards/service-health.json
  2. 2

    Commit and review

    The diff on a dashboard change is readable: a threshold moved, a query narrowed. That is the point.

  3. 3

    Apply from CI

    apply is idempotent — it creates or updates by name.

    GitHub Actions
    - name: Apply dashboards
      env:
        LOGSTREEM_TOKEN: ${{ secrets.LOGSTREEM_TOKEN }}
      run: logstreem dashboards apply dashboards/*.json

Terraform

main.tf
resource "logstreem_dashboard" "service_health" {
  name       = "Service health"
  time_range = "1h"

  element {
    type  = "timeseries"
    title = "Errors by service"
    width = 12
    apl   = <<-LSQL
      ['api-gateway-prod']
      | where status >= 500
      | summarize count() by bin_auto(_time), service
    LSQL
  }
}

Pick one direction and stay there

A dashboard managed in Terraform and edited in the console will be silently reverted on the next apply. Either lock editing or accept the console as the source of truth — do not do both.