Skip to main content

Using Web UI and Expression Browser

1. Accessing Web Interface

Method Description Example
Default Address Local address where Prometheus web UI is accessible http://localhost:9090
Query Parameters Optional parameters to customize UI behavior ?g=g1&g=g2

Example: Starting Prometheus with default UI

prometheus --config.file=prometheus.yml
Note: The web UI is enabled by default when Prometheus is started with a valid configuration file.
Warning: Ensure that the Prometheus server is running and accessible from your browser before attempting to access the web interface.

2. Using Expression Browser

Example: Querying a metric

up
Expression Description Notes
up Boolean indicating if a job is up Returns 1 for up, 0 for down
rate(up[5m]) Rate of change over 5 minutes Useful for detecting recent outages
Note: The Expression Browser supports full Prometheus Query Language (PromQL) syntax.

Example: Using functions

rate(http_requests_total[1h])
Function Description Usage
rate() Calculates per-second rate over a time window rate(metric[5m])
sum() Aggregates values across a vector sum(http_requests_total)
max() Returns maximum value in a vector max(http_requests_total)
Warning: Expression Browser does not support real-time updates. Results are cached and refreshed on query submission.

Example: Filtering with labels

http_requests_total{job="api-server"}
Label Selector Example Description
{job="api-server"} http_requests_total{job="api-server"} Selects metrics with job label equal to "api-server"
{job!="api-server"} http_requests_total{job!="api-server"} Selects metrics with job label not equal to "api-server"
{job=~"api.*"} http_requests_total{job=~"api.*"} Selects metrics with job label matching regex pattern

3. Viewing Targets Status

Target State Last Scrape Scrape Duration Errors
node_exporter UP 2026-01-15T10:00:00Z 200ms 0
alertmanager UP 2026-01-15T10:00:05Z 150ms 0
prometheus UP 2026-01-15T10:00:10Z 300ms 0
blackbox_exporter DOWN 2026-01-15T09:55:00Z — 12
Note: Targets are considered DOWN if they have not been scraped successfully in the last 5 minutes.

Example: Querying Target Status


prometheus_target_status

4. Checking Service Discovery

Example: Service Discovery Configuration

scrape_configs:
  - job_name: "prometheus"
    static_configs:
      - targets: ['localhost:9090']
  - job_name: "node"
    static_configs:
      - targets: ['localhost:9100']
  - job_name: "alertmanager"
    static_configs:
      - targets: ['localhost:9093']
Service Discovery Method Description Configuration Example Notes
Static Config Manually define targets in configuration static_configs: Simple and direct, good for small setups
Consul SD Discover targets via Consul service catalog consul_sd_configs: Dynamic discovery with service registration
Kubernetes SD Discover targets from Kubernetes pods/services kubernetes_sd_configs: Automatically discovers services in cluster
EC2 SD Discover targets from AWS EC2 instances ec2_sd_configs: Useful for cloud-based deployments
DNSSD Discover targets via DNS SRV records dns_sd_configs: Flexible, supports dynamic updates
Note: Service discovery is critical for dynamic environments where targets may change frequently. Prometheus supports multiple SD methods to integrate with various infrastructure tools.

5. Viewing Configuration

Configuration Item Description Example
prometheus.yml Primary configuration file for Prometheus global:
scrape_configs Defines how to scrape targets
scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']
rule_files List of rule files to load rule_files: ['alerts.yml']
storage.tsdb.retention How long to retain samples in the database storage.tsdb.retention: 15d

Example: Basic Configuration File

global:
  scrape_interval: 15s
  evaluation_interval: 15s

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']
Note: The Web UI allows you to view the loaded configuration in YAML format under the Configuration menu.

6. Checking Rule Status

Example: Querying rule status

curl -X GET http://prometheus-server:9090/api/v1/rules
Field Description Example Value
name Rule name up:1m
query Rule query expression up == 1
labels Labels applied to rule {job="prometheus"}
state Current state of rule (active, inactive) active
health Health status (ok, error) ok
Note: Rule status can be checked via the Prometheus web UI under /rules or through the API endpoint.
Warning: If a rule has health set to error, it indicates a problem with the rule's expression or configuration.

7. Viewing Active Alerts

Field Description Example
alertname Name of the alert rule InstanceDown
job Job name that triggered the alert node_exporter
instance Instance that triggered the alert node01:9100
severity Severity level of the alert critical

