good morning!!!!

Skip to content
Snippets Groups Projects
Commit 19a6352a authored by Garet Halliday's avatar Garet Halliday
Browse files

Merge branch 'metrics' into 'master'

Metrics

See merge request gfx/pggat!3
parents 255d4c22 03fc2a13
No related branches found
No related tags found
No related merge requests found
package metrics
import (
"os"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
......@@ -21,14 +23,24 @@ func GatMetrics() *gatMetrics {
}
func newGatmetrics() *gatMetrics {
hostname := os.Getenv("HOSTNAME")
if hostname == "" {
hostname = "default"
}
o := &gatMetrics{
ConnectionCounter: promauto.NewCounter(prometheus.CounterOpts{
Name: "pggat_connection_count_total",
Help: "total number of connections initiated with pggat",
ConstLabels: prometheus.Labels{
"pod": hostname,
},
}),
ActiveConnections: promauto.NewGauge(prometheus.GaugeOpts{
Name: "pggat_current_connection_count",
Help: "number of connections to pggat currently",
ConstLabels: prometheus.Labels{
"pod": hostname,
},
}),
}
return o
......
package metrics
import (
"os"
"time"
"github.com/prometheus/client_golang/prometheus"
......@@ -30,6 +31,10 @@ func PoolMetrics(db string, user string) poolMetrics {
}
func newPoolMetrics(db string, user string) poolMetrics {
hostname := os.Getenv("HOSTNAME")
if hostname == "" {
hostname = "default"
}
o := poolMetrics{
name: db + user,
TxLatency: promauto.NewHistogramVec(prometheus.HistogramOpts{
......@@ -39,6 +44,7 @@ func newPoolMetrics(db string, user string) poolMetrics {
ConstLabels: prometheus.Labels{
"db": db,
"user": user,
"pod": hostname,
},
}, []string{}),
QueryLatency: promauto.NewHistogramVec(prometheus.HistogramOpts{
......@@ -48,6 +54,7 @@ func newPoolMetrics(db string, user string) poolMetrics {
ConstLabels: prometheus.Labels{
"db": db,
"user": user,
"pod": hostname,
},
}, []string{}),
TxErrorCounts: promauto.NewCounterVec(prometheus.CounterOpts{
......@@ -56,6 +63,7 @@ func newPoolMetrics(db string, user string) poolMetrics {
ConstLabels: prometheus.Labels{
"db": db,
"user": user,
"pod": hostname,
},
}, []string{"error"}),
QueryErrorCounts: promauto.NewCounterVec(prometheus.CounterOpts{
......@@ -64,6 +72,7 @@ func newPoolMetrics(db string, user string) poolMetrics {
ConstLabels: prometheus.Labels{
"db": db,
"user": user,
"pod": hostname,
},
}, []string{"error"}),
WaitLatency: promauto.NewHistogramVec(prometheus.HistogramOpts{
......@@ -73,6 +82,7 @@ func newPoolMetrics(db string, user string) poolMetrics {
ConstLabels: prometheus.Labels{
"db": db,
"user": user,
"pod": hostname,
},
}, []string{}),
ReceivedBytes: promauto.NewCounterVec(prometheus.CounterOpts{
......@@ -81,6 +91,7 @@ func newPoolMetrics(db string, user string) poolMetrics {
ConstLabels: prometheus.Labels{
"db": db,
"user": user,
"pod": hostname,
},
}, []string{}),
SentBytes: promauto.NewCounterVec(prometheus.CounterOpts{
......@@ -89,6 +100,7 @@ func newPoolMetrics(db string, user string) poolMetrics {
ConstLabels: prometheus.Labels{
"db": db,
"user": user,
"pod": hostname,
},
}, []string{}),
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment