Last active
August 29, 2015 14:13
-
-
Save dcramer/55a44904be883f8d03e1 to your computer and use it in GitHub Desktop.
Revisions
-
dcramer revised this gist
Jan 22, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ from sentry.utils.runner import configure configure() from datetime import datetime, timedelta from sentry.app import tsdb @@ -18,7 +18,7 @@ def delete(key): def cleanup(): epoch = tsdb.normalize_to_rollup(datetime.utcnow() - timedelta(days=7), 3600) print('Epoch set to {}'.format(epoch)) for connection in tsdb.conn.hosts.itervalues(): print('> Checking connection {}'.format(connection)) -
dcramer revised this gist
Jan 22, 2015 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,8 @@ def delete(key): connection.delete(key) for key in connection.scan_iter('ts:*'): bits = key.split(':', 4) assert len(bits) == 4 if int(bits[2]) < epoch: # 7 days delete(key) -
dcramer revised this gist
Jan 22, 2015 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,6 +2,7 @@ from sentry.utils.runner import configure configure() from datetime import datetime from sentry.app import tsdb @@ -16,7 +17,7 @@ def delete(key): def cleanup(): epoch = tsdb.normalize_to_rollup(datetime.utcnow(), 3600) print('Epoch set to {}'.format(epoch)) for connection in tsdb.conn.hosts.itervalues(): print('> Checking connection {}'.format(connection)) -
dcramer revised this gist
Jan 22, 2015 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,8 +11,7 @@ def delete(key): connection.delete(key) for key in connection.scan_iter('ts:*'): bits = key.split(':', 4) if int(bits[3]) < epoch: # 7 days delete(key) -
dcramer revised this gist
Jan 22, 2015 . 1 changed file with 7 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,21 +5,23 @@ from sentry.app import tsdb def cleanup_connection(connection, epoch): 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 < epoch: # 7 days delete(key) def cleanup(): epoch = (time.time() - 60 * 60 * 24 * 7) / 3600 print('Epoch set to {}'.format(epoch)) for connection in tsdb.conn.hosts.itervalues(): print('> Checking connection {}'.format(connection)) cleanup_connection(connection, epoch) if __name__ == '__main__': -
dcramer created this gist
Jan 22, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ #!/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()