From 46e046e779f4cb97938668fe62967b2281333cde Mon Sep 17 00:00:00 2001 From: Suhas Thalanki <54014218+thesuhas@users.noreply.github.com> Date: Thu, 3 Apr 2025 10:54:45 -0400 Subject: [PATCH] Exporting `file_cache_used` to calculate LFC utilization (#11384) ## Problem Exporting `file_cache_used` which specifies the number of used chunks in the LFC. This helps calculate LFC utilization as: `file_cache_used_pages / (file_cache_used * file_cache_chunk_size_pages)` ## Summary of changes Exporting `file_cache_used`. Related Issue: https://github.com/neondatabase/cloud/issues/26688 --- compute/etc/neon_collector.jsonnet | 1 + compute/etc/sql_exporter/lfc_used_pages.libsonnet | 10 ++++++++++ compute/etc/sql_exporter/lfc_used_pages.sql | 1 + 3 files changed, 12 insertions(+) create mode 100644 compute/etc/sql_exporter/lfc_used_pages.libsonnet create mode 100644 compute/etc/sql_exporter/lfc_used_pages.sql diff --git a/compute/etc/neon_collector.jsonnet b/compute/etc/neon_collector.jsonnet index da2b86d542..449e1199d0 100644 --- a/compute/etc/neon_collector.jsonnet +++ b/compute/etc/neon_collector.jsonnet @@ -33,6 +33,7 @@ import 'sql_exporter/lfc_hits.libsonnet', import 'sql_exporter/lfc_misses.libsonnet', import 'sql_exporter/lfc_used.libsonnet', + import 'sql_exporter/lfc_used_pages.libsonnet', import 'sql_exporter/lfc_writes.libsonnet', import 'sql_exporter/logical_slot_restart_lsn.libsonnet', import 'sql_exporter/max_cluster_size.libsonnet', diff --git a/compute/etc/sql_exporter/lfc_used_pages.libsonnet b/compute/etc/sql_exporter/lfc_used_pages.libsonnet new file mode 100644 index 0000000000..1e39a93482 --- /dev/null +++ b/compute/etc/sql_exporter/lfc_used_pages.libsonnet @@ -0,0 +1,10 @@ +{ + metric_name: 'lfc_used_pages', + type: 'gauge', + help: 'LFC pages used', + key_labels: null, + values: [ + 'lfc_used_pages', + ], + query: importstr 'sql_exporter/lfc_used_pages.sql', +} diff --git a/compute/etc/sql_exporter/lfc_used_pages.sql b/compute/etc/sql_exporter/lfc_used_pages.sql new file mode 100644 index 0000000000..56d92f8514 --- /dev/null +++ b/compute/etc/sql_exporter/lfc_used_pages.sql @@ -0,0 +1 @@ +SELECT lfc_value AS lfc_used_pages FROM neon.neon_lfc_stats WHERE lfc_key = 'file_cache_used_pages';