Get Query Status

Gets the status of a specific foreground or background query executed by the user in the current session.

HTTP Request

GET /api/sonar/queries/:id

Success Response

{
    "id": 60,
    "source": "adhoc",
    "login_name": "xeraph",
    "remote_ip": "0:0:0:0:0:0:0:1",
    "rows": 32,
    "elapsed": 21,
    "is_finished": true,
    "is_cancelled": false,
    "is_scheduled_query": false,
    "constants": {},
    "query_string": "system tables",
    "start_time": 1663044689188,
    "finish_time": 1663044689209,
    "last_started": "2022-09-13 13:51:29+0900",
    "background": false,
    "commands": [
        {
            "command": "system tables",
            "status": "End"
            "push_count": 32,
        }
    ],
    "sub_queries": [],
    "stamp": 5,
    "tags": {}
}
  • id (32-bit integer): Query ID
  • source (String): Query execution type
    • User input (adhoc)
    • Logpresso shell (console)
    • Scheduled query (scheduled-query)
    • REST API client (rest-api)
    • Java client (java-client)
    • Python client (python-client)
    • Internal execution of Logpresso Enterprise (system)
    • Internal execution of Logpresso Sonar (sonar)
    • Batch Rules in Logpresso Sonar (batch-rule)
  • login_name (String): Login user name
  • remote_ip (String): Client IP address. When using a load balancer, the X-Forwarded-For header value is used.
  • rows (64-bit integer): Number of query results. This can be monotonically increasing until the query completes.
  • elapsed (64-bit integer): Elapsed time since query execution (in milliseconds)
  • is_finished (Boolean): Whether the query is finished or not
  • is_cancelled (Boolean): Whether the query was requested to be canceled. A query can be canceled by the user explicitly requesting it or by a failure in the command's internal operations (such as a network error). There is a time difference between the request to cancel the query and the completion of the query. There is a time difference between the query cancel request and the completion of the query.
  • is_scheduled_query (Boolean): Whether the query is scheduled.
  • constants (Map): Constant key-value list. Used when passing query parameters, such as running a procedure or scheduled query.
  • query_string (String): Original query string (preserved in its original form).
  • start_time (64-bit integer): Query start time (UNIX epoch)
  • finish_time (64-bit integer): Query finish time (UNIX epoch)
  • last_started (String): Query start time (yyyy-MM-dd HH:mm:ssZ)
  • background (Boolean): Whether to run in the background. Foreground queries are immediately canceled when the session ends, but background queries continue to run even when the session ends.
  • commands (Array): list of commands in the query
    • command (String): Normalized query command
    • status (String): Command execution status. One of the following statuses: Waiting, Running, Finalizing, or End.
    • push_count (64-bit integer): Number of records passed to the next command.
  • sub_queries (Array): List of subqueries
    • id (32-bit integer): Query ID
    • commands (Array): Command list
      • name (32-bit integer): Command name
      • command (String): Normalized query statement
      • push_count (64-bit integer): Number of records passed to the next command
      • status (String): Command execution status. One of the following statuses: Waiting, Running, Finalizing, or End.
  • stamp (32-bit integer): Query status inquiry version that is used to distinguish the latest version of a status response for the same query ID when more than one status inquiry is made by a client at the same time.
  • tags (Map): Tag key-value list used by client to hold arbitrary, volatile, user-defined data in the query object on the Logpresso server (e.g. paging counts per query).

Error Responses

Query does not exist

HTTP status code 403. Query status cannot be retrieved if the query does not exist or if it was executed by a different account.

{
  "error_code": "invalid-query-id",
  "error_msg": "cannot access query 42"
}
Qeury ID is not an integer

HTTP status code 400

{
  "error_code": "invalid-param-type",
  "error_msg": "query id should be integer type"
}