forked from elastic/beats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Metricbeat] Add 'query' metricset for prometheus module (elastic#17104)
Co-authored-by: esther kim <jabbukka@naver.com>
- Loading branch information
Showing
26 changed files
with
1,204 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//// | ||
This file is generated! See scripts/mage/docs_collector.go | ||
//// | ||
|
||
[[metricbeat-metricset-prometheus-query]] | ||
=== Prometheus query metricset | ||
|
||
beta[] | ||
|
||
include::../../../module/prometheus/query/_meta/docs.asciidoc[] | ||
|
||
|
||
==== Fields | ||
|
||
For a description of each field in the metricset, see the | ||
<<exported-fields-prometheus,exported fields>> section. | ||
|
||
Here is an example document generated by this metricset: | ||
|
||
[source,json] | ||
---- | ||
include::../../../module/prometheus/query/_meta/data.json[] | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"@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": { | ||
"dataType": "vector", | ||
"go_threads": 26 | ||
} | ||
}, | ||
"service": { | ||
"address": "localhost:32768", | ||
"type": "prometheus" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
This is the `query` metricset to query from https://prometheus.io/docs/prometheus/latest/querying/api/#expression-queries[querying API of Promtheus]. | ||
|
||
|
||
[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 | ||
------------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- name: query | ||
type: group | ||
description: > | ||
query metricset | ||
release: beta | ||
fields: |
24 changes: 24 additions & 0 deletions
24
metricbeat/module/prometheus/query/_meta/test/querymetrics_instant_vector.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"status" : "success", | ||
"data" : { | ||
"resultType" : "vector", | ||
"result" : [ | ||
{ | ||
"metric" : { | ||
"__name__" : "up", | ||
"job" : "prometheus", | ||
"instance" : "localhost:9090" | ||
}, | ||
"value": [ 1435781451.781, "1.0" ] | ||
}, | ||
{ | ||
"metric" : { | ||
"__name__" : "up", | ||
"job" : "node", | ||
"instance" : "localhost:9100" | ||
}, | ||
"value" : [ 1435781451.781, "1.19" ] | ||
} | ||
] | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
metricbeat/module/prometheus/query/_meta/test/querymetrics_range_vector.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"status" : "success", | ||
"data" : { | ||
"resultType" : "matrix", | ||
"result" : [ | ||
{ | ||
"metric" : { | ||
"__name__" : "up", | ||
"job" : "prometheus", | ||
"instance" : "localhost:9090" | ||
}, | ||
"values" : [ | ||
[ 1435781430.781, "1" ], | ||
[ 1435781445.781, "1" ], | ||
[ 1435781460.781, "1" ] | ||
] | ||
}, | ||
{ | ||
"metric" : { | ||
"__name__" : "up", | ||
"job" : "node", | ||
"instance" : "localhost:9091" | ||
}, | ||
"values" : [ | ||
[ 1435781430.781, "0" ], | ||
[ 1435781445.781, "0" ], | ||
[ 1435781460.781, "1" ] | ||
] | ||
} | ||
] | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
metricbeat/module/prometheus/query/_meta/test/querymetrics_scalar.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"status":"success", | ||
"data":{ | ||
"resultType":"scalar", | ||
"result":[ | ||
1584628364.185, | ||
"100.4" | ||
] | ||
} | ||
} |
Oops, something went wrong.