Prometheus Literals
In Prometheus, literals refer to the constant values that can be used in queries and alerting rules. Here are some common literals used in Prometheus:
1. Numeric Literals: These include integers and floating-point numbers. For example:
- 42: An integer literal.
- 3.14: A floating-point literal.
2. String Literals: These are enclosed in double quotes ("). For example:
- "hello": A string literal containing the text "hello".
3. Boolean Literals: These represent the truth values of true and false.
4. Duration Literals: These represent time durations. They can be expressed using a combination of numbers and units. For example:
- 5s: A duration of 5 seconds.
- 2h30m: A duration of 2 hours and 30 minutes.
5. Time Literals: These represent specific points in time and are formatted using the ISO 8601 standard. For example:
- 2023-07-02T12:34:56Z: A time literal representing July 2, 2023, at 12:34:56 UTC.
6. Regular Expression Literals: These are enclosed in slashes (`/`). They are used for pattern matching in regular expression-based queries and alerting rules. For example:
- /^http/: A regular expression literal that matches strings starting with "http".
7. Range Vector Selector Literals: These are used to select a range of time series data. They use the square bracket notation. For example:
- my_metric[5m]: A range vector selector literal that selects data for the metric "my_metric" over the past 5 minutes.
These are some of the common literals used in Prometheus. They provide the necessary flexibility to construct queries and alerting rules based on different types of data and time periods.