# prometheus-operator/kube-prometheus architecture

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

- Interactive diagram: https://gitdiagram.com/prometheus-operator/kube-prometheus
- Repository: https://github.com/prometheus-operator/kube-prometheus

## Overview

##### Main Components
- Prometheus Operator – This is core to managing the lifecycle of Prometheus instances, Alertmanager, ServiceMonitors, and PrometheusRules via Custom Resource Definitions (CRDs).
- Prometheus – The highly available monitoring server that scrapes metrics from endpoints.
- Alertmanager – Responsible for processing and sending alerts generated from Prometheus.
- Exporters – Include components such as:
- Node Exporter (collects node-level metrics)
- Blackbox Exporter (for endpoint monitoring)
- kube-state-metrics (exposes Kubernetes state metrics)
- Grafana – For dashboards and visualization of monitoring data.
- Prometheus Adapter – For exposing metrics to the Kubernetes Metrics API.
- jsonnet Library/Templates – Represent the customization and templating engine that generates manifests and dashboards.
- Supporting tooling & scripts – CI/CD workflows, configurations, and developer workspaces that help test and deploy the system.

##### Component Relationships and Interactions
- The Prometheus Operator is the central manager that deploys and configures Prometheus, Alertmanager, and related CRDs inside a Kubernetes cluster.
- Prometheus instances are set up and managed via the Operator and then scrape metrics from the node exporters, blackbox exporter, kube-state-metrics, and other configured targets.
- Alertmanager receives alerts (triggered by Prometheus rules configured via jsonnet) and processes them based on the defined routing.
- Grafana consumes data from Prometheus to display dashboards. The project also provides pre-configured dashboards stored in manifests and jsonnet.
- Prometheus Adapter serves as a bridge to expose resource metrics through the Kubernetes metrics API.
- The jsonnet directories, along with build scripts and configuration files (like Makefile, build.sh, etc.), orchestrate how the overall manifests are generated and updated. They act as a “library” that can be customized by downstream users.

##### Architectural Patterns
- Declarative Infrastructure: The manifest and CRD files underscore a declarative style where Kubernetes is the single source of truth.
- Library/Package Pattern: The use of jsonnet and the structure of the repository indicate that this monitoring stack can be imported and custom-tailored much like a library.
- Separation of Concerns: The system distinguishes between “control” (Prometheus Operator and CRDs) and “data collection/visualization” (Prometheus, Alertmanager, exporters, Grafana).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Kubernetes Cluster Boundary
    subgraph "Kubernetes Cluster"
        direction TB
        PO["Prometheus Operator<br/>(control for CRDs)"]:::control
        P["Prometheus<br/>(monitoring server)"]:::monitor
        AM["Alertmanager<br/>(alert processing)"]:::monitor
        subgraph "Exporters\n(Node Exporter, Blackbox Exporter, kube-state-metrics)"
            direction TB
            NE["Node Exporter"]:::exporter
            BE["Blackbox Exporter"]:::exporter
            KSM["kube-state-metrics"]:::exporter
        end
        G["Grafana<br/>(dashboards & visualization)"]:::dashboard
        PA["Prometheus Adapter<br/>(metrics API bridge)"]:::monitor
    end

    %% External Configuration & Tools
    subgraph "Configuration & Deployment"
        direction TB
        JL["jsonnet Library/Templates<br/>(manifest generator)"]:::config
        CI["CI/CD & Developer Tools"]:::external
    end

    %% Relationships within Kubernetes Cluster
    PO -->|"manages"| P
    PO -->|"manages"| AM
    P -->|"scrapes"| NE
    P -->|"scrapes"| BE
    P -->|"scrapes"| KSM
    P -->|"sendsAlerts"| AM
    P -->|"feedsData"| G
    P -->|"exposes"| PA

    %% Relationships from external configuration/tools to Cluster
    JL -->|"generates manifests for"| PO
    JL -->|"generates manifests for"| P
    JL -->|"generates manifests for"| AM
    JL -->|"generates manifests for"| NE
    JL -->|"generates manifests for"| BE
    JL -->|"generates manifests for"| KSM
    JL -->|"generates manifests for"| G
    JL -->|"generates manifests for"| PA
    CI -->|"deploys and tests"| JL

    %% Click Events for Component Mapping
    click PO "https://github.com/prometheus-operator/kube-prometheus/blob/main/jsonnet/kube-prometheus/components/prometheus-operator.libsonnet"
    click P "https://github.com/prometheus-operator/kube-prometheus/blob/main/jsonnet/kube-prometheus/components/prometheus.libsonnet"
    click AM "https://github.com/prometheus-operator/kube-prometheus/blob/main/jsonnet/kube-prometheus/components/alertmanager.libsonnet"
    click NE "https://github.com/prometheus-operator/kube-prometheus/blob/main/jsonnet/kube-prometheus/components/node-exporter.libsonnet"
    click BE "https://github.com/prometheus-operator/kube-prometheus/blob/main/jsonnet/kube-prometheus/components/blackbox-exporter.libsonnet"
    click KSM "https://github.com/prometheus-operator/kube-prometheus/blob/main/jsonnet/kube-prometheus/components/kube-state-metrics.libsonnet"
    click G "https://github.com/prometheus-operator/kube-prometheus/blob/main/jsonnet/kube-prometheus/components/grafana.libsonnet"
    click PA "https://github.com/prometheus-operator/kube-prometheus/blob/main/jsonnet/kube-prometheus/components/prometheus-adapter.libsonnet"
    click JL "https://github.com/prometheus-operator/kube-prometheus/tree/main/jsonnet/kube-prometheus/"
    click CI "https://github.com/prometheus-operator/kube-prometheus/tree/main/developer-workspace/"

    %% Styles
    classDef control fill:#f9c74f,stroke:#000,stroke-width:2px;
    classDef monitor fill:#90be6d,stroke:#000,stroke-width:2px;
    classDef exporter fill:#577590,stroke:#000,stroke-width:2px;
    classDef dashboard fill:#277da1,stroke:#000,stroke-width:2px;
    classDef config fill:#6d6875,stroke:#fff,stroke-width:2px,color:#fff;
    classDef external fill:#8ac926,stroke:#000,stroke-width:2px;
```
