Skip to content

Commit 1522360

Browse files
craig[bot]kyle-a-wong
andcommitted
Merge #151066
151066: cli: add cluster_settings_history.txt to debug zip r=kyle-a-wong a=kyle-a-wong Adds a new file exported to debug zip called "cluster_settings_history.txt" which provides a history of cluster setting changes, as they exist in the system event log table. This means history will only exist as long as the events haven't been removed from the table. Sensitive cluster settings will always be redacted in this file, and non reportable cluster settings will be redacted for redacted debug zips. Epic: CRDB-52093 Resolves: CRDB-50883 Release note (cli change): Adds a new file to debug zip that provides a history of cluster setting changes. Sensitive cluster settings will always be redacted in this file, and non reportable cluster settings will be redacted for redacted debug zips. Co-authored-by: Kyle Wong <[email protected]>
2 parents 8fcfd5a + 93e2085 commit 1522360

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

pkg/cli/testdata/zip/file-filters/testzip_file_filters

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include all filters. We are excluding cpu.pprof file to avoid flakiness in tests.
22
--include-files=* --exclude-files=cpu.pprof
33
----
4+
debug/cluster_settings_history.txt
45
debug/crdb_internal.cluster_contention_events.txt
56
debug/crdb_internal.cluster_database_privileges.txt
67
debug/crdb_internal.cluster_distsql_flows.txt
@@ -144,6 +145,7 @@ debug/tenant_ranges.err.txt
144145
#include only txt files
145146
--include-files=*.txt
146147
----
148+
debug/cluster_settings_history.txt
147149
debug/crdb_internal.cluster_contention_events.txt
148150
debug/crdb_internal.cluster_database_privileges.txt
149151
debug/crdb_internal.cluster_distsql_flows.txt
@@ -294,6 +296,7 @@ debug/tenant_ranges.err.txt
294296
#exclude only log files. We are excluding cpu.pprof file to avoid flakiness in tests.
295297
--exclude-files=*.log,cpu.pprof
296298
----
299+
debug/cluster_settings_history.txt
297300
debug/crdb_internal.cluster_contention_events.txt
298301
debug/crdb_internal.cluster_database_privileges.txt
299302
debug/crdb_internal.cluster_distsql_flows.txt
@@ -438,6 +441,7 @@ debug/tenant_ranges.err.txt
438441
#exclude only json files. We are excluding cpu.pprof file to avoid flakiness in tests.
439442
--exclude-files=*.json,cpu.pprof
440443
----
444+
debug/cluster_settings_history.txt
441445
debug/crdb_internal.cluster_contention_events.txt
442446
debug/crdb_internal.cluster_database_privileges.txt
443447
debug/crdb_internal.cluster_distsql_flows.txt
@@ -550,6 +554,7 @@ debug/tenant_ranges.err.txt
550554
#include only txt files with system table file exclustion
551555
--include-files=*.txt --exclude-files=system.*.txt
552556
----
557+
debug/cluster_settings_history.txt
553558
debug/crdb_internal.cluster_contention_events.txt
554559
debug/crdb_internal.cluster_database_privileges.txt
555560
debug/crdb_internal.cluster_distsql_flows.txt

pkg/cli/zip_table_registry.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,61 @@ FROM crdb_internal.transaction_contention_events
674674
"full_config_sql",
675675
},
676676
},
677+
// cluster_settings_history Provides a history of cluster settings changes
678+
// via the system.eventlog table. If the value is reset via `RESET
679+
// CLUSTER SETTING <x>`, the value is shown as 'DEFAULT'. This can be used
680+
// to distinguish between when a user explicitly sets the value to the
681+
// default value via `SET CLUSTER SETTING <x> = <y>`. For cluster settings
682+
// set in v25.4+, the `default_value` column will show the default value
683+
// for the setting at the time of the change, which may differ from the
684+
// current default value.
685+
// The `value` column will always be redacted if the setting is sensitive.
686+
// If a redacted debug zip is requested, non-reportable settings will
687+
// also be redacted.
688+
"cluster_settings_history": {
689+
customQueryUnredacted: `
690+
WITH setting_events AS (
691+
SELECT
692+
timestamp,
693+
info::jsonb AS info_json
694+
FROM system.eventlog
695+
WHERE "eventType" = 'set_cluster_setting'
696+
)
697+
SELECT
698+
info_json ->> 'SettingName' as setting_name,
699+
CASE
700+
WHEN cs.sensitive AND info_json ->> 'Value' <> 'DEFAULT' THEN '<redacted>'
701+
ELSE info_json ->> 'Value'
702+
END value,
703+
info_json ->> 'DefaultValue' as default_value,
704+
cs.default_value as current_default_value,
705+
info_json ->> 'ApplicationName' as application_name,
706+
se.timestamp
707+
FROM setting_events se
708+
JOIN crdb_internal.cluster_settings cs on cs.variable = se.info_json ->> 'SettingName'
709+
ORDER BY setting_name, timestamp`,
710+
customQueryRedacted: `
711+
WITH setting_events AS (
712+
SELECT
713+
timestamp,
714+
info::jsonb AS info_json
715+
FROM system.eventlog
716+
WHERE "eventType" = 'set_cluster_setting'
717+
)
718+
SELECT
719+
info_json ->> 'SettingName' as setting_name,
720+
CASE
721+
WHEN (cs.sensitive OR NOT cs.reportable) AND info_json ->> 'Value' <> 'DEFAULT' THEN '<redacted>'
722+
ELSE info_json ->> 'Value'
723+
END value,
724+
info_json ->> 'DefaultValue' as default_value,
725+
cs.default_value as current_default_value,
726+
info_json ->> 'ApplicationName' as application_name,
727+
se.timestamp
728+
FROM setting_events se
729+
JOIN crdb_internal.cluster_settings cs on cs.variable = se.info_json ->> 'SettingName'
730+
ORDER BY setting_name, timestamp`,
731+
},
677732
}
678733

679734
var zipInternalTablesPerNode = DebugZipTableRegistry{

pkg/cli/zip_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ ORDER BY name ASC`)
135135
tables = append(tables, table)
136136
}
137137
tables = append(tables, "crdb_internal.probe_ranges_1s_read_limit_100")
138+
tables = append(tables, "cluster_settings_history")
138139
sort.Strings(tables)
139140

140141
var exp []string

0 commit comments

Comments
 (0)