CorefinityCorefinityDocs
Open the Control PanelControl Panel
Recipes · 5 of 8

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 read scope, 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.
  1. Start the export

    Send the format (csv, or json for one JSON object a line), the source to read and how far back to read. GET /corestack/sites/{site}/logs/streams lists the sources; a query narrows the lines.

    Terminal
    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 202 with the export to follow, in download, and its capability. Note download.id, and keep the capability: it is shown only this once, and step 3 needs it.

  2. Read the export

    Read the export every few seconds until its state is ready. Only the person who started an export can read it.

    failed and expired are final too: start a new export.

    Terminal
    curl https://manage.corefinity.com/api/corestack/logs/exports/01JB2Y8N7Q4X3R5T6V8W9Z0A1B \
      -H "Authorization: Bearer $COREFINITY_TOKEN" -H "Accept: application/json"

    lines and bytes say how large the file is, and truncated is true when it was cut at the limit.

  3. Collect the file

    Send the capability within 24 hours. The answer is 200 with 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.

    Terminal
    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

StatusreasonWhat to do
404feature_offLogs are not on for your company
422invalidCorrect the field named in field and errors. On capability: it is missing or is not this export's; nothing is used up
409logs_not_collectedLogs are not collected for this environment yet
409logs_rangefrom is before the time your logs are kept for. Choose a later start
409query_too_wideAdd a source or narrow the time range
409download_preparingThe export is still being prepared. Do step 2 until state is ready
410expiredThe export was collected already, has expired or failed. Start a new one
503logs_busy, logs_cluster_unavailableThe logs store is busy or did not answer. The request itself is fine: try again shortly
429rate_limitedStarting and collecting share a budget of 5 requests in 10 minutes. Wait for the seconds in Retry-After; see Rate limits
Was this helpful?
Open in ClaudeOpen in ChatGPT