Skip to content

prometheus query

Run a prometheus query at a single point in time

Description

Evaluates an instant query at a single point in time

Synopsis

prometheus query
    [--site <site>]
    [--cluster <cluster>]
    <query>
    [--time <time>]

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 expression in promQL format
     Example: "up"
     Default: _None_      Attributes: required

time - (time)

     Evaluation timestamp. Query is evaluated at this time (Should be provided in rfc3339 format)
     Example: --time "2015-07-01T20:10:51.781Z"
     Default: _None_      Attributes: optional

Examples

Input:

! prometheus query "up"
Output:
{
  "status": "success",
  "data": {
    "resultType": "vector",
    "result": [
      {
        "metric": {
          "__name__": "up",
          "instance": "localhost:1234",
          "job": "kafka"
        },
        "value": [1634749948.86, "0"]
      },
      {
        "metric": {
          "__name__": "up",
          "instance": "localhost:9090",
          "job": "prometheus"
        },
        "value": [1634749948.86, "1"]
      },
      {
        "metric": {
          "__name__": "up",
          "instance": "localhost:9100",
          "job": "node-exporter"
        },
        "value": [1634749948.86, "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.