Course contentsShow
← Cloud and Infrastructure
Lesson 1963 of 2,98942. Observability - MetricsFree lesson

Instant Vector Selectors

Query current metric values using metric names and label matchers for precise data selection.

Instant Vector Selectors

You'll learn how to query Prometheus for current metric values using precise selector syntax.

What Are Instant Vector Selectors?

An instant vector selector is a PromQL query that returns a set of time series with a single sample value per series—essentially a snapshot of "right now." You specify which metrics you want by combining a metric name with optional label matchers to filter down to exactly the data you need.

Think of it like searching a library: the metric name is the book category, and label matchers are filters like "published after 2020" or "author equals Smith." You get back all matching books with their current checkout status—not their full history, just their current state.

Basic Syntax

The simplest instant vector selector is just the metric name:

http_requests_total

This returns all time series for that metric, regardless of labels.

Adding Label Matchers

To be more precise, add label matchers inside curly braces:

http_requests_total{method="GET", status="200"}

This returns only series where both labels match exactly.

You can use different operators:

  • = : exact match
  • != : not equal
  • =~ : regex match
  • !~ : regex non-match

Example with regex:

http_requests_total{path=~"/api/.*", status!="500"}

This selects all /api/ paths except those with status 500.

Why This Matters

Instant vector selectors are the foundation of every PromQL query. They let you pinpoint exactly which metrics and dimensions matter for your question—whether you're building dashboards, setting alerts, or investigating issues. Without precise selectors, you'd drown in irrelevant data.

Key Takeaway: Instant vector selectors query current metric values by combining metric names with label matchers, giving you precise, snapshot-style data selection in Prometheus.