metrics.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package metrics
  2. var MetricStats Registry
  3. var UseNilMetrics bool
  4. func init() {
  5. // init with nil metrics
  6. initMetricVars(&MetricSettings{})
  7. }
  8. var (
  9. M_Instance_Start Counter
  10. M_Page_Status_200 Counter
  11. M_Page_Status_500 Counter
  12. M_Page_Status_404 Counter
  13. M_Api_Status_500 Counter
  14. M_Api_Status_404 Counter
  15. M_Api_User_SignUpStarted Counter
  16. M_Api_User_SignUpCompleted Counter
  17. M_Api_User_SignUpInvite Counter
  18. M_Api_Dashboard_Save Timer
  19. M_Api_Dashboard_Get Timer
  20. M_Api_Dashboard_Search Timer
  21. M_Api_Admin_User_Create Counter
  22. M_Api_Login_Post Counter
  23. M_Api_Login_OAuth Counter
  24. M_Api_Org_Create Counter
  25. M_Api_Dashboard_Snapshot_Create Counter
  26. M_Api_Dashboard_Snapshot_External Counter
  27. M_Api_Dashboard_Snapshot_Get Counter
  28. M_Models_Dashboard_Insert Counter
  29. M_Alerting_Result_Critical Counter
  30. M_Alerting_Result_Warning Counter
  31. M_Alerting_Result_Info Counter
  32. M_Alerting_Result_Ok Counter
  33. M_Alerting_Active_Alerts Counter
  34. M_Alerting_Notification_Sent_Slack Counter
  35. M_Alerting_Notification_Sent_Email Counter
  36. M_Alerting_Notification_Sent_Webhook Counter
  37. // Timers
  38. M_DataSource_ProxyReq_Timer Timer
  39. M_Alerting_Exeuction_Time Timer
  40. )
  41. func initMetricVars(settings *MetricSettings) {
  42. UseNilMetrics = settings.Enabled == false
  43. MetricStats = NewRegistry()
  44. M_Instance_Start = RegCounter("instance_start")
  45. M_Page_Status_200 = RegCounter("page.resp_status", "code", "200")
  46. M_Page_Status_500 = RegCounter("page.resp_status", "code", "500")
  47. M_Page_Status_404 = RegCounter("page.resp_status", "code", "404")
  48. M_Api_Status_500 = RegCounter("api.resp_status", "code", "500")
  49. M_Api_Status_404 = RegCounter("api.resp_status", "code", "404")
  50. M_Api_User_SignUpStarted = RegCounter("api.user.signup_started")
  51. M_Api_User_SignUpCompleted = RegCounter("api.user.signup_completed")
  52. M_Api_User_SignUpInvite = RegCounter("api.user.signup_invite")
  53. M_Api_Dashboard_Save = RegTimer("api.dashboard.save")
  54. M_Api_Dashboard_Get = RegTimer("api.dashboard.get")
  55. M_Api_Dashboard_Search = RegTimer("api.dashboard.search")
  56. M_Api_Admin_User_Create = RegCounter("api.admin.user_create")
  57. M_Api_Login_Post = RegCounter("api.login.post")
  58. M_Api_Login_OAuth = RegCounter("api.login.oauth")
  59. M_Api_Org_Create = RegCounter("api.org.create")
  60. M_Api_Dashboard_Snapshot_Create = RegCounter("api.dashboard_snapshot.create")
  61. M_Api_Dashboard_Snapshot_External = RegCounter("api.dashboard_snapshot.external")
  62. M_Api_Dashboard_Snapshot_Get = RegCounter("api.dashboard_snapshot.get")
  63. M_Models_Dashboard_Insert = RegCounter("models.dashboard.insert")
  64. M_Alerting_Result_Critical = RegCounter("alerting.result", "severity", "critical")
  65. M_Alerting_Result_Warning = RegCounter("alerting.result", "severity", "warning")
  66. M_Alerting_Result_Info = RegCounter("alerting.result", "severity", "info")
  67. M_Alerting_Result_Ok = RegCounter("alerting.result", "severity", "ok")
  68. M_Alerting_Active_Alerts = RegCounter("alerting.active_alerts")
  69. M_Alerting_Notification_Sent_Slack = RegCounter("alerting.notifications_sent", "type", "slack")
  70. M_Alerting_Notification_Sent_Email = RegCounter("alerting.notifications_sent", "type", "email")
  71. M_Alerting_Notification_Sent_Webhook = RegCounter("alerting.notifications_sent", "type", "webhook")
  72. // Timers
  73. M_DataSource_ProxyReq_Timer = RegTimer("api.dataproxy.request.all")
  74. M_Alerting_Exeuction_Time = RegTimer("alerting.execution_time")
  75. }