[MXS-1780] Provide access to current queries via REST-API Created: 2018-04-11  Updated: 2018-11-08  Resolved: 2018-11-08

Status: Closed
Project: MariaDB MaxScale
Component/s: Core, REST-API
Affects Version/s: None
Fix Version/s: 2.3.1

Type: New Feature Priority: Major
Reporter: Johan Wikman Assignee: Johan Wikman
Resolution: Fixed Votes: 1
Labels: None

Sprint: MXS-SPRINT-69

 Description   

‘SHOW MAXSCALE QUERIES’ - shows the list of queries currently running through MaxScale, the service it is associated with, filters on the service, the user@client sending the query, backend server where the query is running, start time when query was received. The ability to run this command shall be configurable.



 Comments   
Comment by Johan Wikman [ 2018-11-07 ]

This has now been implemented so that the information is provided as part of the session information.
When querying for the session data, the output will contain the following:

$ curl admin:password@127.0.0.1:8989/v1/sessions/7
{
    "links": {
        "self": "http://127.0.0.1:8989/v1/sessions/7"
    },
   "data": {
...
        "attributes": {
...
            "queries": [
                {
                    "command": "COM_QUERY",
                    "statement": "select @@version_comment limit 1",
                    "received": "2018-11-07T11:28:22.133",
                    "completed": "2018-11-07T11:28:22.133",
                    "responses": [
                        {
                            "server": "Server2",
                            "duration": 0
                        }
                    ]
                },
...
}

where

  • command denotes the protocol command,
  • statement is present if the command is COM_QUERY,
  • received shows the timestamp when MaxScale received the packet,
  • completed is present and shows the timestamp, if MaxScale has received all responses from the servers (may be just one),
  • responses is an array containing the individual server notes (may be just one), where server identifies the server and duration the time, expressed in milliseconds, it took before MaxScale received the response.

This information is available if retain_last_statements has been specified, either in the MaxScale global section or specifically for the service the session relates to.

The maxctrl command show sessions shows the last statements of the sessions, but not the details.

The feature can be turned on and off at runtime using maxctrl alter service. E.g.

maxctrl -u admin -p password alter service RWS retain_last_statements 5

The command above will cause new sessions related to the service RWS to retain the last 5 statements of the session. Existing sessions are not affected.

Generated at Thu Feb 08 04:09:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.