This is the `query` metricset to query from https://prometheus.io/docs/prometheus/latest/querying/api/#expression-queries[querying API of Prometheus].


[float]
=== Configuration

[float]
==== Instant queries

The following configuration performs an instant query for `up` metric at a single point in time:
[source,yaml]
-------------------------------------------------------------------------------------
- module: prometheus
  period: 10s
  hosts: ["localhost:9090"]
  metricsets: ["query"]
  queries:
  - name: 'up'
    path: '/api/v1/query'
    params:
      query: "up"
-------------------------------------------------------------------------------------


More complex PromQL expressions can also be used like the following one which calculates the per-second rate of HTTP
requests as measured over the last 5 minutes.
[source,yaml]
-------------------------------------------------------------------------------------
- module: prometheus
  period: 10s
  hosts: ["localhost:9090"]
  metricsets: ["query"]
  queries:
  - name: "rate_http_requests_total"
    path: "/api/v1/query"
    params:
      query: "rate(prometheus_http_requests_total[5m])"
-------------------------------------------------------------------------------------




[float]
==== Range queries


The following example evaluates the expression `up` over a 30-second range with a query resolution of 15 seconds:
[source,yaml]
-------------------------------------------------------------------------------------
- module: prometheus
  period: 10s
  metricsets: ["query"]
  hosts: ["node:9100"]
  queries:
  - name: "up_master"
    path: "/api/v1/query_range"
    params:
      query: "up{node='master01'}"
      start: "2019-12-20T23:30:30.000Z"
      end: "2019-12-21T23:31:00.000Z"
      step: 15s
-------------------------------------------------------------------------------------
