query_range {promr}R Documentation

Evaluate an expression query over a range of time.

Description

Evaluate an expression query over a range of time.

Usage

query_range(
  query,
  start,
  end,
  host = "http://127.0.0.1:9090",
  step = "10s",
  timeout = NA
)

Arguments

query

A PromQL query.

start

A RFC3339 timestamp string, numerical unix timestamp, or POSIXct object.

end

A RFC3339 timestamp string, numerical unix timestamp, or POSIXct object.

host

An optional host - defaulting to ⁠http://127.0.0.1:9090⁠

step

An optional query resolution step width, defaulting to ⁠10s⁠

timeout

An optional query timeout value, defaulting to server-side limit. Note this timeout is capped to the server-side value.

Value

A tibble of all series returned by the server, with nested measurements.

Examples

## Not run: 
# Run a simple range query against the specified host.
query_range(
  "up",
  "2022-08-20T00:00:00Z",
  "2022-08-21T00:00:00Z",
  host = "http://127.0.0.1:9090"
)

# Run a server-side aggregation query, using the default local host.
query_range(
  "rate(http_requests_total[5m])",
  "2022-08-20T00:00:00Z",
  "2022-08-21T00:00:00Z"
)

# Specify the time range using POSIXct objects, and set the optional "step"
query_range(
  "rate(http_requests_total[5m])",
  strptime(
    "2022-08-20T20:10:30",
    format = "%Y-%m-%dT%H:%M:%S"
  ),
  strptime(
    "2022-08-21T20:10:30",
    format = "%Y-%m-%dT%H:%M:%S"
  ),
  step = "30s"
)

# Specify the time range using unix timestamps, and set an optional "timeout"
query_range(
  "rate(http_requests_total[5m])",
  1660989814,
  1661076214,
  timeout = "60s"
)

## End(Not run)

[Package promr version 0.1.3 Index]