How to Install, Configure, and Run Prometheus: A Step‑by‑Step Guide
This guide walks you through installing Prometheus via binary download, configuring global scrape settings and job definitions, running the server with command‑line options, and using the web UI and PromQL to verify target health and query metrics, illustrated with screenshots and example queries.
Installation
Download the pre‑compiled binary package for your operating system from https://prometheus.io/download/. For a Mac Mini with an ARM64 processor, select the darwin arm64 package, extract it, and you are ready to use the binaries.
After extraction, clear the default prometheus.yml file so you can start configuring Prometheus from scratch.
Configuration
Set a faster global scrape interval for the tutorial:
global:
scrape_interval: 5sDefine scrape_configs to tell Prometheus what to scrape:
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets:
- localhost:9090
- job_name: "demo"
static_configs:
- targets:
- demo.promlabs.com:10000
- demo.promlabs.com:10001
- demo.promlabs.com:10002Each job_name groups a set of targets. The first job scrapes Prometheus’s own metrics; the second job scrapes a public demo service. prometheus: collects metrics from the Prometheus server itself. demo: collects metrics exposed by the demo website.
Prometheus accesses targets via standard HTTP requests. If you need other protocols or authentication, additional configuration is required.
Running the Server
Navigate to the installation directory and start the server: $ ./prometheus Common command‑line flags (defaults shown) are:
# Configuration file path (default: ./prometheus.yml)
--config.file="prometheus.yml"
# Listen address (default: 0.0.0.0:9090)
--web.listen-address=0.0.0.0:9090
# TSDB storage path (default: ./data/)
--storage.tsdb.path="data/"Check the startup logs to ensure the service started correctly.
Open the web UI at http://localhost:9090 to view the dashboard.
In Status → Target health , verify that all scrape targets are UP, indicating they are reachable.
Use the expression browser to query metrics. Example counter: prometheus_tsdb_head_samples_appended_total To see the growth rate, apply the rate() function.
Example for the 90th‑percentile latency of the demo service:
histogram_quantile(0.9, sum by (le, path) (rate(demo_api_request_duration_seconds_bucket[5m])))If the time axis shows the wrong timezone, click the gear icon, go to Global settings , and enable Use local time .
Summary of covered steps:
Install and start the Prometheus service.
Verify the health of scrape targets.
Execute basic PromQL queries to retrieve metric data.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
