{"action":"created","issue":{"url":"https://api.github.com/repos/cloudfoundry/cloud_controller_ng/issues/327","labels_url":"https://api.github.com/repos/cloudfoundry/cloud_controller_ng/issues/327/labels{/name}","comments_url":"https://api.github.com/repos/cloudfoundry/cloud_controller_ng/issues/327/comments","events_url":"https://api.github.com/repos/cloudfoundry/cloud_controller_ng/issues/327/events","html_url":"https://github.com/cloudfoundry/cloud_controller_ng/issues/327","id":55284449,"number":327,"title":"/v2/*/destructively_purge_all_and_reseed_started_apps - support an event ID to finish on","user":{"login":"drnic","id":108,"avatar_url":"https://avatars.githubusercontent.com/u/108?v=3","gravatar_id":"","url":"https://api.github.com/users/drnic","html_url":"https://github.com/drnic","followers_url":"https://api.github.com/users/drnic/followers","following_url":"https://api.github.com/users/drnic/following{/other_user}","gists_url":"https://api.github.com/users/drnic/gists{/gist_id}","starred_url":"https://api.github.com/users/drnic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drnic/subscriptions","organizations_url":"https://api.github.com/users/drnic/orgs","repos_url":"https://api.github.com/users/drnic/repos","events_url":"https://api.github.com/users/drnic/events{/privacy}","received_events_url":"https://api.github.com/users/drnic/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-23T14:05:35Z","updated_at":"2015-01-24T00:53:39Z","closed_at":null,"body":"I think there is a chance that after you've downloaded `/v2/app_usage_events` and `/v2/service_usage_events`, but before you run `.../destructively_purge_all_and_reseed_started_apps` there will be new events. I think this could be mitigated by passing in an argument like \"?last_event_id=\"\r\n\r\nAll events up-to-and-including this `last_event_id` would be deleted but not anything newer."},"comment":{"url":"https://api.github.com/repos/cloudfoundry/cloud_controller_ng/issues/comments/71291688","html_url":"https://github.com/cloudfoundry/cloud_controller_ng/issues/327#issuecomment-71291688","issue_url":"https://api.github.com/repos/cloudfoundry/cloud_controller_ng/issues/327","id":71291688,"user":{"login":"crhino","id":4146455,"avatar_url":"https://avatars.githubusercontent.com/u/4146455?v=3","gravatar_id":"","url":"https://api.github.com/users/crhino","html_url":"https://github.com/crhino","followers_url":"https://api.github.com/users/crhino/followers","following_url":"https://api.github.com/users/crhino/following{/other_user}","gists_url":"https://api.github.com/users/crhino/gists{/gist_id}","starred_url":"https://api.github.com/users/crhino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/crhino/subscriptions","organizations_url":"https://api.github.com/users/crhino/orgs","repos_url":"https://api.github.com/users/crhino/repos","events_url":"https://api.github.com/users/crhino/events{/privacy}","received_events_url":"https://api.github.com/users/crhino/received_events","type":"User","site_admin":false},"created_at":"2015-01-24T00:53:39Z","updated_at":"2015-01-24T00:53:39Z","body":"@drnic We have discussed this with people who had some context on this endpoint, and the verdict is that this endpoint should only be called once, if at all. The use for this endpoint was basically to initiate a new \"epoch\" to start billing, it is not intended to be a weekly/monthly API call.\r\n\r\nWe would recommend that you use the `/v2/app_usage_events` and filter with the `after_guid` parameter in order to get events after a certain time. As noted on the [api docs](http://apidocs.cloudfoundry.org/196/app_usage_events/list_all_app_usage_events.html), events close to the current time should not be processed since other events might still be in transaction. The idea would be to periodically grab the events starting after a specific event guid until sometime before the current time, saving the last event guid that you process. You would then be able to periodically grab a time slice of events and use that for billing.\r\n\r\nTo periodically clean the events table, the cloud_controller_clock has a periodic job that will clean up events older than a specified date. This can be configured with the `app_usage_events.cutoff_age_in_days` [property](https://github.com/cloudfoundry/cf-release/blob/345a8b3e1ea0005a3e9fced13f0bf6fa6f7ad981/jobs/cloud_controller_clock/spec#L94).\r\n\r\n"}}