1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2024-10-31 17:11:13 +01:00
ntfy/server/server_metrics.go

106 lines
3.4 KiB
Go
Raw Normal View History

2023-03-07 04:16:10 +01:00
package server
import (
"github.com/prometheus/client_golang/prometheus"
)
var (
metrics = newMetrics()
)
type serverMetrics struct {
2023-03-14 15:19:15 +01:00
messagesPublishedSuccess prometheus.Counter
messagesPublishedFailure prometheus.Counter
messagesCached prometheus.Gauge
firebasePublishedSuccess prometheus.Counter
firebasePublishedFailure prometheus.Counter
emailsPublishedSuccess prometheus.Counter
emailsPublishedFailure prometheus.Counter
emailsReceivedSuccess prometheus.Counter
emailsReceivedFailure prometheus.Counter
unifiedPushPublishedSuccess prometheus.Counter
matrixPublishedSuccess prometheus.Counter
matrixPublishedFailure prometheus.Counter
attachmentsTotalSize prometheus.Gauge
visitors prometheus.Gauge
subscribers prometheus.Gauge
topics prometheus.Gauge
httpRequests *prometheus.CounterVec
2023-03-07 04:16:10 +01:00
}
func newMetrics() *serverMetrics {
m := &serverMetrics{
messagesPublishedSuccess: prometheus.NewCounter(prometheus.CounterOpts{
Name: "ntfy_messages_published_success",
}),
messagesPublishedFailure: prometheus.NewCounter(prometheus.CounterOpts{
Name: "ntfy_messages_published_failure",
}),
messagesCached: prometheus.NewGauge(prometheus.GaugeOpts{
Name: "ntfy_messages_cached_total",
}),
firebasePublishedSuccess: prometheus.NewCounter(prometheus.CounterOpts{
Name: "ntfy_firebase_published_success",
}),
firebasePublishedFailure: prometheus.NewCounter(prometheus.CounterOpts{
Name: "ntfy_firebase_published_failure",
}),
emailsPublishedSuccess: prometheus.NewCounter(prometheus.CounterOpts{
Name: "ntfy_emails_sent_success",
}),
emailsPublishedFailure: prometheus.NewCounter(prometheus.CounterOpts{
Name: "ntfy_emails_sent_failure",
}),
2023-03-14 15:19:15 +01:00
emailsReceivedSuccess: prometheus.NewCounter(prometheus.CounterOpts{
Name: "ntfy_emails_received_success",
}),
emailsReceivedFailure: prometheus.NewCounter(prometheus.CounterOpts{
Name: "ntfy_emails_received_failure",
}),
unifiedPushPublishedSuccess: prometheus.NewCounter(prometheus.CounterOpts{
Name: "ntfy_unifiedpush_published_success",
}),
matrixPublishedSuccess: prometheus.NewCounter(prometheus.CounterOpts{
Name: "ntfy_matrix_published_success",
}),
matrixPublishedFailure: prometheus.NewCounter(prometheus.CounterOpts{
Name: "ntfy_matrix_published_failure",
}),
attachmentsTotalSize: prometheus.NewGauge(prometheus.GaugeOpts{
Name: "ntfy_attachments_total_size",
}),
2023-03-07 04:16:10 +01:00
visitors: prometheus.NewGauge(prometheus.GaugeOpts{
Name: "ntfy_visitors_total",
}),
subscribers: prometheus.NewGauge(prometheus.GaugeOpts{
Name: "ntfy_subscribers_total",
}),
topics: prometheus.NewGauge(prometheus.GaugeOpts{
Name: "ntfy_topics_total",
}),
httpRequests: prometheus.NewCounterVec(prometheus.CounterOpts{
Name: "ntfy_http_requests_total",
}, []string{"http_code", "ntfy_code", "http_method"}),
}
prometheus.MustRegister(
m.messagesPublishedSuccess,
m.messagesPublishedFailure,
m.messagesCached,
m.firebasePublishedSuccess,
m.firebasePublishedFailure,
m.emailsPublishedSuccess,
m.emailsPublishedFailure,
2023-03-14 15:19:15 +01:00
m.emailsReceivedSuccess,
m.emailsReceivedFailure,
m.unifiedPushPublishedSuccess,
m.matrixPublishedSuccess,
m.matrixPublishedFailure,
m.attachmentsTotalSize,
2023-03-07 04:16:10 +01:00
m.visitors,
m.subscribers,
m.topics,
m.httpRequests,
)
return m
}