diff --git a/lib/metrics/pool.go b/lib/metrics/pool.go
index b1775d3f7d30d6964016db63cba9cc02afd366f6..997fc6bce222613e0d2b345f300c7dc0dc48f397 100644
--- a/lib/metrics/pool.go
+++ b/lib/metrics/pool.go
@@ -8,12 +8,14 @@ import (
 )
 
 type poolMetrics struct {
-	name          string
-	TxLatency     *prometheus.HistogramVec
-	QueryLatency  *prometheus.HistogramVec
-	WaitLatency   *prometheus.HistogramVec
-	ReceivedBytes *prometheus.CounterVec
-	SentBytes     *prometheus.CounterVec
+	name             string
+	TxLatency        *prometheus.HistogramVec
+	QueryLatency     *prometheus.HistogramVec
+	TxErrorCounts    *prometheus.CounterVec
+	QueryErrorCounts *prometheus.CounterVec
+	WaitLatency      *prometheus.HistogramVec
+	ReceivedBytes    *prometheus.CounterVec
+	SentBytes        *prometheus.CounterVec
 }
 
 func PoolMetrics(db string, user string) poolMetrics {
@@ -48,6 +50,22 @@ func newPoolMetrics(db string, user string) poolMetrics {
 				"user": user,
 			},
 		}, []string{}),
+		TxErrorCounts: promauto.NewCounterVec(prometheus.CounterOpts{
+			Name: "pggat_db_transaction_error_count_total",
+			Help: "transaction latency",
+			ConstLabels: prometheus.Labels{
+				"db":   db,
+				"user": user,
+			},
+		}, []string{"error"}),
+		QueryErrorCounts: promauto.NewCounterVec(prometheus.CounterOpts{
+			Name: "pggat_db_query_error_count_total",
+			Help: "transaction latency",
+			ConstLabels: prometheus.Labels{
+				"db":   db,
+				"user": user,
+			},
+		}, []string{"error"}),
 		WaitLatency: promauto.NewHistogramVec(prometheus.HistogramOpts{
 			Name:    "pggat_db_wait_latency",
 			Help:    "wait latency",
@@ -109,3 +127,25 @@ func RecordWaitTime(db string, user string, dur time.Duration) {
 	p := PoolMetrics(db, user)
 	p.WaitLatency.WithLabelValues().Observe(float64(dur.Nanoseconds()))
 }
+
+func RecordTransactionError(db string, user string, err error) {
+	if !On() {
+		return
+	}
+	p := PoolMetrics(db, user)
+	if err == nil {
+		return
+	}
+	p.TxErrorCounts.WithLabelValues(err.Error()).Inc()
+}
+
+func RecordQueryError(db string, user string, err error) {
+	if !On() {
+		return
+	}
+	p := PoolMetrics(db, user)
+	if err == nil {
+		return
+	}
+	p.TxErrorCounts.WithLabelValues(err.Error()).Inc()
+}