# prometheus-community/yet-another-cloudwatch-exporter architecture

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

- Interactive diagram: https://gitdiagram.com/prometheus-community/yet-another-cloudwatch-exporter
- Repository: https://github.com/prometheus-community/yet-another-cloudwatch-exporter

## Overview

##### Main Components

a. Core Components:
- AWS CloudWatch (External Service)
- YACE Exporter Core
- Prometheus Server (External Service)
- AWS IAM/STS (Authentication Layer)

b. Internal YACE Components:
- Config Management (/pkg/config)
- Client Layer (/pkg/clients)
- Job Management (/pkg/job)
- Metrics Model (/pkg/model)
- Prometheus Utilities (/pkg/promutil)

##### Component Relationships and Data Flow

**[AWS CloudWatch] <---> [YACE Exporter Core] <---> [Prometheus Server]**

- v
**[AWS IAM/STS] <---> [Authentication Layer]**

##### Detailed Component Breakdown

- YACE Exporter     |

- Config Management   |
- Client Layer        |
- Job Management      |
- Metrics Model       |
- Prometheus Utils    |

##### Key Interactions to Highlight

a. Discovery Flow:
**[Config] -> [Job Management] -> [AWS Clients] -> [CloudWatch API]**

b. Metrics Collection Flow:
**[CloudWatch] -> [YACE Clients] -> [Metrics Model] -> [Prometheus Format]**

##### Technical Details

- Scraping intervals
- Concurrency limits
- AWS SDK integration points
- Metric data formats
- Resource discovery mechanisms

##### Implementation Notes

Emphasize:
- Decoupled scraping architecture
- Background metric collection
- Resource tagging system
- CloudWatch API optimization
- Cross-account role assumption

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph AWS["AWS Services"]
        CW[("Amazon CloudWatch")]:::aws
        IAM["AWS IAM/STS"]:::aws
    end

    subgraph YACE["YACE Exporter Core"]
        Core["Main Exporter Service"]:::core
        click Core "https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/cmd/yace/main.go"

        subgraph Config["Configuration Layer"]
            CM["Config Management"]:::config
            click CM "https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/pkg/config/config.go"
            Services["Service Definitions"]:::config
            click Services "https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/pkg/config/services.go"
        end

        subgraph Clients["Client Layer"]
            CF["Client Factory"]:::client
            click CF "https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/pkg/clients/factory.go"
            CWClient["CloudWatch Client"]:::client
            click CWClient "https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/pkg/clients/cloudwatch/client.go"
            TagClient["Tagging Client"]:::client
            click TagClient "https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/pkg/clients/tagging/client.go"
            AccClient["Account Client"]:::client
            click AccClient "https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/pkg/clients/account/client.go"
        end

        subgraph Jobs["Job Management"]
            Scraper["Scraper"]:::job
            click Scraper "https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/pkg/job/scraper.go"
            Discovery["Resource Discovery"]:::job
            click Discovery "https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/pkg/job/discovery.go"
            Static["Static Jobs"]:::job
            click Static "https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/pkg/job/static.go"
        end

        subgraph Processing["Processing Layer"]
            MetricsModel["Metrics Model"]:::model
            click MetricsModel "https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/pkg/model/model.go"
            PromUtils["Prometheus Utilities"]:::prom
            click PromUtils "https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/pkg/promutil/prometheus.go"
        end

        subgraph DataProcessing["Metric Processing"]
            MetricProcessor["Metric Data Processor"]:::processor
            click MetricProcessor "https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/pkg/job/getmetricdata/processor.go"
            MetricIterator["Metric Iterator"]:::processor
            click MetricIterator "https://github.com/prometheus-community/yet-another-cloudwatch-exporter/blob/master/pkg/job/getmetricdata/iterator.go"
        end
    end

    PROM["Prometheus Server"]:::prometheus

    %% Connections
    CW --> CWClient
    IAM --> AccClient
    CM --> Core
    Services --> Core
    CF --> CWClient
    CF --> TagClient
    CF --> AccClient
    Core --> Scraper
    Scraper --> Discovery
    Discovery --> MetricProcessor
    MetricProcessor --> MetricIterator
    MetricIterator --> MetricsModel
    MetricsModel --> PromUtils
    PromUtils --> PROM

    %% Styles
    classDef aws fill:#2196F3,stroke:#fff,stroke-width:2px,color:#fff
    classDef core fill:#4CAF50,stroke:#fff,stroke-width:2px,color:#fff
    classDef config fill:#FFC107,stroke:#fff,stroke-width:2px,color:#000
    classDef client fill:#9C27B0,stroke:#fff,stroke-width:2px,color:#fff
    classDef job fill:#FF5722,stroke:#fff,stroke-width:2px,color:#fff
    classDef model fill:#607D8B,stroke:#fff,stroke-width:2px,color:#fff
    classDef prom fill:#795548,stroke:#fff,stroke-width:2px,color:#fff
    classDef processor fill:#3F51B5,stroke:#fff,stroke-width:2px,color:#fff
    classDef prometheus fill:#E91E63,stroke:#fff,stroke-width:2px,color:#fff

    %% Legend
    subgraph Legend
        L1["AWS Services"]:::aws
        L2["Core Components"]:::core
        L3["Configuration"]:::config
        L4["Clients"]:::client
        L5["Jobs"]:::job
        L6["Models"]:::model
        L7["Prometheus"]:::prometheus
        L8["Processors"]:::processor
    end
```
