diff --git a/docs/generated/metrics/metrics.html b/docs/generated/metrics/metrics.html
index e6b3fed655e3..d84dc4a036e9 100644
--- a/docs/generated/metrics/metrics.html
+++ b/docs/generated/metrics/metrics.html
@@ -1444,7 +1444,7 @@
APPLICATION | sql.statements.active | Number of currently active user SQL statements | Active Statements | GAUGE | COUNT | AVG | NONE |
APPLICATION | sql.statements.active.internal | Number of currently active user SQL statements (internal queries) | SQL Internal Statements | GAUGE | COUNT | AVG | NONE |
APPLICATION | sql.stats.activity.update.latency | The latency of updates made by the SQL activity updater job. Includes failed update attempts | Nanoseconds | HISTOGRAM | NANOSECONDS | AVG | NONE |
-APPLICATION | sql.stats.activity.updates.failed | Number of update attempts made by the SQL activity updater job that failed with errors | failed updatesgi | COUNTER | COUNT | AVG | NON_NEGATIVE_DERIVATIVE |
+APPLICATION | sql.stats.activity.updates.failed | Number of update attempts made by the SQL activity updater job that failed with errors | failed updates | COUNTER | COUNT | AVG | NON_NEGATIVE_DERIVATIVE |
APPLICATION | sql.stats.activity.updates.successful | Number of successful updates made by the SQL activity updater job | successful updates | COUNTER | COUNT | AVG | NON_NEGATIVE_DERIVATIVE |
APPLICATION | sql.stats.cleanup.rows_removed | Number of stale statistics rows that are removed | SQL Stats Cleanup | COUNTER | COUNT | AVG | NON_NEGATIVE_DERIVATIVE |
APPLICATION | sql.stats.discarded.current | Number of fingerprint statistics being discarded | Discarded SQL Stats | COUNTER | COUNT | AVG | NON_NEGATIVE_DERIVATIVE |
@@ -1452,6 +1452,7 @@
APPLICATION | sql.stats.flush.done_signals.ignored | Number of times the SQL Stats activity update job ignored the signal sent to it indicating a flush has completed | flush done signals ignored | COUNTER | COUNT | AVG | NON_NEGATIVE_DERIVATIVE |
APPLICATION | sql.stats.flush.duration | Time took to in nanoseconds to complete SQL Stats flush | SQL Stats Flush | HISTOGRAM | NANOSECONDS | AVG | NONE |
APPLICATION | sql.stats.flush.error | Number of errors encountered when flushing SQL Stats | SQL Stats Flush | COUNTER | COUNT | AVG | NON_NEGATIVE_DERIVATIVE |
+APPLICATION | sql.stats.flush.fingerprint.count | The number of unique statement and transaction fingerprints included in the SQL Stats flush | statement & transaction fingerprints | COUNTER | COUNT | AVG | NON_NEGATIVE_DERIVATIVE |
APPLICATION | sql.stats.mem.current | Current memory usage for fingerprint storage | Memory | GAUGE | BYTES | AVG | NONE |
APPLICATION | sql.stats.mem.max | Memory usage for fingerprint storage | Memory | HISTOGRAM | BYTES | AVG | NONE |
APPLICATION | sql.stats.reported.mem.current | Current memory usage for reported fingerprint storage | Memory | GAUGE | BYTES | AVG | NONE |
diff --git a/pkg/sql/conn_executor.go b/pkg/sql/conn_executor.go
index 9c97798df044..51bddc0279a0 100644
--- a/pkg/sql/conn_executor.go
+++ b/pkg/sql/conn_executor.go
@@ -487,6 +487,7 @@ func NewServer(cfg *ExecutorConfig, pool *mon.BytesMonitor) *Server {
Knobs: cfg.SQLStatsTestingKnobs,
FlushCounter: serverMetrics.StatsMetrics.SQLStatsFlushStarted,
FlushDoneSignalsIgnored: serverMetrics.StatsMetrics.SQLStatsFlushDoneSignalsIgnored,
+ FlushedFingerprintCount: serverMetrics.StatsMetrics.SQLStatsFlushFingerprintCount,
FailureCounter: serverMetrics.StatsMetrics.SQLStatsFlushFailure,
FlushDuration: serverMetrics.StatsMetrics.SQLStatsFlushDuration,
}, memSQLStats)
@@ -587,6 +588,7 @@ func makeServerMetrics(cfg *ExecutorConfig) ServerMetrics {
DiscardedStatsCount: metric.NewCounter(MetaDiscardedSQLStats),
SQLStatsFlushStarted: metric.NewCounter(MetaSQLStatsFlushStarted),
SQLStatsFlushDoneSignalsIgnored: metric.NewCounter(MetaSQLStatsFlushDoneSignalsIgnored),
+ SQLStatsFlushFingerprintCount: metric.NewCounter(MetaSQLStatsFlushFingerprintCount),
SQLStatsFlushFailure: metric.NewCounter(MetaSQLStatsFlushFailure),
SQLStatsFlushDuration: metric.NewHistogram(metric.HistogramOptions{
diff --git a/pkg/sql/exec_util.go b/pkg/sql/exec_util.go
index 001d79107c15..71d4a62cc968 100644
--- a/pkg/sql/exec_util.go
+++ b/pkg/sql/exec_util.go
@@ -1135,6 +1135,12 @@ var (
Measurement: "SQL Stats Flush",
Unit: metric.Unit_COUNT,
}
+ MetaSQLStatsFlushFingerprintCount = metric.Metadata{
+ Name: "sql.stats.flush.fingerprint.count",
+ Help: "The number of unique statement and transaction fingerprints included in the SQL Stats flush",
+ Measurement: "statement & transaction fingerprints",
+ Unit: metric.Unit_COUNT,
+ }
MetaSQLStatsFlushDoneSignalsIgnored = metric.Metadata{
Name: "sql.stats.flush.done_signals.ignored",
Help: "Number of times the SQL Stats activity update job ignored the signal sent to it indicating " +
diff --git a/pkg/sql/executor_statement_metrics.go b/pkg/sql/executor_statement_metrics.go
index 1dee940545e3..9a9665e76a05 100644
--- a/pkg/sql/executor_statement_metrics.go
+++ b/pkg/sql/executor_statement_metrics.go
@@ -77,6 +77,7 @@ type StatsMetrics struct {
SQLStatsFlushStarted *metric.Counter
SQLStatsFlushDoneSignalsIgnored *metric.Counter
+ SQLStatsFlushFingerprintCount *metric.Counter
SQLStatsFlushFailure *metric.Counter
SQLStatsFlushDuration metric.IHistogram
SQLStatsRemovedRows *metric.Counter
diff --git a/pkg/sql/sql_activity_update_job.go b/pkg/sql/sql_activity_update_job.go
index 35f899275470..a3307c3541dc 100644
--- a/pkg/sql/sql_activity_update_job.go
+++ b/pkg/sql/sql_activity_update_job.go
@@ -137,7 +137,7 @@ func newActivityUpdaterMetrics() metric.Struct {
NumFailedUpdates: metric.NewCounter(metric.Metadata{
Name: "sql.stats.activity.updates.failed",
Help: "Number of update attempts made by the SQL activity updater job that failed with errors",
- Measurement: "failed updatesgi",
+ Measurement: "failed updates",
Unit: metric.Unit_COUNT,
MetricType: io_prometheus_client.MetricType_COUNTER,
}),
diff --git a/pkg/sql/sqlstats/persistedsqlstats/flush.go b/pkg/sql/sqlstats/persistedsqlstats/flush.go
index 57fc4c723d2b..7d23c02789ad 100644
--- a/pkg/sql/sqlstats/persistedsqlstats/flush.go
+++ b/pkg/sql/sqlstats/persistedsqlstats/flush.go
@@ -68,8 +68,10 @@ func (s *PersistedSQLStats) Flush(ctx context.Context) {
return
}
+ fingerprintCount := s.SQLStats.GetTotalFingerprintCount()
+ s.cfg.FlushedFingerprintCount.Inc(fingerprintCount)
log.Infof(ctx, "flushing %d stmt/txn fingerprints (%d bytes) after %s",
- s.SQLStats.GetTotalFingerprintCount(), s.SQLStats.GetTotalFingerprintBytes(), timeutil.Since(s.lastFlushStarted))
+ fingerprintCount, s.SQLStats.GetTotalFingerprintBytes(), timeutil.Since(s.lastFlushStarted))
s.lastFlushStarted = now
aggregatedTs := s.ComputeAggregatedTs()
diff --git a/pkg/sql/sqlstats/persistedsqlstats/provider.go b/pkg/sql/sqlstats/persistedsqlstats/provider.go
index a9fd7bcbd44d..34906bb3ea11 100644
--- a/pkg/sql/sqlstats/persistedsqlstats/provider.go
+++ b/pkg/sql/sqlstats/persistedsqlstats/provider.go
@@ -50,6 +50,7 @@ type Config struct {
FlushDuration metric.IHistogram
FlushDoneSignalsIgnored *metric.Counter
FailureCounter *metric.Counter
+ FlushedFingerprintCount *metric.Counter
// Testing knobs.
Knobs *sqlstats.TestingKnobs