Introduction Querying Metrics

Querying

  • Prometheus provides a functional expression language called PromQL
    • Provides built in operators and functions
    • Vector-based calculations like Excel
    • Expressions over time-series vectors
  • PromQL is read-only
  • Example:
    • 100 - (avg by (instance) (irate(node_cpu_seconds_total{job='node_exporter',mode="idle"}[5m])) * 100)

Querying - Expressions

  • Instance vector
    • a set of time series containing a single sample for each time series, all sharing the same timestamp
    • Example:
      • node_cpu_secounds_total
  • Range  vector
    • a set of time series containing a range of data points over time for each time series
    • Example:
      • node_cpu_seconds_total[5m]
  • Scalar
    • a simple numeric floating point value
    • Example:
      • -3.14
  • String
    • a simple string value; currently unused

Querying - Operators

  • Arithmetic binary operators
    • Example:
      • Operatorsdescription
        -subtraction
        *multiplication
        /division
        %modulo
        ^power/exponentiation)
  • Comparison binary operators
    • Example:
      • Operatorsdescription
        ==equal
        !=not-equal
        >greater-then
        <less-than
        >=greater-or-equal
        <=less-or-equal
  • Logical/set binary operators
    • Example:
      • Operatorsdescription
        andintersection
        orunion
        unlesscomplement
  • Aggregation operators
    • Example:
      • Operatorsdescription
        sumcalculate sum over dimensions
        minselect minimum over dimensions
        maxselect maximum over dimensions
        avgcalculate the average over dimensions
        stddevcalculate population standard deviation over dimensions
        stdvarcalculate population standard variance over dimensions
        countcount number of elements in the vector
        count_valuescount number of elements with the same value
        bottomksmallest k elements by sample value
        topklargest k elements by sample value
        quantile

        calculate over dimensions

  • No labels

0 Comments

You are not logged in. Any changes you make will be marked as anonymous. You may want to Log In if you already have an account.