-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor Prometheus metric mappings #9948
Changes from all commits
64a5c0b
e3004d0
c2fc75e
86bc56a
411cc77
7ac6a9b
28167f9
ec1feed
229c108
694d58d
940734d
5a970c4
5657e00
b6af126
2536029
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,8 @@ This file is generated! See scripts/docs_collector.py | |
[[metricbeat-module-prometheus]] | ||
== Prometheus module | ||
|
||
This module periodically fetches metrics from | ||
https://prometheus.io/docs/[Prometheus]. | ||
|
||
The default metricset is `collector`. | ||
This module periodically scrapes metrics from | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As you remove the stats metricset, we could already be here more specific that it scrapes metrics from prometheus exporters? |
||
https://prometheus.io/docs/instrumenting/exporters/[Prometheus exporters]. | ||
|
||
|
||
[float] | ||
|
@@ -21,20 +19,11 @@ in <<configuration-metricbeat>>. Here is an example configuration: | |
---- | ||
metricbeat.modules: | ||
- module: prometheus | ||
metricsets: ["stats"] | ||
enabled: true | ||
period: 10s | ||
hosts: ["localhost:9090"] | ||
#metrics_path: /metrics | ||
#namespace: example | ||
|
||
- module: prometheus | ||
metricsets: ["collector"] | ||
enabled: true | ||
period: 10s | ||
hosts: ["localhost:9090"] | ||
#metrics_path: /metrics | ||
#namespace: example | ||
metrics_path: /metrics | ||
#username: "user" | ||
#password: "secret" | ||
|
||
# This can be used for service account based authorization: | ||
# bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token | ||
|
@@ -52,9 +41,5 @@ The following metricsets are available: | |
|
||
* <<metricbeat-metricset-prometheus-collector,collector>> | ||
|
||
* <<metricbeat-metricset-prometheus-stats,stats>> | ||
|
||
include::prometheus/collector.asciidoc[] | ||
|
||
include::prometheus/stats.asciidoc[] | ||
|
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
FROM prom/prometheus:v1.5.1 | ||
FROM prom/prometheus:v2.6.0 | ||
HEALTHCHECK --interval=1s --retries=90 CMD nc -w 1 localhost 9090 </dev/null | ||
EXPOSE 9090 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
This module periodically fetches metrics from | ||
https://prometheus.io/docs/[Prometheus]. | ||
|
||
The default metricset is `collector`. | ||
This module periodically scrapes metrics from | ||
https://prometheus.io/docs/instrumenting/exporters/[Prometheus exporters]. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
- key: prometheus | ||
title: "Prometheus" | ||
description: > | ||
Stats collected from Prometheus. | ||
Stats scraped from a Prometheus endpoint. | ||
short_config: false | ||
release: ga | ||
settings: ["ssl", "http"] | ||
fields: | ||
- name: prometheus | ||
type: group | ||
# Order is important here, labels will match first, the rest are double | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about placing labels in the base level to avoid possible issues with this? This is also the recommendation in ECS. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would prefer to keep it like this for now, main reasons are:
I want to make sure this module won't end on mapping issues and we can use these metrics reliably, not against this change once the problem is gone (for instance, if/when index per module is implemented). WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM, but I wonder some things (not blocking this PR)
Why would we want to do it here?
I guess this is no different with any other module, maybe we shouldn't have a field for labels in ECS till we don't have a complete solution for these mapping issues. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That could make sense, I still have some doubts on how ECS will play out in cases like this, I would prefer to play it safe on this module and learn from the process with others 😇 |
||
- name: prometheus.labels | ||
type: object | ||
object_type: keyword | ||
description: > | ||
fields: | ||
Prometheus metric labels | ||
- name: prometheus.metrics | ||
type: object | ||
object_type: double | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
object_type_mapping_type: "*" | ||
description: > | ||
Prometheus metric |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
{ | ||
"@timestamp": "2017-10-12T08:05:34.853Z", | ||
"beat": { | ||
"agent": { | ||
"hostname": "host.example.com", | ||
"name": "host.example.com" | ||
}, | ||
"event": { | ||
"dataset": "prometheus.collector", | ||
"duration": 115000, | ||
"module": "prometheus" | ||
}, | ||
"metricset": { | ||
"host": "prometheus:9090", | ||
"module": "prometheus", | ||
"name": "collector", | ||
"namespace": "collector", | ||
"rtt": 115 | ||
"name": "collector" | ||
}, | ||
"prometheus": { | ||
"collector": { | ||
"label": { | ||
"event": "add", | ||
"role": "node" | ||
}, | ||
"prometheus_sd_kubernetes_events_total": { | ||
"value": 0 | ||
} | ||
"labels": { | ||
"interval": "15s" | ||
}, | ||
"metrics": { | ||
"prometheus_target_interval_length_seconds_count": 1, | ||
"prometheus_target_interval_length_seconds_sum": 15.000226176 | ||
} | ||
}, | ||
"service": { | ||
"address": "172.29.0.2:9090", | ||
"type": "prometheus" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an interesting one. We should probably make it configurable so the user can set service.type and service.name. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,43 @@ | ||
The Prometheus `collector` metricset fetches data from https://prometheus.io/docs/instrumenting/exporters/[prometheus exporters]. | ||
The Prometheus `collector` metricset scrapes data from https://prometheus.io/docs/instrumenting/exporters/[prometheus exporters]. | ||
|
||
All events with the same labels are grouped together as one event. The fields | ||
exported by this metricset vary depending on the Prometheus exporter that you're | ||
using. | ||
|
||
[float] | ||
=== Scraping from a Prometheus exporter | ||
|
||
To scrape metrics from a Prometheus exporter, configure the `hosts` field to it. The path | ||
to retrieve the metrics from (`/metrics` by default) can be configured with `metrics_path`. | ||
|
||
[source,yaml] | ||
------------------------------------------------------------------------------------- | ||
- module: prometheus | ||
period: 10s | ||
hosts: ["localhost:9090"] | ||
metrics_path: /metrics | ||
|
||
#username: "user" | ||
#password: "secret" | ||
|
||
# This can be used for service account based authorization: | ||
#bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token | ||
#ssl.certificate_authorities: | ||
# - /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt | ||
------------------------------------------------------------------------------------- | ||
|
||
|
||
[float] | ||
=== Scraping all metrics from a Prometheus server | ||
|
||
This module can scrape all metrics stored in a Prometheus server, by using the | ||
https://prometheus.io/docs/prometheus/latest/federation/[federation API]. By pointing this | ||
config to the Prometheus server: | ||
|
||
[source,yaml] | ||
------------------------------------------------------------------------------------- | ||
metricbeat.modules: | ||
- module: prometheus | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is kind of like a second "flawor" of the metricset. In the future we potentially could add a simple config There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like it, it would be a nice addition, I agree it can be added later |
||
period: 10s | ||
hosts: ["localhost:9090"] | ||
metrics_path: '/federate' | ||
query: | ||
'match[]': '{__name__!=""}' | ||
------------------------------------------------------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also needs a note, that the stat metricset was removed.