mirror of
https://github.com/minio/minio.git
synced 2025-02-04 18:36:00 -05:00
Add metrics for webhook endpoint stats (#17179)
This commit is contained in:
parent
c23c982593
commit
c326e5a34e
@ -69,6 +69,7 @@ func init() {
|
|||||||
getIAMNodeMetrics(),
|
getIAMNodeMetrics(),
|
||||||
getKMSNodeMetrics(),
|
getKMSNodeMetrics(),
|
||||||
getMinioHealingMetrics(),
|
getMinioHealingMetrics(),
|
||||||
|
getWebhookMetrics(),
|
||||||
}
|
}
|
||||||
|
|
||||||
allMetricsGroups := func() (allMetrics []*MetricsGroup) {
|
allMetricsGroups := func() (allMetrics []*MetricsGroup) {
|
||||||
@ -137,6 +138,7 @@ const (
|
|||||||
notifySubsystem MetricSubsystem = "notify"
|
notifySubsystem MetricSubsystem = "notify"
|
||||||
lambdaSubsystem MetricSubsystem = "lambda"
|
lambdaSubsystem MetricSubsystem = "lambda"
|
||||||
auditSubsystem MetricSubsystem = "audit"
|
auditSubsystem MetricSubsystem = "audit"
|
||||||
|
webhookSubsystem MetricSubsystem = "webhook"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MetricName are the individual names for the metric.
|
// MetricName are the individual names for the metric.
|
||||||
@ -211,6 +213,11 @@ const (
|
|||||||
kmsRequestsError = "request_error"
|
kmsRequestsError = "request_error"
|
||||||
kmsRequestsFail = "request_failure"
|
kmsRequestsFail = "request_failure"
|
||||||
kmsUptime = "uptime"
|
kmsUptime = "uptime"
|
||||||
|
|
||||||
|
webhookOnline = "online"
|
||||||
|
webhookQueueLength = "queue_length"
|
||||||
|
webhookTotalMessages = "total_messages"
|
||||||
|
webhookFailedMessages = "failed_messages"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -2367,6 +2374,73 @@ func getKMSNodeMetrics() *MetricsGroup {
|
|||||||
return mg
|
return mg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getWebhookMetrics() *MetricsGroup {
|
||||||
|
mg := &MetricsGroup{
|
||||||
|
cacheInterval: 10 * time.Second,
|
||||||
|
}
|
||||||
|
mg.RegisterRead(func(ctx context.Context) []Metric {
|
||||||
|
tgts := append(logger.SystemTargets(), logger.AuditTargets()...)
|
||||||
|
metrics := make([]Metric, 0, len(tgts))
|
||||||
|
for _, t := range tgts {
|
||||||
|
isOnline := 0
|
||||||
|
if t.IsOnline(ctx) {
|
||||||
|
isOnline = 1
|
||||||
|
}
|
||||||
|
labels := map[string]string{
|
||||||
|
"name": t.String(),
|
||||||
|
"endpoint": t.Endpoint(),
|
||||||
|
}
|
||||||
|
metrics = append(metrics, Metric{
|
||||||
|
Description: MetricDescription{
|
||||||
|
Namespace: clusterMetricNamespace,
|
||||||
|
Subsystem: webhookSubsystem,
|
||||||
|
Name: webhookOnline,
|
||||||
|
Help: "Is the webhook online?",
|
||||||
|
Type: gaugeMetric,
|
||||||
|
},
|
||||||
|
VariableLabels: labels,
|
||||||
|
Value: float64(isOnline),
|
||||||
|
})
|
||||||
|
metrics = append(metrics, Metric{
|
||||||
|
Description: MetricDescription{
|
||||||
|
Namespace: clusterMetricNamespace,
|
||||||
|
Subsystem: webhookSubsystem,
|
||||||
|
Name: webhookQueueLength,
|
||||||
|
Help: "Webhook queue length",
|
||||||
|
Type: counterMetric,
|
||||||
|
},
|
||||||
|
VariableLabels: labels,
|
||||||
|
Value: float64(t.Stats().QueueLength),
|
||||||
|
})
|
||||||
|
metrics = append(metrics, Metric{
|
||||||
|
Description: MetricDescription{
|
||||||
|
Namespace: clusterMetricNamespace,
|
||||||
|
Subsystem: webhookSubsystem,
|
||||||
|
Name: webhookTotalMessages,
|
||||||
|
Help: "Total number of messages sent to this target",
|
||||||
|
Type: counterMetric,
|
||||||
|
},
|
||||||
|
VariableLabels: labels,
|
||||||
|
Value: float64(t.Stats().TotalMessages),
|
||||||
|
})
|
||||||
|
metrics = append(metrics, Metric{
|
||||||
|
Description: MetricDescription{
|
||||||
|
Namespace: clusterMetricNamespace,
|
||||||
|
Subsystem: webhookSubsystem,
|
||||||
|
Name: webhookFailedMessages,
|
||||||
|
Help: "Number of messages that failed to send",
|
||||||
|
Type: counterMetric,
|
||||||
|
},
|
||||||
|
VariableLabels: labels,
|
||||||
|
Value: float64(t.Stats().FailedMessages),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return metrics
|
||||||
|
})
|
||||||
|
return mg
|
||||||
|
}
|
||||||
|
|
||||||
func getKMSMetrics() *MetricsGroup {
|
func getKMSMetrics() *MetricsGroup {
|
||||||
mg := &MetricsGroup{
|
mg := &MetricsGroup{
|
||||||
cacheInterval: 10 * time.Second,
|
cacheInterval: 10 * time.Second,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user