Author Image

CTO & Co-founder of Visivo

Automating Analytics Infrastructure as Code for Reliability

Learn how treating analytics infrastructure as code enables automation, reduces errors, and ensures consistent deployments across environments.

Analytics infrastructure automation diagram

Most analytics teams still configure dashboards by hand: click through a GUI, change a setting, deploy, and hope. Software teams stopped working that way years ago. The DORA State of DevOps Report found that elite performers deploy 208x more frequently than low performers, with greater reliability. Analytics infrastructure as code brings the same discipline to business intelligence. Define the whole analytics stack in code and you get version control, automated deployment, and an environment you can reproduce on demand.

What analytics infrastructure as code means

Analytics infrastructure as code (IaC) means every part of your analytics environment (dashboards, data connections, calculations, visualizations, and configuration) is defined in code rather than set up by hand. Anaconda's State of Data Science report found that data scientists spend 45% of their time on data preparation and cleaning. IaC automates a share of that work. Instead of clicking through an interface to create a report, you write a declarative configuration that describes the state you want.

Analytics artifacts become first-class citizens in your stack. Applications define their infrastructure with tools like Terraform; Visivo lets you define sources, models, Insights, and dashboards in YAML the same way. If the idea is new to you, start with our BI-as-code introduction:

# project.visivo.yml
name: analytics-infrastructure

sources:
  - name: snowflake-source
    type: snowflake
    account: ${env.SNOWFLAKE_ACCOUNT}
    warehouse: ANALYTICS_WH
    database: PRODUCTION
    username: ${env.SNOWFLAKE_USER}
    password: ${env.SNOWFLAKE_PASSWORD}

models:
  - name: primary_warehouse
    source: ${ref(snowflake-source)}
    sql: |
      SELECT date, revenue FROM analytics.fact_table

insights:
  - name: revenue_insight
    props:
      type: scatter
      x: ?{ ${ref(primary_warehouse).date} }
      y: ?{ ${ref(primary_warehouse).revenue} }

charts:
  - name: executive_chart
    insights:
      - ${ref(revenue_insight)}

dashboards:
  - name: Executive Dashboard
    rows:
      - height: medium
        items:
          - width: 1
            chart: ${ref(executive_chart)}

The file is the documentation, and it cannot fall out of date, because it is what runs. The deploy is a script, so it does the same thing every time.

Automating setup and deployment

Scripts and configuration files replace checklists and runbooks. Every deployment follows the same path, and a step nobody has to remember is a step nobody can skip.

Automated environment provisioning: A new environment is a script, not an afternoon of setup:

#!/bin/bash
# provision-analytics-env.sh

# Initialize a new Visivo project. This writes project.visivo.yml and opens
# the onboarding wizard in `visivo serve` at localhost:8000. Deploy from the
# local UI, or stop the server and deploy from the CLI.
visivo init

# Run the project's queries, then deploy to the staging stage
visivo run
visivo deploy -s staging

CI/CD pipeline integration: Analytics deploys run in the same CI your application code already uses:

# .github/workflows/analytics-deploy.yml
name: Deploy Analytics Infrastructure

on:
  push:
    branches: [main]
    paths:
      - "**.yml"

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Install Visivo
        run: |
          pip install visivo
          # Or use: curl -fsSL https://visivo.sh | bash

      - name: Run Tests
        run: |
          visivo test

      - name: Run Project
        run: |
          visivo run

      - name: Deploy to Staging
        run: |
          visivo deploy -s staging
        env:
          VISIVO_TOKEN: $\{{ secrets.VISIVO_TOKEN }}

      - name: Deploy to Production
        if: success()
        run: |
          visivo deploy -s production
        env:
          VISIVO_TOKEN: $\{{ secrets.VISIVO_TOKEN }}

Parameterized dashboards: Visivo has no template language. Instead of stamping out one copy of a dashboard per department, build one dashboard and let an input choose the department. Every department then reads the same metric definition:

# project.visivo.yml
name: department-analytics

sources:
  - name: warehouse
    type: duckdb
    database: analytics.duckdb

models:
  - name: revenue_model
    source: ${ref(warehouse)}
    sql: SELECT date, department, category, revenue FROM sales
    metrics:
      - name: total_revenue
        expression: "SUM(revenue)"

inputs:
  - name: department
    type: single-select
    options: ?{ SELECT DISTINCT department FROM ${ref(revenue_model)} }

insights:
  - name: revenue_insight
    props:
      type: scatter
      mode: lines
      x: ?{ ${ref(revenue_model).date} }
      y: ?{ ${ref(revenue_model).total_revenue} }
    interactions:
      - filter: ?{ ${ref(revenue_model).department} = '${ref(department).value}' }
  - name: category_insight
    props:
      type: pie
      labels: ?{ ${ref(revenue_model).category} }
      values: ?{ ${ref(revenue_model).total_revenue} }
    interactions:
      - filter: ?{ ${ref(revenue_model).department} = '${ref(department).value}' }

charts:
  - name: department_revenue
    insights:
      - ${ref(revenue_insight)}
  - name: department_breakdown
    insights:
      - ${ref(category_insight)}

dashboards:
  - name: Department Dashboard
    rows:
      - height: small
        items:
          - input: ${ref(department)}
      - height: medium
        items:
          - chart: ${ref(department_revenue)}
          - chart: ${ref(department_breakdown)}

When a project grows to many dashboards, split it into one file per team and pull them together with includes: in project.visivo.yml.

Whether you deploy one dashboard or a hundred, the process is the same, and every step of it is in Git.

Reliability through code

When the analytics stack is code, reliability stops being a goal and becomes a property of the system. Every state it has ever been in is a commit you can test and return to.

Disaster recovery: When a deploy goes wrong, recovery is a checkout and a redeploy:

# Disaster recovery procedure
# 1. Identify last known good state
LAST_GOOD_COMMIT=$(git log --format="%H" -n 1 --before="2024-12-28")

# 2. Rollback to that state
git checkout $LAST_GOOD_COMMIT

# 3. Test locally first
visivo run
visivo test

# 4. Redeploy to each environment
for stage in dev staging production; do
  echo "Deploying to $stage..."
  visivo deploy -s $stage

  # Verify deployment
  if [ $? -eq 0 ]; then
    echo "$stage deployment successful"
  else
    echo "$stage deployment failed - stopping rollback"
    exit 1
  fi
done

# 5. Document in Git
git tag -a "recovery-$(date +%Y%m%d)" -m "Recovery from incident"
git push --tags

Confidence through automation: The analytics stack gets the same guarantees as the application stack:

  • Predictable outcomes: Every deployment follows the same tested path
  • Quick recovery: Issues are resolved by reverting to a known good state
  • Audit compliance: Every change is logged with who, what, when, and why
  • Knowledge preservation: Infrastructure knowledge is encoded, not trapped in individuals

The goal is fewer production incidents, faster deploys, and more confidence in what you ship. The automation takes some work up front and pays for itself in operational overhead you no longer carry.

Analytics teams can run on the same automated, tested, version-controlled process the rest of engineering already uses. If you want to try it, /get-started takes you from install to a first deploy, and the Visivo documentation covers visivo run, visivo test, and visivo deploy in full.

Install command copied