Ask about logs
Answer a natural-language question about one project's stored logs. Returns a plain-language answer, what was measured over which window (explanation, window), the part of the window the numbers cover (meta), and a queryId. An overview (what is broken, recent errors, what changed, what is new, with no specific topic, field or request for lines) is searched: its results are the window's kinds of log lines, with their counts in the window and the window before and example lines; every other question is measured exactly. A question may be asked in any language, and is answered in it. The period it names is read from it, on the clock of timeZone ("the last 6 hours", "this afternoon", "since midnight", "between 18:00 and 19:00", "this hour against the previous hour", which reads both hours and compares them); a window replaces that period, and the answer says so. A period that cannot be read is said to be, and the last hour is read instead. With results: true it also returns the rows, value, table, series or kinds of log lines the answer was written from. Pass the queryId to logs.executeQuery to run the same query again over any window with no model involved. When nothing matches, status is not_found: the answer names the window that was read, interpretedAs how the question was read, and the queryId runs the same query over a wider window. A question that asks nothing about the project's logs, or about another project's, is refused with nothing searched (status error, rejection.code not_about_logs or other_project, no queryId), and one no query answered is not_found with no queryId; one that asks to change or delete logs is answered with the lines it names (writeDeclined), since logs are read-only.
POST https://api.sazabi.com/v1/logs/ask
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
curl -X POST "https://example.com/logs/ask" \ -H "Content-Type: application/json" \ -d '{ "question": "string" }'{ "queryId": "10210520-b895-40ca-bce5-474f9643bf53", "parentId": "70850378-7d3c-4f45-91b7-942d4dfbbd43", "status": "ok", "answer": "string", "explanation": "string", "interpretedAs": "string", "results": { "kind": "search", "kinds": [ { "message": "string", "severity": "string", "services": [ { "service": "string", "count": 0 } ], "count": 0, "previousCount": 0, "firstSeen": "string", "firstSeenInWindow": true, "lastSeen": "string", "examples": [ { "id": "string", "time": "string", "service": "string", "severity": "string", "body": "string", "attributes": { "property1": "string", "property2": "string" }, "traceId": "string", "spanId": "string" } ] } ], "matched": 0, "truncated": true, "previousWindow": { "from": "2019-08-24T14:15:22Z", "to": "2019-08-24T14:15:22Z" } }, "window": { "from": "2019-08-24T14:15:22Z", "to": "2019-08-24T14:15:22Z" }, "periods": [ { "name": "string", "window": { "from": "2019-08-24T14:15:22Z", "to": "2019-08-24T14:15:22Z" }, "results": { "kind": "search", "kinds": [ { "message": "string", "severity": "string", "services": [ { "service": "string", "count": 0 } ], "count": 0, "previousCount": 0, "firstSeen": "string", "firstSeenInWindow": true, "lastSeen": "string", "examples": [ { "id": "string", "time": "string", "service": "string", "severity": "string", "body": "string", "attributes": { "property1": "string", "property2": "string" }, "traceId": "string", "spanId": "string" } ] } ], "matched": 0, "truncated": true, "previousWindow": { "from": "2019-08-24T14:15:22Z", "to": "2019-08-24T14:15:22Z" } } } ], "meta": { "coverage": { "from": "2019-08-24T14:15:22Z", "to": "2019-08-24T14:15:22Z", "status": "complete", "reason": "stored_range" } }, "rejection": { "code": "bucket_too_fine", "message": "string" }, "writeDeclined": true, "attempts": [ { "n": 0, "action": "string" } ], "timings": { "planMs": 0, "executeMs": 0, "answerMs": 0, "totalMs": 0 }, "nextCursor": "string"}