This program automatically scales DigitalOcean apps based on Prometheus metrics. It monitors a specified metric and scales the application instances up or down based on defined threshold values.
- Configurable Scaling: Scale your application instances up or down based on metric values surpassing the defined thresholds.
- Integration with DigitalOcean Apps: Seamless integration with DigitalOcean's App Platform.
- Uses Prometheus: Leverages Prometheus for fetching metric data.
- DigitalOcean account.
- An instance of Prometheus to monitor metrics.
-
Environment Variables: Set the following environment variables:
PROMETHEUS_HOST
: The URL of your Prometheus instance.THRESHOLD_UP
: The metric value threshold to trigger scaling up.MAX_SIZE
: The maximum number of instances for your app.THRESHOLD_DOWN
: The metric value threshold to trigger scaling down.DO_API_TOKEN
: Your DigitalOcean API token.DO_APP_ID
: The ID of your DigitalOcean app.PROMETHEUS_METRIC
: The Prometheus metric to monitor.
-
godotenv Support: The program supports loading the environment variables from a
.env
file.
- The program continuously checks the specified Prometheus metric.
- If the metric value surpasses the
THRESHOLD_UP
, the program scales up the application, provided the number of instances hasn't reachedMAX_SIZE
. - If the metric value falls below the
THRESHOLD_DOWN
, the program scales down the application, but ensures there's always at least one instance running.
- Currently, the program assumes that your DigitalOcean app has only one service. Multiple services are not supported yet.
- Support for scaling multiple services within a DigitalOcean app.
- Customizable sleep duration between metric checks.
- Handle Prometheus and DigitalOcean API connection issues gracefully.
Run the program using:
go run main.go