prometheus range-query
Run a prometheus query over a range of time
Description
Evaluates an expression query over a range of time
Synopsis
prometheus range-query
[--site <site>]
[--cluster <cluster>]
<query>
--start_time <start_time>
--end_time <end_time>
--step <step>
Arguments
site
- (string)
Site where this command will be executed
Example: --site "site-1"
Default: input.site
Attributes: optional
cluster
- (string)
Name of prometheus cluster
Example: --cluster "prometheus-default"
Default: prometheus-default
Attributes: optional
query
- (string)
Query
Example: "up"
Default: _None_
Attributes: required
start_time
- (string)
Start timestamp (inclusive, Should be provided in rfc3339 format)
Example: --start_time "2015-07-01T20:10:51.781Z"
Default: _None_
Attributes: required
end_time
- (string)
End timestamp (inclusive, Should be provided in rfc3339 format)
Example: --end_time "2015-07-01T20:10:51.781Z"
Default: _None_
Attributes: required
step
- (float)
Query resolution step width in seconds
Example: --step 15.5
Default: _None_
Attributes: required
Examples
Input:
! prometheus range-query --start_time "2021-10-19T20:10:51.781Z" --end_time "2021-10-20T20:10:51.781Z" "up" --step 30000
{
"status": "success",
"data": {
"resultType": "matrix",
"result": [
{
"metric": {
"__name__": "up",
"instance": "localhost:1234",
"job": "kafka"
},
"values": [
[1634674251.781, "0"],
[1634704251.781, "0"],
[1634734251.781, "0"]
]
},
{
"metric": {
"__name__": "up",
"instance": "localhost:9090",
"job": "prometheus"
},
"values": [
[1634674251.781, "1"],
[1634704251.781, "1"],
[1634734251.781, "1"]
]
},
{
"metric": {
"__name__": "up",
"instance": "localhost:9100",
"job": "node-exporter"
},
"values": [
[1634674251.781, "0"],
[1634704251.781, "0"],
[1634734251.781, "0"]
]
}
]
}
}
Access Control
To use this command, you need access to the following:
Field | Value |
---|---|
Action | "read" |
Service Type | "prometheus" |
Service Instance | cluster |
Namespace | |
Object Type | |
Object ID |
Please see Access Control for details.