# azure/prometheus-collector architecture

> Architecture diagram of the GitHub repository azure/prometheus-collector, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/azure/prometheus-collector
- Repository: https://github.com/azure/prometheus-collector

## Overview

The repository combines Azure Monitor’s Prometheus collector with a separate Prometheus-rule-to-ARM conversion CLI. The collector’s principal workflow is to start its configured collector runtime, discover scrape targets, scrape and export metrics for managed Azure Monitor; the README confirms the managed-store purpose. The rule converter accepts YAML/JSON rules, validates and transforms them into an ARM template. Edges are limited to relationships visible in excerpts or documented in the README; some substantial but unsampled subsystems are included without speculative wiring.

Main entry points: [`tools/az-prom-rules-converter/src/index.ts`](https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/index.ts) (Conversion Flow), [`otelcollector/prometheusreceiver/metrics_receiver.go`](https://github.com/azure/prometheus-collector/blob/main/otelcollector/prometheusreceiver/metrics_receiver.go) (Metrics Receiver), [`otelcollector/otel-allocator/internal/server/server.go`](https://github.com/azure/prometheus-collector/blob/main/otelcollector/otel-allocator/internal/server/server.go) (Target Allocator), [`tools/az-prom-rules-converter/src/cli.ts`](https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/cli.ts) (Converter CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Collector Runtime"]
  node_operator["Runtime Launcher<br/>[main.go]"]
  node_collector["Collector Process<br/>[main.go]"]
  node_fluent_bit["Fluent Bit Output<br/>[out_appinsights.go]"]
end

subgraph group_scraping["Prometheus Scraping"]
  node_metrics_receiver["Metrics Receiver"]
  node_discovery["Target Discovery"]
  node_scrape["Scrape Manager"]
  node_api_server["Prometheus API<br/>[manager.go]"]
end

subgraph group_allocator["Target Allocation"]
  node_allocator_manager["Allocator Integration<br/>[manager.go]"]
  node_allocator_service["Target Allocator<br/>[server.go]"]
  node_allocation["Allocation Strategies<br/>[allocator.go]"]
  node_target_discovery["Allocator Discovery<br/>[discovery.go]"]
  node_watcher["Configuration Watcher<br/>[watcher.go]"]
end

subgraph group_config["Configuration and Telemetry"]
  node_config_builder["Configuration Reader<br/>[main.go]"]
  node_config_parsers["Config Map Parsers<br/>[configmapparser.go]"]
end

subgraph group_converter["Rule Conversion CLI"]
  node_cli["Converter CLI<br/>[cli.ts]"]
  node_flow["Conversion Flow<br/>[index.ts]"]
  node_yaml_json["YAML to JSON<br/>[yaml2json.ts]"]
  node_input_validation["Input Validation"]
  node_prom_validation["Prometheus Validation"]
  node_arm_conversion["ARM Conversion<br/>[to-arm-template.ts]"]
  node_rule_group["Rule Group Mapping"]
  node_rule_properties["Rule Properties Mapping"]
  node_arm_validation["ARM Validation"]
end

node_azure_store[("Azure Monitor Store")]
node_user(("Operator"))
node_output["Template Output"]

node_operator -->|"starts"| node_collector
node_operator -->|"starts"| node_fluent_bit
node_metrics_receiver -->|"starts"| node_discovery
node_metrics_receiver -->|"starts"| node_scrape
node_metrics_receiver -->|"starts"| node_allocator_manager
node_metrics_receiver -->|"starts"| node_api_server
node_collector -.->|"sends metrics"| node_azure_store
node_allocator_manager -.->|"coordinates"| node_allocator_service
node_allocator_service -.->|"discovers targets"| node_target_discovery
node_allocator_service -.->|"assigns targets"| node_allocation
node_watcher -.->|"updates config"| node_allocator_service
node_user -->|"provides rules"| node_cli
node_cli -->|"runs flow"| node_flow
node_flow -->|"validates input"| node_input_validation
node_flow -->|"parses YAML"| node_yaml_json
node_flow -->|"validates rules"| node_prom_validation
node_flow -->|"converts rules"| node_arm_conversion
node_flow -->|"validates template"| node_arm_validation
node_arm_conversion -->|"maps groups"| node_rule_group
node_rule_group -.->|"maps properties"| node_rule_properties
node_cli -->|"writes template"| node_output

click node_operator "https://github.com/azure/prometheus-collector/blob/main/otelcollector/main/main.go"
click node_collector "https://github.com/azure/prometheus-collector/blob/main/otelcollector/main/main.go"
click node_metrics_receiver "https://github.com/azure/prometheus-collector/blob/main/otelcollector/prometheusreceiver/metrics_receiver.go"
click node_discovery "https://github.com/azure/prometheus-collector/blob/main/otelcollector/prometheusreceiver/metrics_receiver.go"
click node_scrape "https://github.com/azure/prometheus-collector/blob/main/otelcollector/prometheusreceiver/metrics_receiver.go"
click node_api_server "https://github.com/azure/prometheus-collector/blob/main/otelcollector/prometheusreceiver/internal/apiserver/manager.go"
click node_allocator_manager "https://github.com/azure/prometheus-collector/blob/main/otelcollector/prometheusreceiver/internal/targetallocator/manager.go"
click node_allocator_service "https://github.com/azure/prometheus-collector/blob/main/otelcollector/otel-allocator/internal/server/server.go"
click node_allocation "https://github.com/azure/prometheus-collector/blob/main/otelcollector/otel-allocator/internal/allocation/allocator.go"
click node_target_discovery "https://github.com/azure/prometheus-collector/blob/main/otelcollector/otel-allocator/internal/target/discovery.go"
click node_watcher "https://github.com/azure/prometheus-collector/blob/main/otelcollector/otel-allocator/internal/watcher/watcher.go"
click node_config_builder "https://github.com/azure/prometheus-collector/blob/main/otelcollector/configuration-reader-builder/main.go"
click node_config_parsers "https://github.com/azure/prometheus-collector/blob/main/otelcollector/shared/configmap/mp/configmapparser.go"
click node_fluent_bit "https://github.com/azure/prometheus-collector/blob/main/otelcollector/fluent-bit/src/out_appinsights.go"
click node_cli "https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/cli.ts"
click node_flow "https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/index.ts"
click node_yaml_json "https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/steps/yaml2json.ts"
click node_input_validation "https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/steps/validate-input-not-empty.ts"
click node_prom_validation "https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/steps/validate-prom-schemas.ts"
click node_arm_conversion "https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/steps/to-arm-template.ts"
click node_rule_group "https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/steps/to-azure/to-azure-prom-rule-group.ts"
click node_rule_properties "https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/steps/to-azure/to-azure-prom-rule-group-properties.ts"
click node_arm_validation "https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/steps/validate-arm-template.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_operator,node_collector,node_fluent_bit toneBlue
class node_metrics_receiver,node_discovery,node_scrape,node_api_server,node_azure_store toneAmber
class node_allocator_manager,node_allocator_service,node_allocation,node_target_discovery,node_watcher toneMint
class node_config_builder,node_config_parsers toneRose
class node_cli,node_flow,node_yaml_json,node_input_validation,node_prom_validation,node_arm_conversion,node_rule_group,node_rule_properties,node_arm_validation,node_user,node_output toneIndigo
```

## Components

### Collector Runtime

- [Runtime Launcher](https://github.com/azure/prometheus-collector/blob/main/otelcollector/main/main.go): `otelcollector/main/main.go`
- [Collector Process](https://github.com/azure/prometheus-collector/blob/main/otelcollector/main/main.go): `otelcollector/main/main.go`
- [Fluent Bit Output](https://github.com/azure/prometheus-collector/blob/main/otelcollector/fluent-bit/src/out_appinsights.go): `otelcollector/fluent-bit/src/out_appinsights.go`

### Prometheus Scraping

- [Metrics Receiver](https://github.com/azure/prometheus-collector/blob/main/otelcollector/prometheusreceiver/metrics_receiver.go): `otelcollector/prometheusreceiver/metrics_receiver.go`
- [Target Discovery](https://github.com/azure/prometheus-collector/blob/main/otelcollector/prometheusreceiver/metrics_receiver.go): `otelcollector/prometheusreceiver/metrics_receiver.go`
- [Scrape Manager](https://github.com/azure/prometheus-collector/blob/main/otelcollector/prometheusreceiver/metrics_receiver.go): `otelcollector/prometheusreceiver/metrics_receiver.go`
- [Prometheus API](https://github.com/azure/prometheus-collector/blob/main/otelcollector/prometheusreceiver/internal/apiserver/manager.go): `otelcollector/prometheusreceiver/internal/apiserver/manager.go`

### Target Allocation

- [Allocator Integration](https://github.com/azure/prometheus-collector/blob/main/otelcollector/prometheusreceiver/internal/targetallocator/manager.go): `otelcollector/prometheusreceiver/internal/targetallocator/manager.go`
- [Target Allocator](https://github.com/azure/prometheus-collector/blob/main/otelcollector/otel-allocator/internal/server/server.go): `otelcollector/otel-allocator/internal/server/server.go`
- [Allocation Strategies](https://github.com/azure/prometheus-collector/blob/main/otelcollector/otel-allocator/internal/allocation/allocator.go): `otelcollector/otel-allocator/internal/allocation/allocator.go`
- [Allocator Discovery](https://github.com/azure/prometheus-collector/blob/main/otelcollector/otel-allocator/internal/target/discovery.go): `otelcollector/otel-allocator/internal/target/discovery.go`
- [Configuration Watcher](https://github.com/azure/prometheus-collector/blob/main/otelcollector/otel-allocator/internal/watcher/watcher.go): `otelcollector/otel-allocator/internal/watcher/watcher.go`

### Configuration and Telemetry

- [Configuration Reader](https://github.com/azure/prometheus-collector/blob/main/otelcollector/configuration-reader-builder/main.go): `otelcollector/configuration-reader-builder/main.go`
- [Config Map Parsers](https://github.com/azure/prometheus-collector/blob/main/otelcollector/shared/configmap/mp/configmapparser.go): `otelcollector/shared/configmap/mp/configmapparser.go`

### Rule Conversion CLI

- [Converter CLI](https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/cli.ts): `tools/az-prom-rules-converter/src/cli.ts`
- [Conversion Flow](https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/index.ts): `tools/az-prom-rules-converter/src/index.ts`
- [YAML to JSON](https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/steps/yaml2json.ts): `tools/az-prom-rules-converter/src/steps/yaml2json.ts`
- [Input Validation](https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/steps/validate-input-not-empty.ts): `tools/az-prom-rules-converter/src/steps/validate-input-not-empty.ts`
- [Prometheus Validation](https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/steps/validate-prom-schemas.ts): `tools/az-prom-rules-converter/src/steps/validate-prom-schemas.ts`
- [ARM Conversion](https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/steps/to-arm-template.ts): `tools/az-prom-rules-converter/src/steps/to-arm-template.ts`
- [Rule Group Mapping](https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/steps/to-azure/to-azure-prom-rule-group.ts): `tools/az-prom-rules-converter/src/steps/to-azure/to-azure-prom-rule-group.ts`
- [Rule Properties Mapping](https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/steps/to-azure/to-azure-prom-rule-group-properties.ts): `tools/az-prom-rules-converter/src/steps/to-azure/to-azure-prom-rule-group-properties.ts`
- [ARM Validation](https://github.com/azure/prometheus-collector/blob/main/tools/az-prom-rules-converter/src/steps/validate-arm-template.ts): `tools/az-prom-rules-converter/src/steps/validate-arm-template.ts`

### Other components

- **Azure Monitor Store**
- **Operator**
- **Template Output**

## Connections

- Runtime Launcher → Collector Process: starts (evidence: `otelcollector/main/main.go`)
- Runtime Launcher → Fluent Bit Output: starts (evidence: `otelcollector/main/main.go`)
- Metrics Receiver → Target Discovery: starts (evidence: `otelcollector/prometheusreceiver/metrics_receiver.go`)
- Metrics Receiver → Scrape Manager: starts (evidence: `otelcollector/prometheusreceiver/metrics_receiver.go`)
- Metrics Receiver → Allocator Integration: starts (evidence: `otelcollector/prometheusreceiver/metrics_receiver.go`)
- Metrics Receiver → Prometheus API: starts (evidence: `otelcollector/prometheusreceiver/metrics_receiver.go`)
- Collector Process → Azure Monitor Store: sends metrics
- Allocator Integration → Target Allocator: coordinates
- Target Allocator → Allocator Discovery: discovers targets
- Target Allocator → Allocation Strategies: assigns targets
- Configuration Watcher → Target Allocator: updates config
- Operator → Converter CLI: provides rules (evidence: `tools/az-prom-rules-converter/src/cli.ts`)
- Converter CLI → Conversion Flow: runs flow (evidence: `tools/az-prom-rules-converter/src/cli.ts`)
- Conversion Flow → Input Validation: validates input (evidence: `tools/az-prom-rules-converter/src/index.ts`)
- Conversion Flow → YAML to JSON: parses YAML (evidence: `tools/az-prom-rules-converter/src/index.ts`)
- Conversion Flow → Prometheus Validation: validates rules (evidence: `tools/az-prom-rules-converter/src/index.ts`)
- Conversion Flow → ARM Conversion: converts rules (evidence: `tools/az-prom-rules-converter/src/index.ts`)
- Conversion Flow → ARM Validation: validates template (evidence: `tools/az-prom-rules-converter/src/index.ts`)
- ARM Conversion → Rule Group Mapping: maps groups (evidence: `tools/az-prom-rules-converter/src/steps/to-arm-template.ts`)
- Rule Group Mapping → Rule Properties Mapping: maps properties
- Converter CLI → Template Output: writes template (evidence: `tools/az-prom-rules-converter/src/cli.ts`)
