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 @@ APPLICATIONsql.statements.activeNumber of currently active user SQL statementsActive StatementsGAUGECOUNTAVGNONE APPLICATIONsql.statements.active.internalNumber of currently active user SQL statements (internal queries)SQL Internal StatementsGAUGECOUNTAVGNONE APPLICATIONsql.stats.activity.update.latencyThe latency of updates made by the SQL activity updater job. Includes failed update attemptsNanosecondsHISTOGRAMNANOSECONDSAVGNONE -APPLICATIONsql.stats.activity.updates.failedNumber of update attempts made by the SQL activity updater job that failed with errorsfailed updatesgiCOUNTERCOUNTAVGNON_NEGATIVE_DERIVATIVE +APPLICATIONsql.stats.activity.updates.failedNumber of update attempts made by the SQL activity updater job that failed with errorsfailed updatesCOUNTERCOUNTAVGNON_NEGATIVE_DERIVATIVE APPLICATIONsql.stats.activity.updates.successfulNumber of successful updates made by the SQL activity updater jobsuccessful updatesCOUNTERCOUNTAVGNON_NEGATIVE_DERIVATIVE APPLICATIONsql.stats.cleanup.rows_removedNumber of stale statistics rows that are removedSQL Stats CleanupCOUNTERCOUNTAVGNON_NEGATIVE_DERIVATIVE APPLICATIONsql.stats.discarded.currentNumber of fingerprint statistics being discardedDiscarded SQL StatsCOUNTERCOUNTAVGNON_NEGATIVE_DERIVATIVE @@ -1452,6 +1452,7 @@ APPLICATIONsql.stats.flush.done_signals.ignoredNumber of times the SQL Stats activity update job ignored the signal sent to it indicating a flush has completedflush done signals ignoredCOUNTERCOUNTAVGNON_NEGATIVE_DERIVATIVE APPLICATIONsql.stats.flush.durationTime took to in nanoseconds to complete SQL Stats flushSQL Stats FlushHISTOGRAMNANOSECONDSAVGNONE APPLICATIONsql.stats.flush.errorNumber of errors encountered when flushing SQL StatsSQL Stats FlushCOUNTERCOUNTAVGNON_NEGATIVE_DERIVATIVE +APPLICATIONsql.stats.flush.fingerprint.countThe number of unique statement and transaction fingerprints included in the SQL Stats flushstatement & transaction fingerprintsCOUNTERCOUNTAVGNON_NEGATIVE_DERIVATIVE APPLICATIONsql.stats.mem.currentCurrent memory usage for fingerprint storageMemoryGAUGEBYTESAVGNONE APPLICATIONsql.stats.mem.maxMemory usage for fingerprint storageMemoryHISTOGRAMBYTESAVGNONE APPLICATIONsql.stats.reported.mem.currentCurrent memory usage for reported fingerprint storageMemoryGAUGEBYTESAVGNONE 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