You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.9 KiB

  1. // Copyright (c) 2015-2024 MinIO, Inc.
  2. //
  3. // This file is part of MinIO Object Storage stack
  4. //
  5. // This program is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU Affero General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU Affero General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Affero General Public License
  16. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. package cmd
  18. import (
  19. "context"
  20. "github.com/minio/minio/internal/logger"
  21. )
  22. const (
  23. auditFailedMessages = "failed_messages"
  24. auditTargetQueueLength = "target_queue_length"
  25. auditTotalMessages = "total_messages"
  26. targetID = "target_id"
  27. )
  28. var (
  29. auditFailedMessagesMD = NewCounterMD(auditFailedMessages,
  30. "Total number of messages that failed to send since start",
  31. targetID)
  32. auditTargetQueueLengthMD = NewGaugeMD(auditTargetQueueLength,
  33. "Number of unsent messages in queue for target",
  34. targetID)
  35. auditTotalMessagesMD = NewCounterMD(auditTotalMessages,
  36. "Total number of messages sent since start",
  37. targetID)
  38. )
  39. // loadAuditMetrics - `MetricsLoaderFn` for audit
  40. // such as failed messages and total messages.
  41. func loadAuditMetrics(_ context.Context, m MetricValues, c *metricsCache) error {
  42. audit := logger.CurrentStats()
  43. for id, st := range audit {
  44. labels := []string{targetID, id}
  45. m.Set(auditFailedMessages, float64(st.FailedMessages), labels...)
  46. m.Set(auditTargetQueueLength, float64(st.QueueLength), labels...)
  47. m.Set(auditTotalMessages, float64(st.TotalMessages), labels...)
  48. }
  49. return nil
  50. }