Title: | Prometheus 'PromQL' Query Client for 'R' |
---|---|
Description: | A native 'R' client library for querying the 'Prometheus' time-series database, using the 'PromQL' query language. |
Authors: | Dom Dwyer [aut, cre] |
Maintainer: | Dom Dwyer <[email protected]> |
License: | Apache License (>= 2) |
Version: | 0.1.3 |
Built: | 2025-03-12 03:28:30 UTC |
Source: | https://github.com/domodwyer/promr |
Construct a URL for the specified query.
build_url(base, query, start, end, step, timeout = NA)
build_url(base, query, start, end, step, timeout = NA)
base |
A hostname and schema to base the generated path off of. |
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. |
step |
A query resolution step width. |
timeout |
An optional query timeout value, defaulting to server-side limit. Note this timeout is capped to the server-side value. |
A URL to execute the query.
A helper function to map an input of various types to a timestamp string suitable for use with Prometheus.
cast_timestamp(input)
cast_timestamp(input)
input |
A RFC3339 timestamp string, numerical unix timestamp, or POSIXct object. |
A Prometheus-compatible timestamp that can be coerced to a string.
Evaluate an expression query over a range of time.
query_range( query, start, end, host = "http://127.0.0.1:9090", step = "10s", timeout = NA )
query_range( query, start, end, host = "http://127.0.0.1:9090", step = "10s", timeout = NA )
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 |
step |
An optional query resolution step width, defaulting to |
timeout |
An optional query timeout value, defaulting to server-side limit. Note this timeout is capped to the server-side value. |
A tibble of all series returned by the server, with nested measurements.
## 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)
## 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)