[8.x](backport #40411) {,x-pack/}metricbeat/module/prometheus/{collector,remote_write}: Add metrics_count to Prometheus module if metrics_count is true
#40784
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed commit message
Add
metrics_countmetric (counter) to each document (if enabled) forcollectorandremote_writedatastreams. Please see the sample docs for more info.Checklist
CHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.Sample output
Collector
{ "_index": ".ds-metricbeat-8.16.0-2024.08.01-000001", "_id": "i14sKZEBcmwqWRmK-rWQ", "_version": 1, "_score": 0, "_source": { "@timestamp": "2024-08-06T19:31:39.257Z", "prometheus": { "labels": { "instance": "localhost:8081", "job": "prometheus" }, "system_memory_usage_bytes": { "value": 7351702269.7480135 }, "up": { "value": 1 } }, "metrics_count": 2, "metricset": { "name": "collector", "period": 10000 }, "service": { "type": "prometheus", "address": "http://localhost:8081/metrics" }, "event": { "dataset": "prometheus.collector", "module": "prometheus", "duration": 2130125 }, "agent": { "name": "Subhams-MacBook-Pro.local", "type": "metricbeat", "version": "8.16.0", "ephemeral_id": "6d63b998-1566-4299-aa59-ced8c7a0b7e3", "id": "00e1e439-0173-4fb3-8d90-74f4b06ea202" }, "ecs": { "version": "8.0.0" }, "host": { "mac": [ "36-1C-20-59-8C-80", "36-1C-20-59-8C-84", "36-1C-20-59-8C-88", "6A-03-C5-9F-E3-B5", "6A-03-C5-9F-E3-B6", "6A-03-C5-9F-E3-B7", "6A-03-C5-9F-E3-D5", "6A-03-C5-9F-E3-D6", "6A-03-C5-9F-E3-D7", "AA-B7-74-48-81-60", "BC-D0-74-0D-6F-A5", "BE-D0-74-0D-6F-A5", "BE-D0-74-D0-53-64", "CA-59-C1-CF-D2-0F" ], "hostname": "Subhams-MacBook-Pro.local", "name": "subhams-macbook-pro.local", "architecture": "arm64", "os": { "type": "macos", "platform": "darwin", "version": "13.6", "family": "darwin", "name": "macOS", "kernel": "22.6.0", "build": "22G120" }, "id": "C2677768-AA3E-5023-BD42-EB78BC3453A2", "ip": [ "fe80::6803:c5ff:fe9f:e3d7", "fe80::6803:c5ff:fe9f:e3d5", "fe80::6803:c5ff:fe9f:e3d6", "fe80::bcd0:74ff:fe0d:6fa5", "fe80::8e1:bdcb:6244:6bc2", "2405:201:d02a:1114:1042:40ca:c385:f622", "2405:201:d02a:1114:da8:4a8:4c93:310f", "192.168.29.202", "fe80::c859:c1ff:fecf:d20f", "fe80::c859:c1ff:fecf:d20f", "fe80::c646:a13d:9b18:7919", "fe80::db4f:7fe7:4b9:cc51", "fe80::ce81:b1c:bd2c:69e", "fe80::8c9c:d4c3:99a0:8bf8", "fe80::781e:7cd2:79db:db56", "fe80::2376:e283:a58f:4f88", "fe80::7ff1:4c06:56e6:d8e2", "192.168.65.1", "fe80::bcd0:74ff:fed0:5364", "fda2:9011:41d4:6fd3:14bc:39e2:c7ad:76c4" ] } }, "fields": { "beats_state.state.host.hostname": [ "Subhams-MacBook-Pro.local" ], "host.os.name.text": [ "macOS" ], "host.hostname": [ "Subhams-MacBook-Pro.local" ], "host.mac": [ "36-1C-20-59-8C-80", "36-1C-20-59-8C-84", "36-1C-20-59-8C-88", "6A-03-C5-9F-E3-B5", "6A-03-C5-9F-E3-B6", "6A-03-C5-9F-E3-B7", "6A-03-C5-9F-E3-D5", "6A-03-C5-9F-E3-D6", "6A-03-C5-9F-E3-D7", "AA-B7-74-48-81-60", "BC-D0-74-0D-6F-A5", "BE-D0-74-0D-6F-A5", "BE-D0-74-D0-53-64", "CA-59-C1-CF-D2-0F" ], "host.os.build": [ "22G120" ], "service.type": [ "prometheus" ], "host.ip": [ "fe80::6803:c5ff:fe9f:e3d7", "fe80::6803:c5ff:fe9f:e3d5", "fe80::6803:c5ff:fe9f:e3d6", "fe80::bcd0:74ff:fe0d:6fa5", "fe80::8e1:bdcb:6244:6bc2", "2405:201:d02a:1114:1042:40ca:c385:f622", "2405:201:d02a:1114:da8:4a8:4c93:310f", "192.168.29.202", "fe80::c859:c1ff:fecf:d20f", "fe80::c859:c1ff:fecf:d20f", "fe80::c646:a13d:9b18:7919", "fe80::db4f:7fe7:4b9:cc51", "fe80::ce81:b1c:bd2c:69e", "fe80::8c9c:d4c3:99a0:8bf8", "fe80::781e:7cd2:79db:db56", "fe80::2376:e283:a58f:4f88", "fe80::7ff1:4c06:56e6:d8e2", "192.168.65.1", "fe80::bcd0:74ff:fed0:5364", "fda2:9011:41d4:6fd3:14bc:39e2:c7ad:76c4" ], "agent.type": [ "metricbeat" ], "logstash_stats.timestamp": [ "2024-08-06T19:31:39.257Z" ], "event.module": [ "prometheus" ], "host.os.version": [ "13.6" ], "host.os.kernel": [ "22.6.0" ], "host.os.name": [ "macOS" ], "metrics_count": [ 2 ], "agent.name": [ "Subhams-MacBook-Pro.local" ], "host.name": [ "subhams-macbook-pro.local" ], "beats_state.timestamp": [ "2024-08-06T19:31:39.257Z" ], "host.id": [ "C2677768-AA3E-5023-BD42-EB78BC3453A2" ], "beats_state.state.host.name": [ "subhams-macbook-pro.local" ], "timestamp": [ "2024-08-06T19:31:39.257Z" ], "prometheus.system_memory_usage_bytes.value": [ 7351702269.7480135 ], "prometheus.up.value": [ 1 ], "host.os.type": [ "macos" ], "kibana_stats.timestamp": [ "2024-08-06T19:31:39.257Z" ], "metricset.period": [ 10000 ], "agent.hostname": [ "Subhams-MacBook-Pro.local" ], "event.duration": [ 2130125 ], "host.architecture": [ "arm64" ], "metricset.name": [ "collector" ], "prometheus.labels.instance": [ "localhost:8081" ], "@timestamp": [ "2024-08-06T19:31:39.257Z" ], "agent.id": [ "00e1e439-0173-4fb3-8d90-74f4b06ea202" ], "ecs.version": [ "8.0.0" ], "host.os.platform": [ "darwin" ], "service.address": [ "http://localhost:8081/metrics" ], "agent.ephemeral_id": [ "6d63b998-1566-4299-aa59-ced8c7a0b7e3" ], "prometheus.labels.job": [ "prometheus" ], "agent.version": [ "8.16.0" ], "beats_state.state.host.architecture": [ "arm64" ], "host.os.family": [ "darwin" ], "event.dataset": [ "prometheus.collector" ] } }Remote Write
{ "@timestamp": [ "2024-08-06T20:11:35.881Z" ], "agent.ephemeral_id": [ "4b5d7b27-4dec-4d60-89c5-5214e9805929" ], "agent.hostname": [ "Subhams-MacBook-Pro.local" ], "agent.id": [ "00e1e439-0173-4fb3-8d90-74f4b06ea202" ], "agent.name": [ "Subhams-MacBook-Pro.local" ], "agent.type": [ "metricbeat" ], "agent.version": [ "8.16.0" ], "beats_state.state.host.architecture": [ "arm64" ], "beats_state.state.host.hostname": [ "Subhams-MacBook-Pro.local" ], "beats_state.state.host.name": [ "subhams-macbook-pro.local" ], "beats_state.timestamp": [ "2024-08-06T20:11:35.881Z" ], "ecs.version": [ "8.0.0" ], "event.dataset": [ "prometheus.remote_write" ], "event.module": [ "prometheus" ], "host.architecture": [ "arm64" ], "host.hostname": [ "Subhams-MacBook-Pro.local" ], "host.id": [ "C2677768-AA3E-5023-BD42-EB78BC3453A2" ], "host.ip": [ "fe80::6803:c5ff:fe9f:e3d7", "fe80::6803:c5ff:fe9f:e3d5", "fe80::6803:c5ff:fe9f:e3d6", "fe80::bcd0:74ff:fe0d:6fa5", "fe80::8e1:bdcb:6244:6bc2", "2405:201:d02a:1114:1042:40ca:c385:f622", "2405:201:d02a:1114:da8:4a8:4c93:310f", "192.168.29.202", "fe80::c859:c1ff:fecf:d20f", "fe80::c859:c1ff:fecf:d20f", "fe80::c646:a13d:9b18:7919", "fe80::db4f:7fe7:4b9:cc51", "fe80::ce81:b1c:bd2c:69e", "fe80::8c9c:d4c3:99a0:8bf8", "fe80::781e:7cd2:79db:db56", "fe80::2376:e283:a58f:4f88", "fe80::7ff1:4c06:56e6:d8e2", "192.168.65.1", "fe80::bcd0:74ff:fed0:5364", "fda2:9011:41d4:6fd3:14bc:39e2:c7ad:76c4" ], "host.mac": [ "36-1C-20-59-8C-80", "36-1C-20-59-8C-84", "36-1C-20-59-8C-88", "6A-03-C5-9F-E3-B5", "6A-03-C5-9F-E3-B6", "6A-03-C5-9F-E3-B7", "6A-03-C5-9F-E3-D5", "6A-03-C5-9F-E3-D6", "6A-03-C5-9F-E3-D7", "AA-B7-74-48-81-60", "BC-D0-74-0D-6F-A5", "BE-D0-74-0D-6F-A5", "BE-D0-74-D0-53-64", "CA-59-C1-CF-D2-0F" ], "host.name": [ "subhams-macbook-pro.local" ], "host.os.build": [ "22G120" ], "host.os.family": [ "darwin" ], "host.os.kernel": [ "22.6.0" ], "host.os.name": [ "macOS" ], "host.os.name.text": [ "macOS" ], "host.os.platform": [ "darwin" ], "host.os.type": [ "macos" ], "host.os.version": [ "13.6" ], "kibana_stats.timestamp": [ "2024-08-06T20:11:35.881Z" ], "logstash_stats.timestamp": [ "2024-08-06T20:11:35.881Z" ], "metrics_count": [ 6 ], "metricset.name": [ "remote_write" ], "prometheus.labels.instance": [ "localhost:8081" ], "prometheus.labels.job": [ "prometheus" ], "prometheus.scrape_duration_seconds.value": [ 0.0047865 ], "prometheus.scrape_samples_post_metric_relabeling.value": [ 17 ], "prometheus.scrape_samples_scraped.value": [ 17 ], "prometheus.scrape_series_added.value": [ 0 ], "prometheus.system_memory_usage_bytes.value": [ 2583889525.1153283 ], "prometheus.up.value": [ 1 ], "service.type": [ "prometheus" ], "timestamp": [ "2024-08-06T20:11:35.881Z" ], "_id": "-l5RKZEBcmwqWRmKn-Xc", "_index": ".ds-metricbeat-8.16.0-2024.08.01-000001", "_score": null }This is an automatic backport of pull request #40411 done by [Mergify](https://mergify.com).