Export logs
Start an export of a site's log lines, read it until the file is ready and collect the file.
On this page
An export makes a file of the log lines that match, up to 50,000 lines or 64 MiB. This recipe exports the last day of web requests to the site harbourandfinch.example.com as CSV.
Before you start
- A token with the
readscope, and a person who can see the site's logs. - Every step needs two-factor enrolment when your company requires it.
- No step waits for a maintenance window.
Start the export
Send the
format(csv, orjsonfor one JSON object a line), thesourceto read and how far back to read.GET /lists the sources; acorestack/ sites/ {site}/ logs/ streams querynarrows the lines.curl -X POST https://manage.corefinity.com/api/corestack/sites/1042/logs/exports \ -H "Authorization: Bearer $COREFINITY_TOKEN" -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d '{"format": "csv", "source": "web-access", "range": "24h"}'The answer is
202with the export to follow, indownload, and itscapability. Notedownload.id, and keep thecapability: it is shown only this once, and step 3 needs it.Read the export
Read the export every few seconds until its
stateisready. Only the person who started an export can read it.failedandexpiredare final too: start a new export.curl https://manage.corefinity.com/api/corestack/logs/exports/01JB2Y8N7Q4X3R5T6V8W9Z0A1B \ -H "Authorization: Bearer $COREFINITY_TOKEN" -H "Accept: application/json"linesandbytessay how large the file is, andtruncatedistruewhen it was cut at the limit.Collect the file
Send the
capabilitywithin 24 hours. The answer is200with the file itself, not a JSON document.The file can be collected once. Collecting it removes the export: a second request answers
410, and so does a request after the 24 hours.curl -X POST https://manage.corefinity.com/api/corestack/logs/exports/01JB2Y8N7Q4X3R5T6V8W9Z0A1B/collect \ -H "Authorization: Bearer $COREFINITY_TOKEN" -H "Accept: application/json" \ -H "Content-Type: application/json" \ -d '{"capability": "Example-export-capability-0000000000000000000001"}' \ -o harbourandfinch-web-access.csv
If it is refused
| Status | reason | What to do |
|---|---|---|
404 | feature_off | Logs are not on for your company |
422 | invalid | Correct the field named in field and errors. On capability: it is missing or is not this export's; nothing is used up |
409 | logs_not_collected | Logs are not collected for this environment yet |
409 | logs_range | from is before the time your logs are kept for. Choose a later start |
409 | query_too_wide | Add a source or narrow the time range |
409 | download_preparing | The export is still being prepared. Do step 2 until state is ready |
410 | expired | The export was collected already, has expired or failed. Start a new one |
503 | logs_busy, logs_cluster_unavailable | The logs store is busy or did not answer. The request itself is fine: try again shortly |
429 | rate_limited | Starting and collecting share a budget of 5 requests in 10 minutes. Wait for the seconds in Retry-After; see Rate limits |