
- Use
=to select series with an exact label value. Example: get filesystem availability fornode1only.
instance="node1"):
- Use
!=to remove series matching a specific label value. Example: excludetmpfsdevices.
device not equal to tmpfs):
- Use
=~to match label values with a regex. Example: match devices that start with/dev/sda.
device matching /dev/sda.*):
Regular expressions are powerful but can impact performance if overused. Test and keep regex patterns as simple and specific as possible. For a regex reference, see Regular-Expressions.info.
- Use
!~to exclude series whose label values match a regex. Example: exclude mount points beginning with/boot.
mountpoint starts with /boot):
- Combine multiple label matchers by separating them with commas inside the braces. Example: series on
node1excludingtmpfsdevices.
node1 excluding tmpfs devices):
- An instant vector returns the latest sample per series. A range vector returns the sequence of samples for each matching series over a specified duration. Use square brackets with a duration to request a range vector. Example: last 2 minutes for
node_arp_entriesonnode1.
5m, 1h, 5d) depending on how far back you need data.
Additional resources
- Prometheus documentation: https://prometheus.io/docs/prometheus/latest/querying/basics/
- Regex reference: https://www.regular-expressions.info/
Make sure label values and regex patterns are quoted correctly. Unquoted or malformed regexes can cause query errors. When in doubt, test queries in the Prometheus UI or Grafana Explore.