{
  "namespace": "observability",
  "region": "prod-aws-us-east-1",
  "retentionWindow": {
    "end": "2026-07-09T00:00:00Z",
    "start": "2026-04-23T00:00:00Z"
  },
  "shardStepInterval": "6h",
  "sourceReplicaCount": 5,
  "steps": {
    "prepare": {
      "items": [
        {
          "name": "preflight",
          "desc": "Describe the VMCluster; manually confirm Ready status, frozen vmagent split rules, and target cluster readiness",
          "command": [
            "kubectl -n observability describe vmcluster vmcluster"
          ]
        },
        {
          "name": "generate-tenants",
          "desc": "Generate the tenant lists, flatten them with `vm-migration tenants merge`, then pass the flat list to `plan compile` via --tenants (example commands — adjust flags per environment)",
          "command": [
            "# Example commands — adjust flags per environment (see vm-migration tenants --help).",
            "vm-migration tenants dedicated k8s --output tenants-dedicated-k8s.json",
            "vm-migration tenants dedicated s3 --s3-bucket <bucket> --output tenants-dedicated-s3.json",
            "vm-migration tenants essential mgmt --addr <addr> --region <region> --provider <provider> --output essential-mgmt.json",
            "vm-migration tenants essential rds --clusters-in essential-mgmt.json --secret-file <secret-file> --db-host <db-host> --output essential-rds.json",
            "vm-migration tenants essential s3 --clusters-in essential-rds.json --s3-bucket <bucket> --output tenants-essential.json",
            "vm-migration tenants merge --input tenants-dedicated-k8s.json --input tenants-dedicated-s3.json --input tenants-essential.json --output tenants.json"
          ]
        },
        {
          "name": "enable-dedup",
          "desc": "Patch VMCluster vmselect.extraArgs dedup.minScrapeInterval=1ms; idempotent",
          "command": [
            "yq -i 'with(select(.kind == \"VMCluster\"); .spec.vmselect.extraArgs.\"dedup.minScrapeInterval\" = \"1ms\")' <repo-path>/deployments/dataplane/vmcluster/envs/<region>/vmcluster.yaml",
            "git -C <repo-path> diff -- deployments/dataplane/vmcluster/envs/prod-aws-us-east-1/vmcluster.yaml",
            "# Review the diff above; commit and push when ready (not done by this tool). Wait for ArgoCD sync before proceeding to the next stage."
          ]
        },
        {
          "name": "drain-insert",
          "desc": "Patch maintenanceInsertNodeIDs=[3..4]; new writes hash only to vmstorage-0..2",
          "command": [
            "yq -i 'with(select(.kind == \"VMCluster\"); .spec.vmstorage.maintenanceInsertNodeIDs = [3, 4])' <repo-path>/deployments/dataplane/vmcluster/envs/<region>/vmcluster.yaml",
            "git -C <repo-path> diff -- deployments/dataplane/vmcluster/envs/prod-aws-us-east-1/vmcluster.yaml",
            "# Review the diff above; commit and push when ready (not done by this tool). Wait for ArgoCD sync before proceeding to the next stage."
          ]
        },
        {
          "name": "deploy-vmselects",
          "desc": "Deploy both temporary vmselects via the serve API: vmselect-migration on 3..4 (vmctl export source) and vmselect-candidate on 0..2 (verification query path)",
          "command": [
            "# The migration must exist on serve first: curl -X POST <serve>/migrations/<name> --data-binary @<compiled-plan.json>",
            "curl -X POST <serve>/migrations/<name>/deploy",
            "curl -N <serve>/migrations/<name>/logs"
          ]
        }
      ]
    },
    "migration": {
      "items": [
        {
          "name": "run",
          "desc": "run",
          "command": [
            "curl -X POST <serve>/migrations/<name>/run -d '{\"retries\":0}'",
            "curl -N <serve>/migrations/<name>/logs",
            "curl '<serve>/migrations/<name>/summary?format=text'"
          ]
        }
      ]
    },
    "decommission": {
      "items": [
        {
          "name": "drain-select",
          "desc": "Patch maintenanceSelectNodeIDs=[3..4]; production queries no longer touch vmstorage-3..4",
          "command": [
            "yq -i 'with(select(.kind == \"VMCluster\"); .spec.vmstorage.maintenanceSelectNodeIDs = [3, 4])' <repo-path>/deployments/dataplane/vmcluster/envs/<region>/vmcluster.yaml",
            "git -C <repo-path> diff -- deployments/dataplane/vmcluster/envs/prod-aws-us-east-1/vmcluster.yaml",
            "# Review the diff above; commit and push when ready (not done by this tool). Wait for ArgoCD sync before proceeding to the next stage."
          ]
        },
        {
          "name": "scale-down",
          "desc": "Patch vmstorage.replicaCount=3; StatefulSet removes pods 3..4 in reverse order while PVCs are retained",
          "command": [
            "yq -i 'with(select(.kind == \"VMCluster\"); .spec.vmstorage.replicaCount = 3)' <repo-path>/deployments/dataplane/vmcluster/envs/<region>/vmcluster.yaml",
            "git -C <repo-path> diff -- deployments/dataplane/vmcluster/envs/prod-aws-us-east-1/vmcluster.yaml",
            "# Review the diff above; commit and push when ready (not done by this tool). Wait for ArgoCD sync before proceeding to the next stage."
          ]
        },
        {
          "name": "cleanup",
          "desc": "Undeploy vmselect-migration and vmselect-candidate after the rollback window closes",
          "command": [
            "curl -X POST <serve>/migrations/<name>/undeploy",
            "curl -N <serve>/migrations/<name>/logs"
          ]
        }
      ]
    }
  },
  "targetReplicaCount": 3,
  "tenants": [
    "1001:0",
    "1002:0",
    "1003:0"
  ],
  "vmcluster": {
    "name": "vmcluster",
    "vminsertName": "vminsert-vmcluster",
    "vminsertURLPattern": "http://vminsert-vmcluster.observability.svc.cluster.local:8480/insert/{tenant}/prometheus",
    "vmselectName": "vmselect-vmcluster",
    "vmselectURLPattern": "http://vmselect-vmcluster.observability.svc.cluster.local:8481/select/{tenant}/prometheus"
  },
  "vmctl": {
    "concurrency": 24,
    "rateLimitBytes": 100000000,
    "stepInterval": "day"
  },
  "vmselects": {
    "image": "557537366020.dkr.ecr.us-west-2.amazonaws.com/victoriametrics/vmselect:v1.122.2-cluster",
    "migration": {
      "name": "vmselect-migration",
      "urlPattern": "http://vmselect-migration.observability.svc.cluster.local:8481/select/{tenant}/prometheus",
      "replicas": 1,
      "resources": {
        "limits": {
          "cpu": "1",
          "memory": "4Gi"
        },
        "requests": {
          "cpu": "0.5",
          "memory": "2Gi"
        }
      }
    },
    "candidate": {
      "name": "vmselect-candidate",
      "urlPattern": "http://vmselect-candidate.observability.svc.cluster.local:8481/select/{tenant}/prometheus",
      "replicas": 1,
      "resources": {
        "limits": {
          "cpu": "1",
          "memory": "4Gi"
        },
        "requests": {
          "cpu": "0.5",
          "memory": "2Gi"
        }
      }
    }
  }
}
