Prometheus query metricset
Elastic Cloud Serverless projects are autoscaled environments, fully managed by Elastic and available on Elastic Cloud. Availability This functionality is generally available and ready for production usage. Serverless interfaces and procedures might differ from classic Elastic Stack deployments. The Elastic Stack includes Elastic's core products such as Elasticsearch, Kibana, Logstash, and Beats. Availability This functionality is generally available and ready for production usage. Unless stated otherwise on the page, this functionality is available when your Elastic Stack is deployed on Elastic Cloud Hosted, Elastic Cloud Enterprise, Elastic Cloud on Kubernetes, and self-managed environments. This documentation corresponds to the latest patch available for each minor version. If you're not using the latest patch, check the release notes for changes.
Serverless
Generally available
Stack
Generally available
This is the query metricset to query from querying API of Prometheus.
The following configuration performs an instant query for up metric at a single point in time:
- 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.
- 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])"
The following example evaluates the expression up over a 30-second range with a query resolution of 15 seconds:
- 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
For a description of each field in the metricset, see the exported fields section.
Here is an example document generated by this metricset:
{
"@timestamp": "2017-10-12T08:05:34.853Z",
"event": {
"dataset": "prometheus.query",
"duration": 115000,
"module": "prometheus"
},
"metricset": {
"name": "query",
"period": 10000
},
"prometheus": {
"labels": {
"__name__": "go_threads",
"instance": "localhost:9090",
"job": "prometheus"
},
"query": {
"go_threads": 18
}
},
"service": {
"address": "localhost:32769",
"type": "prometheus"
}
}