Deploying a Prometheus App
Introduction
Prometheus is a leading open-source monitoring system with a pull-based scraper and time-series storage. Deploying Prometheus with a Dockerfile on Klutch.sh provides reproducible builds, managed secrets, and persistent storage—all configured from klutch.sh/app. This guide covers installation, Dockerfile setup, environment variables, storage, Nixpacks overrides, and sample queries.
Prerequisites
- A Klutch.sh account (sign up)
- A GitHub repository containing your Prometheus Dockerfile and config (GitHub is the only supported git source)
- Targets to scrape, reachable from the Prometheus container
For onboarding, see the Quick Start.
Architecture and ports
- Prometheus serves HTTP on internal port
9090. Choose HTTP traffic and set the internal port to9090. - Persistent storage is recommended to retain time series across deployments.
Repository layout
prometheus/├── Dockerfile # Must be at repo root for auto-detection└── prometheus.yml # Scrape configurationKeep secrets out of Git; store them in Klutch.sh environment variables.
Installation (local) and starter commands
Build and run locally:
docker build -t prometheus-local .docker run -p 9090:9090 \ -v $(pwd)/prometheus.yml:/etc/prometheus/prometheus.yml \ prometheus-localDockerfile for Prometheus (production-ready)
Place this at the repo root; Klutch.sh auto-detects Dockerfiles.
FROM prom/prometheus:latest
COPY prometheus.yml /etc/prometheus/prometheus.yml
EXPOSE 9090CMD ["/bin/prometheus", "--config.file=/etc/prometheus/prometheus.yml", "--storage.tsdb.path=/prometheus"]Notes:
- Pin to a specific tag (e.g.,
prom/prometheus:v2.49.1) for stability. - The TSDB path is
/prometheus; mount a volume there to persist data.
Environment variables (Klutch.sh)
Prometheus primarily uses flags/config. If you need to override in Nixpacks:
NIXPACKS_START_CMD=/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/prometheus
Attach persistent volumes
Add storage in Klutch.sh (path and size only):
/prometheus— TSDB data directory.
Ensure it is writable inside the container.
Deploy Prometheus on Klutch.sh (Dockerfile workflow)
- Push your repository—with the Dockerfile and
prometheus.ymlat the root—to GitHub. - Open klutch.sh/app, create a project, and add an app.
- Select HTTP traffic and set the internal port to
9090. - Attach a volume at
/prometheussized for your retention and ingestion rate. - Deploy. Access Prometheus at
https://example-app.klutch.sh.
Sample configuration (prometheus.yml)
global: scrape_interval: 15s evaluation_interval: 15s
scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] - job_name: 'app' static_configs: - targets: ['your-app:8080']Adjust targets to match your services reachable from the Prometheus container.
Sample queries and checks
UI/health check:
curl -I https://example-app.klutch.sh/-/readyQuery an example metric:
curl "https://example-app.klutch.sh/api/v1/query?query=up"Health checks and production tips
- Use readiness probe
/-/readyand liveness probe/-/healthy. - Keep scrape targets reachable from the Prometheus container; secure endpoints with auth if needed.
- Pin image versions and test config changes in staging; reload by redeploying with updated config.
- Monitor volume usage on
/prometheus; resize before retention causes pressure.
Prometheus on Klutch.sh delivers reproducible Docker builds, persistent TSDB storage, and managed configuration—without extra YAML or CI steps. Configure ports, storage, and scrape targets, then start collecting metrics.