Example: Alert Rule Expression


InstanceDown = up == 0
Note: Alerts are displayed in the Web UI under the Alerts tab. Active alerts are those currently firing.

8. Using TSDB Status Page

Example: Accessing TSDB Status Page

curl http://localhost:9090/status
Endpoint Description Notes
/status Provides information about the TSDB (Time Series Database) status Includes storage statistics, WAL (Write-Ahead Log) info, and compaction stats

TSDB Status Page Overview

  • Storage Info: Shows the current size of the storage directory and number of series
  • WAL Info: Displays information about the Write-Ahead Log, including segment count and size
  • Compaction Info: Lists compaction statistics, including duration and number of chunks
  • Memory Usage: Shows memory usage statistics for the Prometheus instance
Note: The TSDB status page is available at /status and provides low-level details about the internal state of the Prometheus storage engine.
Warning: This endpoint is intended for debugging and monitoring purposes. It may change in future versions of Prometheus.

9. Checking Runtime Information

Information Type Description Endpoint Notes
Build Information Version, revision, build date, and Go version of the Prometheus server /api/v1/status/buildinfo Returns structured JSON with build details
Runtime Information Process and system-level runtime statistics /api/v1/status/runtimeinfo Includes memory usage, goroutine count, and GC stats
Config Current Prometheus configuration file content /api/v1/status/config Shows loaded config in YAML format
Flags Command-line flags used to start Prometheus /api/v1/status/flags Lists all flags and their values

Example: Fetching Build Information

curl "http://localhost:9090/api/v1/status/buildinfo"

Example: Fetching Runtime Info

curl "http://localhost:9090/api/v1/status/runtimeinfo"

10. Using Graph Visualization

Example: Basic Graph Query

up
Expression Description Notes
up Indicates whether a target is up or down Boolean vector indicating target status
rate(up[5m]) Rate of change over 5 minutes Useful for detecting target outages
Note: Graphs can be zoomed and panned using mouse controls or keyboard shortcuts.

Example: Query with Labels

http_requests_total{job="prometheus"}

Steps to Visualize Metrics

  1. Navigate to the Graph tab in the Prometheus Web UI
  2. Enter a metric expression in the query input field
  3. Click "Execute" to view results
  4. Adjust time range using the time selector
  5. Use the graph controls to zoom or pan

Graph vs. Table View

  • Graph: Shows metric values over time with visual trends
  • Table: Displays raw metric values in tabular format

11. Viewing Command-Line Flags

Flag Description Default Value Notes
--config.file Path to the configuration file prometheus.yml Can be overridden with -c
--storage.tsdb.path Directory to store the TSDB data data/ Must be writable by the Prometheus process
--web.listen-address Address to listen on for web interface and telemetry :9090 Can be changed to bind to a specific IP or port
--web.external-url External URL to access the Prometheus web UI nil Used for proper URL generation in alerts and links
--web.enable-lifecycle Enable reload via HTTP POST to /-/reload false Useful for automated configuration reloads
--web.enable-admin-api Enable access to admin HTTP API endpoints false Includes /-/quit, /-/reload
--storage.tsdb.retention.time How long to retain samples in the database 15d Can be specified as h, d, w, y
--storage.tsdb.min-block-duration Minimum size of the block in time 2h Used to optimize query performance
--storage.tsdb.max-block-duration Maximum size of the block in time 2d Used to optimize query performance
--web.console.libraries Directories to load console libraries from nil Allows custom dashboard templates to be loaded
--web.console.templates Directory to load console templates from nil Used to override default console templates

Example: Starting Prometheus with custom flags

prometheus --config.file="custom.yml" --web.listen-address=":9091" --storage.tsdb.retention.time=30d

12. Accessing Health Endpoints

Endpoint Description Response Format Notes
/-/healthy Indicates if the Prometheus server is healthy Text/plain Returns "ok" if healthy
/-/ready Indicates if the Prometheus server is ready to serve requests Text/plain Returns "ok" if ready
/metrics Exposes Prometheus metrics in Prometheus text format Text/plain Used for scraping by Prometheus or other monitoring systems

Example: Checking Health Endpoints

curl http://localhost:9090/-/healthy
curl http://localhost:9090/-/ready
curl http://localhost:9090/metrics

Was this article helpful?