internal-metrics.rst 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. Internal Metrics
  2. =================
  3. Sentry provides an abstraction called 'metrics' which is used for
  4. internal monitoring, generally timings and various counters.
  5. The default backend simply discards them (though some values are still kept
  6. in the internal time series database).
  7. Statsd Backend
  8. --------------
  9. .. code-block:: python
  10. SENTRY_METRICS_BACKEND = 'sentry.metrics.statsd.StatsdMetricsBackend'
  11. SENTRY_METRICS_OPTIONS = {
  12. 'host': 'localhost',
  13. 'port': 8125,
  14. }
  15. Datadog Backend
  16. ---------------
  17. Datadog will require you to install the ``datadog`` package into your Sentry
  18. environment:
  19. .. code-block:: bash
  20. $ pip install datadog
  21. .. code-block:: python
  22. SENTRY_METRICS_BACKEND = 'sentry.metrics.datadog.DatadogMetricsBackend'
  23. SENTRY_METRICS_OPTIONS = {
  24. 'api_key': '...',
  25. 'app_key': '...',
  26. 'tags': {},
  27. }
  28. Logging Backend
  29. ---------------
  30. The ``LoggingBackend`` reports all operations to the ``sentry.metrics``
  31. logger. In addition to the metric name and value, log messages also include
  32. extra data such as the ``instance`` and ``tags`` values which can be displayed
  33. using a custom formatter.
  34. .. code-block:: python
  35. SENTRY_METRICS_BACKEND = 'sentry.metrics.logging.LoggingBackend'
  36. LOGGING['loggers']['sentry.metrics'] = {
  37. 'level': 'DEBUG',
  38. 'handlers': ['console:metrics'],
  39. 'propagate': False,
  40. }
  41. LOGGING['formatters']['metrics'] = {
  42. 'format': '[%(levelname)s] %(message)s; instance=%(instance)r; tags=%(tags)r',
  43. }
  44. LOGGING['handlers']['console:metrics'] = {
  45. 'level': 'DEBUG',
  46. 'class': 'logging.StreamHandler',
  47. 'formatter': 'metrics',
  48. }