Skip to content

Instantly share code, notes, and snippets.

@dcramer
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save dcramer/55a44904be883f8d03e1 to your computer and use it in GitHub Desktop.

Select an option

Save dcramer/55a44904be883f8d03e1 to your computer and use it in GitHub Desktop.
clean up data that should have been expired but wasnt
#!/usr/bin/env python
from sentry.utils.runner import configure
configure()
from sentry.app import tsdb
def cleanup_connection(connection):
def delete(key):
print('Removing key {}'.format(key))
connection.delete(key)
for key in connection.scan_iter('ts:*'):
bits = key.split(':', 4)
epoch = int(bits[3])
if epoch < 394798: # 7 days
delete(key)
def cleanup():
for connection in tsdb.conn.hosts.itervalues():
print('Checking connection {}'.format(connection))
cleanup_connection(connection)
if __name__ == '__main__':
cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment