# grafana/grafana-zabbix architecture

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

- Interactive diagram: https://gitdiagram.com/grafana/grafana-zabbix
- Repository: https://github.com/grafana/grafana-zabbix

## Overview

##### Project Type and Purpose
- Type: Full-stack Grafana plugin (data source + panel plugin)
- Purpose:
– Provide a Zabbix data source for Grafana dashboards (metrics, templating, alerting)
– Offer an interactive “Triggers” panel to view and acknowledge Zabbix problems

##### File Structure
Top-level split:
- Backend (Go)
– pkg/plugin.go: plugin entrypoint (Grafana Plugin SDK)
– pkg/settings: plugin configuration models and loading
– pkg/datasource: core request/response handling, functions, models
– pkg/zabbixapi & pkg/zabbix: connectors to Zabbix HTTP API and direct DB connectors
– pkg/cache: in-memory caching/proxy for API calls
– pkg/timeseries, pkg/metrics, pkg/gtime: data processing, aggregation, time utilities
– go.mod / go.sum: dependency management
- Frontend (React + TS) under src/
– src/datasource: Grafana DataSource plugin UI (QueryEditor, ConfigEditor, responseHandler)
– src/panel-triggers: Custom panel plugin UI (ProblemsPanel, AlertList, modals, migrations)
– src/styles: SCSS variables and component styling files
– src/module.ts + plugin.json: plugin manifest and module registration
- Dev & CI config
– webpack.config.ts, .config/webpack: build pipeline for TS and SCSS
– jest.config.js, test-setup: unit test setup for frontend
– Magefile.go, Makefile, docker-compose.yml, devenv: local dev environment
– .github/workflows: CI for testing, compatibility checks, publishing

##### README for Additional Insights
- Confirms plugin features (templating, annotations, alerting, mixed-source metrics)
- Installation and usage context: loaded by Grafana via grafana-cli
- Live demo and documentation URLs

##### Capturing Essential Details
- Plugin endpoints (Query, Annotations, HealthCheck, Alerting)
- Cache/proxy layer sitting between connector and data processing
- Separation between DataSource plugin and Panel plugin UIs

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["User Browser"]:::external
    subgraph "Grafana Host"
        direction TB
        Static["Static File Server"]:::grafanaHost
        Proxy["Plugin Proxy"]:::grafanaHost
        Loader["Plugin Loader"]:::grafanaHost
    end
    subgraph "Plugin Frontend (React/TS)"
        direction TB
        FEDataSourceUI["DataSource UI Components"]:::frontend
        FEDataSourceCore["DataSource Core Logic"]:::frontend
        FEZabbixConnectors["Zabbix Connectors & Proxy"]:::frontend
        FEPanelTriggers["Panel-Triggers UI"]:::frontend
        SharedComponents["Shared React Components"]:::frontend
        Manifests["Plugin Manifests & Registration"]:::frontend
        Styling["Styling (SCSS)"]:::frontend
    end
    subgraph "Plugin Backend (Go)"
        direction TB
        PluginEntrypoint["Plugin Entrypoint"]:::backend
        BackendSettings["Settings Module"]:::backend
        CoreDatasource["Core Datasource Handler"]:::backend
        HTTPAPIConnector["Zabbix HTTP API Connector"]:::backend
        DBConnector["Direct Zabbix DB Connector"]:::backend
        HTTPClient["HTTP Client Abstraction"]:::backend
        Cache["In-Memory Cache/Proxy"]:::backend
        GTime["Time Utilities"]:::backend
        Metrics["Metrics Processing"]:::backend
        Timeseries["Time-Series Processing"]:::backend
    end
    subgraph "External Services"
        direction TB
        ZabbixAPI["Zabbix Server (HTTP API)"]:::external
        ZabbixDB["Zabbix Database"]:::external
    end
    subgraph "Dev & CI"
        direction TB
        DevEnv["Dev Env & Scripts"]:::dev
        WebpackConfig["Webpack Configuration"]:::dev
        Jest["Jest Test Setup"]:::dev
        Playwright["E2E Test Harness"]:::dev
        CIWorkflows["CI Workflows"]:::dev
    end

    Browser -->|"HTTP GET"| Static
    Static --> FEDataSourceUI
    Static --> FEPanelTriggers
    FEDataSourceUI --> Proxy
    FEDataSourceCore --> Proxy
    FEPanelTriggers --> Proxy
    SharedComponents --> FEDataSourceUI
    SharedComponents --> FEPanelTriggers
    Proxy --> PluginEntrypoint
    PluginEntrypoint --> BackendSettings
    PluginEntrypoint --> CoreDatasource
    CoreDatasource --> HTTPAPIConnector
    CoreDatasource --> DBConnector
    HTTPClient --> HTTPAPIConnector
    CoreDatasource --> Cache
    Cache --> HTTPAPIConnector
    PluginEntrypoint --> GTime
    CoreDatasource --> Metrics
    CoreDatasource --> Timeseries
    HTTPAPIConnector --> ZabbixAPI
    DBConnector --> ZabbixDB
    DevEnv --> WebpackConfig
    DevEnv --> Jest
    DevEnv --> Playwright
    DevEnv --> CIWorkflows

    click PluginEntrypoint "https://github.com/grafana/grafana-zabbix/blob/main/pkg/plugin.go"
    click BackendSettings "https://github.com/grafana/grafana-zabbix/tree/main/pkg/settings"
    click CoreDatasource "https://github.com/grafana/grafana-zabbix/tree/main/pkg/datasource"
    click HTTPAPIConnector "https://github.com/grafana/grafana-zabbix/blob/main/pkg/zabbixapi/zabbix_api.go"
    click DBConnector "https://github.com/grafana/grafana-zabbix/tree/main/pkg/zabbix"
    click HTTPClient "https://github.com/grafana/grafana-zabbix/blob/main/pkg/httpclient/httpclient.go"
    click Cache "https://github.com/grafana/grafana-zabbix/blob/main/pkg/cache/cache.go"
    click GTime "https://github.com/grafana/grafana-zabbix/blob/main/pkg/gtime/gtime.go"
    click Metrics "https://github.com/grafana/grafana-zabbix/blob/main/pkg/metrics/metrics.go"
    click Timeseries "https://github.com/grafana/grafana-zabbix/tree/main/pkg/timeseries"
    click FEDataSourceUI "https://github.com/grafana/grafana-zabbix/tree/main/src/datasource/components"
    click FEDataSourceCore "https://github.com/grafana/grafana-zabbix/tree/main/src/datasource"
    click FEZabbixConnectors "https://github.com/grafana/grafana-zabbix/tree/main/src/datasource/zabbix/connectors"
    click FEPanelTriggers "https://github.com/grafana/grafana-zabbix/tree/main/src/panel-triggers"
    click SharedComponents "https://github.com/grafana/grafana-zabbix/tree/main/src/components"
    click Manifests "https://github.com/grafana/grafana-zabbix/tree/main/src"
    click Styling "https://github.com/grafana/grafana-zabbix/tree/main/src/styles"
    click WebpackConfig "https://github.com/grafana/grafana-zabbix/blob/main/webpack.config.ts"
    click Jest "https://github.com/grafana/grafana-zabbix/tree/main/src/test-setup"
    click Playwright "https://github.com/grafana/grafana-zabbix/tree/main/tests/e2e"
    click DevEnv "https://github.com/grafana/grafana-zabbix/tree/main/Makefile"
    click CIWorkflows "https://github.com/grafana/grafana-zabbix/tree/main/.github/workflows"

    classDef grafanaHost fill:#bbdefb,stroke:#333,stroke-width:1px
    classDef backend fill:#c8e6c9,stroke:#333,stroke-width:1px
    classDef frontend fill:#ffe0b2,stroke:#333,stroke-width:1px
    classDef external fill:#e0e0e0,stroke:#333,stroke-width:1px
    classDef dev fill:#f0f4c3,stroke:#333,stroke-width:1px
```
