How thunderbottom/aws-exporter works
Project type and purpose
• This is a single-binary, open-source Prometheus exporter written in Go.
• It fetches AWS Cost Explorer and EC2 Instance data via the AWS Go SDK, exposes them on an HTTP /metrics endpoint, and is scraped by Prometheus.
File structure
• Top-level files:
• main.go – application entry point, starts HTTP server and registers handlers.
• handler.go – HTTP handler that orchestrates all configured exporters and collects metrics.
• config/ – holds configuration model (model.go) and loader (config.go).
• exporter/ – package containing individual exporters:
– costexplorer.go – implements Cost Explorer metrics
– instance.go – implements EC2 Instance metrics
– utils.go – shared helper functions
• docker/ – Dockerfile for containerized execution
• config.toml.example – sample config for jobs, credentials, filters, tags
• CI/infra files: .drone.yml, Makefile, .hadolint.yml
Key insights from README
• Configurable jobs: each job has AWS creds, region, optional role ARN, filters, tags.
• Prometheus scrapes at /metrics (default port 9980).
• Extensibility: to add a new exporter, create a new file in exporter/, implement an Exporter interface, register it in handler.go.
Components
a. Main components
• AWS Services (Cost Explorer, EC2 API)
• Exporter Binary (Go application)
• Config Loader
• Exporter Manager (in handler.go)
• Individual Exporters (Cost Explorer, EC2 Instance)
• HTTP Metrics Endpoint
• Prometheus Server
• (Optional) Docker Container / Kubernetes Pod
b. Relationships and interactions
• On startup, Exporter Binary reads config.toml.
• For each configured job, the Exporter Manager invokes each exporter:
• Cost Explorer exporter calls AWS CE API → parses cost metrics
• Instance exporter calls EC2 DescribeInstances → collects tags and metadata
• Exporters push metrics into Prometheus client registry inside the binary.
• Prometheus periodically scrapes http://<exporter-host>:9980/metrics.
• (Optional) Exporter Binary runs inside a Docker container or k8s pod.
c. Architectural patterns and design principles
• Modular exporter plugins in a package, pluggable via registration in handler.go.
• Configuration-driven multi-job execution.
• Separation of concerns: config parsing, metric collection, HTTP serving.
d. Technologies, frameworks, libraries
• Language: Go
• AWS Go SDK (github.com/aws/aws-sdk-go)
• Prometheus Go client (github.com/prometheus/client_golang)
• Docker for containerization
Detailed capture of architectural elements
• How role_arn enables cross-account scraping.
• Metrics path /metrics and default port 9980.