# google/slo-generator architecture

> Architecture diagram of the GitHub repository google/slo-generator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/google/slo-generator
- Repository: https://github.com/google/slo-generator

## Overview

##### Main Components

a) Core Components:
- SLO Generator Engine (Central Processing Unit)
- Configuration Management System
- CLI Interface
- API Interface (Flask-based)
- Computation Engine (for SLIs, Error Budgets, and Burn Rates)

b) Backend Providers Layer:
- Cloud Monitoring
- Prometheus
- Datadog
- Dynatrace
- Elasticsearch
- OpenSearch
- Splunk
- Custom Backends

c) Exporter Layer:
- BigQuery
- Cloud Monitoring
- CloudEvent
- PubSub
- Prometheus
- Datadog
- Dynatrace
- Custom Exporters

**┌─ Input Layer ─────────┐    ┌─ Processing Layer ──┐    ┌─ Backend Layer ────┐**
- CLI Interface       │    │ - SLO Generator     │    │ - Cloud Monitoring │
- API Interface       │━━━>│   Core Engine       │━━━>│ - Prometheus      │
- Config Files        │    │ - Compute Engine    │    │ - Datadog         │
- ┘    │ - Error Budget     │    │ - Other Backends  │
- Calculator        │    └──────────────────┘
- ┳─────┘
- ▼
- ┌─ Export Layer ───────┐
- BigQuery          │
- Cloud Monitoring  │
- PubSub           │
- Other Exporters   │
- ┘

##### Key Elements to Highlight

a) Configuration Flow:
- How SLO configurations (YAML/JSON) flow into the system
- Shared configuration management
- Environment variable integration

b) Processing Pipeline:
- SLI computation flow
- Error budget calculation
- Burn rate processing

c) Integration Points:
- Backend service connections
- Export destinations
- API endpoints

##### Additional Details

Callouts for:
- Authentication mechanisms
- Configuration validation
- Error handling paths
- Metric computation formulas
- Export formatting

##### Specific Implementation Notes

- Relationship between the CLI and API interfaces
- How the error budget policies are applied
- Demonstrate the plugin architecture for backends and exporters
- Migration path for v1 to v2 compatibility

##### Deployment Options

A separate section showing deployment scenarios:
- Cloud Run
- Kubernetes
- Cloud Functions
- CloudBuild Pipeline

This system design should emphasize the tool's flexibility in handling different backend providers and export destinations while maintaining a consistent core processing engine.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef input fill:#a8d1f0,stroke:#333
    classDef processing fill:#90EE90,stroke:#333
    classDef backend fill:#FFB347,stroke:#333
    classDef export fill:#DDA0DD,stroke:#333
    classDef deployment fill:#E6E6FA,stroke:#333

    %% Input Layer
    subgraph Input
        CLI["CLI Interface"]
        API["API Interface"]
        Config["Configuration Files"]
    end

    %% Processing Layer
    subgraph Core
        SLOEngine["SLO Generator Engine"]
        ComputeEngine["Computation Engine"]
        ErrorBudget["Error Budget Calculator"]
    end

    %% Backend Layer
    subgraph Backends
        CloudMon["Cloud Monitoring"]
        Prometheus["Prometheus"]
        Datadog["Datadog"]
        Dynatrace["Dynatrace"]
        Elastic["Elasticsearch"]
        OpenSearch["OpenSearch"]
        Splunk["Splunk"]
    end

    %% Export Layer
    subgraph Exporters
        BQ["BigQuery"]
        CloudMonEx["Cloud Monitoring"]
        CloudEvent["CloudEvent"]
        PubSub["PubSub"]
        PromEx["Prometheus"]
        DatadogEx["Datadog"]
        DynatraceEx["Dynatrace"]
    end

    %% Deployment Layer
    subgraph Deployment
        CloudRun["Cloud Run"]
        K8s["Kubernetes"]
        CloudFunc["Cloud Functions"]
    end

    %% Connections
    CLI --> SLOEngine
    API --> SLOEngine
    Config --> SLOEngine
    SLOEngine --> ComputeEngine
    ComputeEngine --> ErrorBudget
    ErrorBudget --> Backends
    ErrorBudget --> Exporters

    %% Click Events
    click CLI "https://github.com/google/slo-generator/blob/master/slo_generator/cli.py"
    click API "https://github.com/google/slo-generator/blob/master/slo_generator/api/main.py"
    click Config "https://github.com/google/slo-generator/blob/master/samples/config.yaml"
    click SLOEngine "https://github.com/google/slo-generator/blob/master/slo_generator/compute.py"
    click CloudMon "https://github.com/google/slo-generator/blob/master/slo_generator/backends/cloud_monitoring.py"
    click Prometheus "https://github.com/google/slo-generator/blob/master/slo_generator/backends/prometheus.py"
    click Datadog "https://github.com/google/slo-generator/blob/master/slo_generator/backends/datadog.py"
    click Dynatrace "https://github.com/google/slo-generator/blob/master/slo_generator/backends/dynatrace.py"
    click Elastic "https://github.com/google/slo-generator/blob/master/slo_generator/backends/elasticsearch.py"
    click OpenSearch "https://github.com/google/slo-generator/blob/master/slo_generator/backends/open_search.py"
    click Splunk "https://github.com/google/slo-generator/blob/master/slo_generator/backends/splunk.py"
    click BQ "https://github.com/google/slo-generator/blob/master/slo_generator/exporters/bigquery.py"
    click CloudMonEx "https://github.com/google/slo-generator/blob/master/slo_generator/exporters/cloud_monitoring.py"
    click CloudEvent "https://github.com/google/slo-generator/blob/master/slo_generator/exporters/cloudevent.py"
    click PubSub "https://github.com/google/slo-generator/blob/master/slo_generator/exporters/pubsub.py"
    click PromEx "https://github.com/google/slo-generator/blob/master/slo_generator/exporters/prometheus.py"
    click DatadogEx "https://github.com/google/slo-generator/blob/master/slo_generator/exporters/datadog.py"
    click DynatraceEx "https://github.com/google/slo-generator/blob/master/slo_generator/exporters/dynatrace.py"
    click CloudRun "https://github.com/google/slo-generator/blob/master/docs/deploy/cloudrun.md"
    click K8s "https://github.com/google/slo-generator/blob/master/docs/deploy/kubernetes.md"
    click CloudFunc "https://github.com/google/slo-generator/blob/master/docs/deploy/cloudfunctions.md"

    %% Style Applications
    class CLI,API,Config input
    class SLOEngine,ComputeEngine,ErrorBudget processing
    class CloudMon,Prometheus,Datadog,Dynatrace,Elastic,OpenSearch,Splunk backend
    class BQ,CloudMonEx,CloudEvent,PubSub,PromEx,DatadogEx,DynatraceEx export
    class CloudRun,K8s,CloudFunc deployment
```
