# netflix/chaosmonkey architecture

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

- Interactive diagram: https://gitdiagram.com/netflix/chaosmonkey
- Repository: https://github.com/netflix/chaosmonkey

## Overview

Chaos Monkey is a Go CLI that schedules randomized production instance terminations through Spinnaker. Its main workflow builds a schedule, persists it and installs cron entries; later, a terminate command checks safeguards, selects an eligible instance, records the event and invokes a terminator. The README documents Spinnaker as required, while sampled code shows its API client and the termination interfaces. Some runtime wiring is unsampled, so uncertain links are omitted or marked dashed.

Main entry points: [`command/chaosmonkey.go`](https://github.com/netflix/chaosmonkey/blob/master/command/chaosmonkey.go) (Command router), [`term/term.go`](https://github.com/netflix/chaosmonkey/blob/master/term/term.go) (Termination logic), [`cmd/chaosmonkey/main.go`](https://github.com/netflix/chaosmonkey/blob/master/cmd/chaosmonkey/main.go) (CLI entry), [`schedule/schedule.go`](https://github.com/netflix/chaosmonkey/blob/master/schedule/schedule.go) (Schedule engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and configuration"]
  node_entry["CLI entry<br/>[main.go]"]
  node_commands["Command router<br/>[chaosmonkey.go]"]
  node_configuration["Configuration<br/>[monkey.go]"]
end

subgraph group_planning["Scheduling and eligibility"]
  node_scheduler["Schedule engine<br/>[schedule.go]"]
  node_eligibility["Eligibility checks<br/>[eligible.go]"]
  node_schedule_store["Schedule storage<br/>[schedstore.go]"]
end

subgraph group_termination["Termination workflow"]
  node_termination["Termination logic<br/>[term.go]"]
  node_term_adapter["Terminator adapter<br/>[terminator.go]"]
  node_trackers["Tracker providers<br/>[tracker.go]"]
  node_outage["Outage guard<br/>[outage.go]"]
end

subgraph group_integrations["External integrations"]
  node_deploy["Deployment model<br/>[deployment.go]"]
  node_mysql[("MySQL persistence<br/>[mysql.go]")]
  node_spinnaker["Spinnaker client<br/>[spinnaker.go]"]
  node_spinnaker_terminator["Spinnaker terminator<br/>[terminator.go]"]
end

node_operator(("Operator"))
node_database_service[("MySQL service")]
node_spinnaker_service["Spinnaker service"]

node_operator -->|"runs CLI"| node_entry
node_entry -->|"executes"| node_commands
node_commands -->|"loads settings"| node_configuration
node_commands -->|"generates schedule"| node_scheduler
node_commands -->|"uses schedule store"| node_schedule_store
node_commands -->|"configures persistence"| node_mysql
node_commands -->|"configures client"| node_spinnaker
node_scheduler -->|"queries deployments"| node_deploy
node_scheduler -->|"reads app settings"| node_configuration
node_commands -->|"lists eligible instances"| node_eligibility
node_eligibility -->|"queries instances"| node_deploy
node_commands -->|"runs termination"| node_termination
node_termination -->|"selects instance"| node_eligibility
node_termination -->|"records termination"| node_trackers
node_termination -->|"checks outage"| node_outage
node_mysql -->|"reads and writes"| node_database_service
node_spinnaker -->|"queries API"| node_spinnaker_service
node_termination -.->|"uses terminator"| node_term_adapter
node_term_adapter -.->|"may delegate"| node_spinnaker_terminator
node_spinnaker_terminator -.->|"terminates instances"| node_spinnaker_service
node_entry -->|"registers provider"| node_outage
node_entry -->|"registers provider"| node_trackers

click node_entry "https://github.com/netflix/chaosmonkey/blob/master/cmd/chaosmonkey/main.go"
click node_commands "https://github.com/netflix/chaosmonkey/blob/master/command/chaosmonkey.go"
click node_configuration "https://github.com/netflix/chaosmonkey/blob/master/config/monkey.go"
click node_scheduler "https://github.com/netflix/chaosmonkey/blob/master/schedule/schedule.go"
click node_eligibility "https://github.com/netflix/chaosmonkey/blob/master/eligible/eligible.go"
click node_deploy "https://github.com/netflix/chaosmonkey/blob/master/deploy/deployment.go"
click node_schedule_store "https://github.com/netflix/chaosmonkey/blob/master/schedstore/schedstore.go"
click node_mysql "https://github.com/netflix/chaosmonkey/blob/master/mysql/mysql.go"
click node_termination "https://github.com/netflix/chaosmonkey/blob/master/term/term.go"
click node_term_adapter "https://github.com/netflix/chaosmonkey/blob/master/term/terminator.go"
click node_spinnaker "https://github.com/netflix/chaosmonkey/blob/master/spinnaker/spinnaker.go"
click node_spinnaker_terminator "https://github.com/netflix/chaosmonkey/blob/master/spinnaker/terminator.go"
click node_trackers "https://github.com/netflix/chaosmonkey/blob/master/tracker/tracker.go"
click node_outage "https://github.com/netflix/chaosmonkey/blob/master/outage/outage.go"

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_entry,node_commands,node_configuration toneBlue
class node_scheduler,node_eligibility,node_schedule_store,node_database_service toneAmber
class node_termination,node_term_adapter,node_trackers,node_outage toneMint
class node_deploy,node_mysql,node_spinnaker,node_spinnaker_terminator toneRose
class node_operator,node_spinnaker_service toneIndigo
```

## Components

### CLI and configuration

- [CLI entry](https://github.com/netflix/chaosmonkey/blob/master/cmd/chaosmonkey/main.go): `cmd/chaosmonkey/main.go`
- [Command router](https://github.com/netflix/chaosmonkey/blob/master/command/chaosmonkey.go): `command/chaosmonkey.go`
- [Configuration](https://github.com/netflix/chaosmonkey/blob/master/config/monkey.go): `config/monkey.go`

### Scheduling and eligibility

- [Schedule engine](https://github.com/netflix/chaosmonkey/blob/master/schedule/schedule.go): `schedule/schedule.go`
- [Eligibility checks](https://github.com/netflix/chaosmonkey/blob/master/eligible/eligible.go): `eligible/eligible.go`
- [Schedule storage](https://github.com/netflix/chaosmonkey/blob/master/schedstore/schedstore.go): `schedstore/schedstore.go`

### Termination workflow

- [Termination logic](https://github.com/netflix/chaosmonkey/blob/master/term/term.go): `term/term.go`
- [Terminator adapter](https://github.com/netflix/chaosmonkey/blob/master/term/terminator.go): `term/terminator.go`
- [Tracker providers](https://github.com/netflix/chaosmonkey/blob/master/tracker/tracker.go): `tracker/tracker.go`
- [Outage guard](https://github.com/netflix/chaosmonkey/blob/master/outage/outage.go): `outage/outage.go`

### External integrations

- [Deployment model](https://github.com/netflix/chaosmonkey/blob/master/deploy/deployment.go): `deploy/deployment.go`
- [MySQL persistence](https://github.com/netflix/chaosmonkey/blob/master/mysql/mysql.go): `mysql/mysql.go`
- [Spinnaker client](https://github.com/netflix/chaosmonkey/blob/master/spinnaker/spinnaker.go): `spinnaker/spinnaker.go`
- [Spinnaker terminator](https://github.com/netflix/chaosmonkey/blob/master/spinnaker/terminator.go): `spinnaker/terminator.go`

### Other components

- **Operator**
- **MySQL service**
- **Spinnaker service**

## Connections

- Operator → CLI entry: runs CLI (evidence: `cmd/chaosmonkey/main.go`)
- CLI entry → Command router: executes (evidence: `cmd/chaosmonkey/main.go`)
- Command router → Configuration: loads settings (evidence: `command/chaosmonkey.go`)
- Command router → Schedule engine: generates schedule (evidence: `command/chaosmonkey.go`)
- Command router → Schedule storage: uses schedule store (evidence: `command/chaosmonkey.go`)
- Command router → MySQL persistence: configures persistence (evidence: `command/chaosmonkey.go`)
- Command router → Spinnaker client: configures client (evidence: `command/chaosmonkey.go`)
- Schedule engine → Deployment model: queries deployments (evidence: `schedule/schedule.go`)
- Schedule engine → Configuration: reads app settings (evidence: `schedule/schedule.go`)
- Command router → Eligibility checks: lists eligible instances
- Eligibility checks → Deployment model: queries instances (evidence: `eligible/eligible.go`)
- Command router → Termination logic: runs termination
- Termination logic → Eligibility checks: selects instance (evidence: `term/term.go`)
- Termination logic → Tracker providers: records termination (evidence: `term/term.go`)
- Termination logic → Outage guard: checks outage (evidence: `term/term.go`)
- MySQL persistence → MySQL service: reads and writes (evidence: `mysql/mysql.go`)
- Spinnaker client → Spinnaker service: queries API (evidence: `spinnaker/spinnaker.go`)
- Termination logic → Terminator adapter: uses terminator
- Terminator adapter → Spinnaker terminator: may delegate
- Spinnaker terminator → Spinnaker service: terminates instances
- CLI entry → Outage guard: registers provider (evidence: `cmd/chaosmonkey/main.go`)
- CLI entry → Tracker providers: registers provider (evidence: `cmd/chaosmonkey/main.go`)
