metrics.go 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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_Status_200 Counter
  16. M_Api_User_SignUpStarted Counter
  17. M_Api_User_SignUpCompleted Counter
  18. M_Api_User_SignUpInvite Counter
  19. M_Api_Dashboard_Save Timer
  20. M_Api_Dashboard_Get Timer
  21. M_Api_Dashboard_Search Timer
  22. M_Api_Admin_User_Create Counter
  23. M_Api_Login_Post Counter
  24. M_Api_Login_OAuth Counter
  25. M_Api_Org_Create Counter
  26. M_Api_Dashboard_Snapshot_Create Counter
  27. M_Api_Dashboard_Snapshot_External Counter
  28. M_Api_Dashboard_Snapshot_Get Counter
  29. M_Models_Dashboard_Insert Counter
  30. M_Alerting_Result_State_Critical Counter
  31. M_Alerting_Result_State_Warning Counter
  32. M_Alerting_Result_State_Ok Counter
  33. M_Alerting_Result_State_Paused Counter
  34. M_Alerting_Result_State_Unknown Counter
  35. M_Alerting_Result_State_ExecutionError Counter
  36. M_Alerting_Active_Alerts Counter
  37. M_Alerting_Notification_Sent_Slack Counter
  38. M_Alerting_Notification_Sent_Email Counter
  39. M_Alerting_Notification_Sent_Webhook Counter
  40. // Timers
  41. M_DataSource_ProxyReq_Timer Timer
  42. M_Alerting_Exeuction_Time Timer
  43. )
  44. func initMetricVars(settings *MetricSettings) {
  45. UseNilMetrics = settings.Enabled == false
  46. MetricStats = NewRegistry()
  47. M_Instance_Start = RegCounter("instance_start")
  48. M_Page_Status_200 = RegCounter("page.resp_status", "code", "200")
  49. M_Page_Status_500 = RegCounter("page.resp_status", "code", "500")
  50. M_Page_Status_404 = RegCounter("page.resp_status", "code", "404")
  51. M_Api_Status_500 = RegCounter("api.resp_status", "code", "500")
  52. M_Api_Status_404 = RegCounter("api.resp_status", "code", "404")
  53. M_Api_Status_200 = RegCounter("api.resp_status", "code", "200")
  54. M_Api_User_SignUpStarted = RegCounter("api.user.signup_started")
  55. M_Api_User_SignUpCompleted = RegCounter("api.user.signup_completed")
  56. M_Api_User_SignUpInvite = RegCounter("api.user.signup_invite")
  57. M_Api_Dashboard_Save = RegTimer("api.dashboard.save")
  58. M_Api_Dashboard_Get = RegTimer("api.dashboard.get")
  59. M_Api_Dashboard_Search = RegTimer("api.dashboard.search")
  60. M_Api_Admin_User_Create = RegCounter("api.admin.user_create")
  61. M_Api_Login_Post = RegCounter("api.login.post")
  62. M_Api_Login_OAuth = RegCounter("api.login.oauth")
  63. M_Api_Org_Create = RegCounter("api.org.create")
  64. M_Api_Dashboard_Snapshot_Create = RegCounter("api.dashboard_snapshot.create")
  65. M_Api_Dashboard_Snapshot_External = RegCounter("api.dashboard_snapshot.external")
  66. M_Api_Dashboard_Snapshot_Get = RegCounter("api.dashboard_snapshot.get")
  67. M_Models_Dashboard_Insert = RegCounter("models.dashboard.insert")
  68. M_Alerting_Result_State_Critical = RegCounter("alerting.result", "state", "critical")
  69. M_Alerting_Result_State_Warning = RegCounter("alerting.result", "state", "warning")
  70. M_Alerting_Result_State_Ok = RegCounter("alerting.result", "state", "ok")
  71. M_Alerting_Result_State_Paused = RegCounter("alerting.result", "state", "paused")
  72. M_Alerting_Result_State_Unknown = RegCounter("alerting.result", "state", "unknown")
  73. M_Alerting_Result_State_ExecutionError = RegCounter("alerting.result", "state", "execution_error")
  74. M_Alerting_Active_Alerts = RegCounter("alerting.active_alerts")
  75. M_Alerting_Notification_Sent_Slack = RegCounter("alerting.notifications_sent", "type", "slack")
  76. M_Alerting_Notification_Sent_Email = RegCounter("alerting.notifications_sent", "type", "email")
  77. M_Alerting_Notification_Sent_Webhook = RegCounter("alerting.notifications_sent", "type", "webhook")
  78. // Timers
  79. M_DataSource_ProxyReq_Timer = RegTimer("api.dataproxy.request.all")
  80. M_Alerting_Exeuction_Time = RegTimer("alerting.execution_time")
  81. }