Calculating montly event ingestion

I would love to get a ballpark figure on the amount of events my orgs are doing to see how much it would cost me to migrate over to hosted Sentry.

I don’t mind if I need to run some queries for it but the current weekly graphs are not detailed or historic enough for this purpose really.

Any clues on how to achieve this?

Open up $ sentry shell and enter:

>>> from sentry.app import tsdb
>>> from django.utils import timezone
>>> from datetime import timedelta
>>> end = timezone.now()
>>> tsdb.get_sums(model=tsdb.models.internal, keys=['events.total'],start=end-timedelta(days=30), end=end)['events.total']

That should give you total events for past 30 days.

1 Like

Perfect! Works like a charm :slight_smile:

>>> from sentry.app import tsdb
>>> from django.utils import timezone
>>> from datetime import timedelta
>>> end = timezone.now()
>>> tsdb.get_sums(model=tsdb.models.internal, keys=['events.total'],start=end-timedelta(days=30), end=end)['events.total']
15177455
>>> from sentry.nodestore.django.models import Node
>>> Node.objects.count()
13078513
>>> 

I just tried that and the number for a single month using the tsdb method is bigger than what I though was the total number of events (Node.objects.count()). Isn’t it weird ?

That could happen for a few reasons off the top of my head:

  • sampling
  • deletions
  • cleanup script

None of those would go back and adjust tsdb metrics.

I am quite new to Python and Sentry, and I have some extra questions:

  • The following works, but I’m sure this can be done more elegantly, can you tell me how?
    tsdb.get_sums(model=tsdb.models.internal, keys=[‘events.total’],start=end-timedelta(days=9999), end=end)[‘events.total’]

  • I would like to be able to not only have the total number of events, but also per Team and/or Project?