if (FALSE) {
# 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"
)
}
Run the code above in your browser using DataLab