From 8c87a935557666869dd389abb2be1f984d1fa7de Mon Sep 17 00:00:00 2001 From: Haoyu Sun Date: Wed, 5 Apr 2023 12:04:58 +0200 Subject: [PATCH] MON-3113: filter unneccessary metrics from mountstats collector. --- .../minimal-service-monitor.yaml | 8 +++++ assets/node-exporter/service-monitor.yaml | 14 ++++++++ jsonnet/components/node-exporter.libsonnet | 36 +++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/assets/node-exporter/minimal-service-monitor.yaml b/assets/node-exporter/minimal-service-monitor.yaml index 925f087012..b3ed816f32 100644 --- a/assets/node-exporter/minimal-service-monitor.yaml +++ b/assets/node-exporter/minimal-service-monitor.yaml @@ -14,6 +14,14 @@ spec: - bearerTokenFile: "" interval: 15s metricRelabelings: + - action: replace + regex: (node_mountstats_nfs_read_bytes_total|node_mountstats_nfs_write_bytes_total|node_mountstats_nfs_operations_requests_total) + replacement: "true" + sourceLabels: + - __name__ + targetLabel: __tmp_keep + - action: labeldrop + regex: __tmp_keep - action: keep regex: (node_cpu_info|node_cpu_seconds_total|node_disk_io_time_seconds_total|node_disk_io_time_weighted_seconds_total|node_disk_read_time_seconds_total|node_disk_reads_completed_total|node_disk_write_time_seconds_total|node_disk_writes_completed_total|node_filefd_allocated|node_filefd_maximum|node_filesystem_avail_bytes|node_filesystem_files|node_filesystem_files_free|node_filesystem_free_bytes|node_filesystem_readonly|node_filesystem_size_bytes|node_load1|node_memory_Buffers_bytes|node_memory_Cached_bytes|node_memory_MemAvailable_bytes|node_memory_MemFree_bytes|node_memory_MemTotal_bytes|node_memory_Slab_bytes|node_netstat_TcpExt_TCPSynRetrans|node_netstat_Tcp_OutSegs|node_netstat_Tcp_RetransSegs|node_network_receive_bytes_total|node_network_receive_drop_total|node_network_receive_errs_total|node_network_receive_packets_total|node_network_transmit_bytes_total|node_network_transmit_drop_total|node_network_transmit_errs_total|node_network_transmit_packets_total|node_network_up|node_nf_conntrack_entries|node_nf_conntrack_entries_limit|node_textfile_scrape_error|node_timex_maxerror_seconds|node_timex_offset_seconds|node_timex_sync_status|node_vmstat_pgmajfault|process_start_time_seconds|virt_platform) sourceLabels: diff --git a/assets/node-exporter/service-monitor.yaml b/assets/node-exporter/service-monitor.yaml index 9d3ba63ed3..d64583896a 100644 --- a/assets/node-exporter/service-monitor.yaml +++ b/assets/node-exporter/service-monitor.yaml @@ -13,6 +13,20 @@ spec: endpoints: - bearerTokenFile: "" interval: 15s + metricRelabelings: + - action: replace + regex: (node_mountstats_nfs_read_bytes_total|node_mountstats_nfs_write_bytes_total|node_mountstats_nfs_operations_requests_total) + replacement: "true" + sourceLabels: + - __name__ + targetLabel: __tmp_keep + - action: drop + regex: node_mountstats_nfs_.+; + sourceLabels: + - __name__ + - __tmp_keep + - action: labeldrop + regex: __tmp_keep port: https relabelings: - action: replace diff --git a/jsonnet/components/node-exporter.libsonnet b/jsonnet/components/node-exporter.libsonnet index 129e192a1a..ec7d0eb56d 100644 --- a/jsonnet/components/node-exporter.libsonnet +++ b/jsonnet/components/node-exporter.libsonnet @@ -31,6 +31,42 @@ function(params) 'monitoring.openshift.io/collection-profile': 'full', }, }, + spec+: { + endpoints: [ + endpoint { + local metricRelabelingsOld = if std.objectHas(endpoint, 'metricRelabelings') then endpoint.metricRelabelings else [], + metricRelabelings: + metricRelabelingsOld + + [ + { + // Drop other metrics from mountstats collector than these 3 metrics: + // 1. node_mountstats_nfs_read_bytes_total + // 2. node_mountstats_nfs_write_bytes_total + // 3. node_mountstats_nfs_operations_requests_total + sourceLabels: ['__name__'], + regex+: '(' + std.join('|', [ + 'node_mountstats_nfs_read_bytes_total', + 'node_mountstats_nfs_write_bytes_total', + 'node_mountstats_nfs_operations_requests_total', + ]) + ')', + action: 'replace', + targetLabel: '__tmp_keep', + replacement: 'true', + }, + { + action: 'drop', + sourceLabels: ['__name__', '__tmp_keep'], + regex: 'node_mountstats_nfs_.+;', + }, + { + action: 'labeldrop', + regex: '__tmp_keep', + }, + ], + } + for endpoint in super.endpoints + ], + }, }, minimalServiceMonitor: generateServiceMonitor.minimal(