bigbluebutton-Github/bbb-graphql-middleware/internal/common/PrometheusMetrics.go
Gustavo Trott e1407149b9
refactor (build/gql-middleware): Introduce config as a yml file (#20992)
* Introduce Gql-Middleware config as a yml file

* use path /usr/share/bbb-graphql-middleware/ instead of /usr/local/bigbluebutton/bbb-graphql-middleware

* remove /etc/default/bbb-graphql-middleware file
2024-08-29 17:40:52 -04:00

96 lines
2.6 KiB
Go

package common
import (
"bbb-graphql-middleware/config"
"github.com/prometheus/client_golang/prometheus"
)
var PrometheusAdvancedMetricsEnabled = config.GetConfig().PrometheusAdvancedMetricsEnabled
var (
HttpConnectionGauge = prometheus.NewGauge(prometheus.GaugeOpts{
Name: "http_connection_active",
Help: "Number of active HTTP connections",
})
HttpConnectionCounter = prometheus.NewCounter(prometheus.CounterOpts{
Name: "http_connection_total",
Help: "Total number of HTTP connections",
})
WsConnectionAcceptedCounter = prometheus.NewCounter(prometheus.CounterOpts{
Name: "ws_connection_accepted",
Help: "Total number of Websocket connections accepted",
})
WsConnectionRejectedCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "ws_connection_rejected",
Help: "Total number of Websocket connections rejected",
},
[]string{"reason"},
)
GqlSubscribeCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "gql_subscription_total",
Help: "Total number of Graphql subscriptions",
},
[]string{"type", "operationName"},
)
GqlMutationsCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "gql_mutation_total",
Help: "Total number of Graphql mutations",
},
[]string{"operationName"},
)
GqlReceivedDataCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "gql_received_data_total",
Help: "Frequency of updates of a given data",
},
[]string{"type", "operationName"},
)
GqlReceivedDataPayloadLength = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: "gql_received_data_payload_length",
Help: "Length (number of positions) of received data payload",
Buckets: []float64{
1,
10,
50,
100,
300,
600,
},
},
[]string{"type", "operationName"},
)
GqlReceivedDataPayloadSize = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: "gql_received_data_payload_size",
Help: "Size (in bytes) of received data payload",
Buckets: []float64{
200,
600,
1200,
5000,
10000,
30000,
},
},
[]string{"type", "operationName"},
)
)
func init() {
prometheus.MustRegister(HttpConnectionGauge)
prometheus.MustRegister(HttpConnectionCounter)
prometheus.MustRegister(WsConnectionAcceptedCounter)
prometheus.MustRegister(WsConnectionRejectedCounter)
prometheus.MustRegister(GqlSubscribeCounter)
prometheus.MustRegister(GqlReceivedDataCounter)
prometheus.MustRegister(GqlMutationsCounter)
prometheus.MustRegister(GqlReceivedDataPayloadSize)
if PrometheusAdvancedMetricsEnabled {
prometheus.MustRegister(GqlReceivedDataPayloadLength)
}
}