Log and Event

Log

GET /api/v1/log
Query Parameters:
 
  • start – (optional) Time stamp of system logs start time (epoch). Default is 0.
  • end – (optional) Time stamp of system logs end time (epoch). Default is 0.
  • limit – (optional) Number of system log records. Default is 20.
  • offset – (optional) Response logs start with.
  • user – (optional) User name who login.
  • level – (optional) Log level like INFO, WARN, ERROR. Append with comma(,) if you want to filter with more than two levels.
  • category – (optional) Function category like container, image, import, export, backup, system. Append with comma(,) if you want to filter with more than two categories.
  • text – (optional) Filter text

Example request

$ curl -sq -XGET -b cookies.txt "http://${QIP}:${QPORT}/container-station/api/v1/log?limit=5&category=image,export"

Example response

[
    {
        "category": "image",
        "id": 59,
        "level": "INFO",
        "message": "Registry remove: new_test",
        "ts": 1628700802,
        "user": "admin"
    },
    {
        "category": "image",
        "id": 58,
        "level": "INFO",
        "message": "Registry edit: new_test",
        "ts": 1628700801,
        "user": "admin"
    },
    {
        "category": "image",
        "id": 57,
        "level": "INFO",
        "message": "Registry add: test, https://test.registry.com",
        "ts": 1628700800,
        "user": "admin"
    },
    {
        "category": "image",
        "id": 56,
        "level": "INFO",
        "message": "Image removed (docker, busybox:latest)",
        "ts": 1628700795,
        "user": "admin"
    },
    {
        "category": "image",
        "id": 55,
        "level": "INFO",
        "message": "Finished background task (image_download, busybox:latest)",
        "ts": 1628700791,
        "user": "admin"
    }
]
GET /api/v1/log/export

Export logs to csv format.

Example request

$ curl -sq -XGET -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/log/export

Example response

Date,Level,Category,User,Message
2021-08-11 16:42:51.676762,INFO,system,admin,Keep original data folder /share/Container
2021-08-11 16:43:04.160557,INFO,system,system,Update image list successfully
2021-08-11 16:43:04.294690,INFO,system,system,Update application metadata successfully
2021-08-11 16:43:10.543662,INFO,system,system,Update image list successfully
2021-08-11 16:43:10.713850,INFO,system,system,Update application metadata successfully
2021-08-11 16:43:38.518454,INFO,container,admin,"Start to do background task (create, ubuntu-1)"
2021-08-11 16:44:57.618839,INFO,container,admin,"Finished background task (create, ubuntu-1)"
2021-08-11 16:45:57.443912,INFO,container,admin,"Start to do background task (application, joomla)"
2021-08-11 16:47:48.016916,INFO,container,admin,"Finished background task (application, joomla)"
2021-08-11 16:49:05.316092,INFO,container,admin,Restart application: joomla
2021-08-11 16:49:10.745047,INFO,container,admin,Kill application: joomla
2021-08-11 16:49:18.197680,INFO,container,admin,Start application: joomla
2021-08-11 16:49:24.049037,INFO,container,admin,Stop application: joomla
2021-08-11 16:49:28.904668,INFO,container,admin,Destroy application: joomla
2021-08-11 16:49:30.765872,INFO,container,admin,"Start to do background task (create, ctest)"
2021-08-11 16:50:13.888122,INFO,container,admin,"Create container (lxc, ctest)"
2021-08-11 16:50:14.683022,INFO,container,admin,"Finished background task (create, ctest)"
2021-08-11 16:50:14.926039,INFO,container,admin,"Start to do background task (create, lxdTest)"
2021-08-11 16:50:18.481793,ERROR,container,admin,"Background task error for create lxdTest: Failed creating instance record: Failed initialising instance: Failed to add device ""disk0"": Missing source path ""/share/test/selenium"" for disk ""disk0"""
2021-08-11 16:50:18.660859,ERROR,container,admin,"Failed to do background task (create, lxdTest)"
2021-08-11 16:50:18.889085,INFO,container,admin,"Start to do background task (create, dtest)"
2021-08-11 16:50:47.467564,INFO,container,admin,"Create container (docker, d59bf8a8b229, dtest)"
2021-08-11 16:50:47.742481,INFO,container,admin,"Finished background task (create, dtest)"
2021-08-11 16:50:48.237480,INFO,container,admin,"Start to do background task (application, joomla)"
2021-08-11 16:51:01.022091,INFO,container,admin,"Finished background task (application, joomla)"
2021-08-11 16:51:01.473309,INFO,image,admin,"Start to do background task (image_download, busybox:latest)"
2021-08-11 16:51:13.498795,INFO,image,admin,"Finished background task (image_download, busybox:latest)"
2021-08-11 16:51:13.851026,INFO,image,admin,"Start to do background task (image_remove, busybox:latest)"
2021-08-11 16:51:14.259497,INFO,image,admin,"Image removed (docker, busybox:latest)"
2021-08-11 16:51:14.479482,INFO,image,admin,"Finished background task (image_remove, busybox:latest)"
2021-08-11 16:51:14.822038,INFO,image,admin,"Start to do background task (image_download, ubuntu-bionic:latest)"
2021-08-11 16:51:15.004474,INFO,image,admin,"Finished background task (image_download, ubuntu-bionic:latest)"
2021-08-11 16:51:30.466391,INFO,container,admin,"Create container (lxc, utest)"
2021-08-11 16:51:33.700593,INFO,container,admin,"Destroy container (lxc, utest)"
2021-08-11 16:51:42.336130,INFO,container,admin,"Create container (lxc, utest)"
2021-08-11 16:51:44.661385,INFO,image,admin,"Start to do background task (image_download, ubuntu:latest)"
2021-08-11 16:51:44.897767,INFO,image,admin,"Finished background task (image_download, ubuntu:latest)"
2021-08-11 16:51:48.232295,INFO,container,admin,"Create container (docker, 5b4b96c56fd7, DockerTestAPI)"
2021-08-11 16:51:51.729272,INFO,container,admin,"Create container (docker, 0f7bfee7f449, DockerTestAPI2)"
2021-08-11 16:51:53.372064,INFO,container,admin,"Start to do background task (create, lxdTest)"
2021-08-11 16:52:10.724089,INFO,container,admin,"Finished background task (create, lxdTest)"
2021-08-11 16:52:16.123429,INFO,container,admin,"Stop container (lxc, utest)"
2021-08-11 16:52:17.036116,INFO,container,admin,"Start container (lxc, utest)"
2021-08-11 16:52:19.502826,INFO,container,admin,"Stop container (docker, 5b4b96c56fd7, DockerTestAPI)"
2021-08-11 16:52:21.813696,INFO,container,admin,"Start container (docker, 5b4b96c56fd7, DockerTestAPI)"
2021-08-11 16:52:24.306341,INFO,container,admin,"Restart container (lxc, utest)"
2021-08-11 16:52:29.521865,INFO,container,admin,"Restart container (docker, 5b4b96c56fd7, DockerTestAPI)"
2021-08-11 16:52:31.178540,INFO,container,admin,"Stop container (lxc, utest)"
2021-08-11 16:52:33.219664,INFO,container,admin,"Stop container (docker, 5b4b96c56fd7, DockerTestAPI)"
2021-08-11 16:52:34.812965,INFO,container,admin,"Destroy container (lxc, utest)"
2021-08-11 16:52:38.320879,INFO,container,admin,"Stop container (docker, 0f7bfee7f449, DockerTestAPI2)"
2021-08-11 16:52:38.918617,INFO,container,admin,"Destroy container (docker, 0f7bfee7f449, DockerTestAPI2)"
2021-08-11 16:52:40.099342,INFO,container,admin,"commit container (docker, 5b4b96c56fd7, aaa:v1)"
2021-08-11 16:53:04.196698,INFO,image,admin,"Start to do background task (image_download, busybox:latest)"
2021-08-11 16:53:11.506500,INFO,image,admin,"Finished background task (image_download, busybox:latest)"
2021-08-11 16:53:15.461287,INFO,image,admin,"Image removed (docker, busybox:latest)"
2021-08-11 16:53:20.631352,INFO,image,admin,"Registry add: test, https://test.registry.com"
2021-08-11 16:53:21.913763,INFO,image,admin,Registry edit: new_test
2021-08-11 16:53:22.799467,INFO,image,admin,Registry remove: new_test
DELETE /api/v1/log

Clear all system logs.

Response JSON Object:
 
  • records (int) – Returns the number of rows deleted.

Example request

$ curl -sq -XDELETE -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/log

Example response

{
  "records": 60
}

Event

GET /api/v1/event
Query Parameters:
 
  • index – start from. default returns the latest 20
  • offset – the newest one

Response format

Category:User:Timestamp:JSON

Category User JSON
image user
action: download
  • name: image name
  • repository: dockerhub, qnap, lxd
  • type: docker, lxc, lxd
  • state: success, error
action: delete
  • name: image name
  • type: docker, lxc, lxd
  • state: success, error
action: update
  • category: local
  • type: docker, lxc, lxd
container user
  • container: container name
  • id: container ID
  • type: docker, lxc, lxd
  • state: create, start, stop, restart, destroy, pause, unpause
  • port: add, remove
export user
  • type: docker, lxc
  • container: container name
  • cid: container ID
  • path: export to
  • compress: true, false
  • state: running, completed, aborted
  • result: if not 0, means something wrong.
import user
  • type: docker, lxc
  • cid: container name
  • path: import from
  • state: running, completed, aborted
  • result: if not 0, means something wrong.

Example request

$ curl -sq -XGET -b cookies.txt http://${QIP}:${QPORT}/container-station/api/v1/event

Example response

{
    "index": 101,
    "messages": [
        "image:admin:1628671995:{\"action\": \"delete\", \"state\": \"success\", \"type\": \"docker\", \"name\": \"busybox\"}",
        "background:admin:1628671991:{\"category\": \"image_download\", \"state\": \"completed\", \"container\": \"busybox:latest\", \"result\": 0, \"tid\": 1}",
        "image:admin:1628671991:{\"name\": \"busybox\", \"repository\": \"dockerhub\", \"state\": \"success\", \"tag\": \"latest\", \"action\": \"download\", \"type\": \"docker\"}",
        "background:admin:1628671984:{\"category\": \"image_download\", \"tid\": 1, \"state\": \"running\", \"container\": \"busybox:latest\"}",
        "container:all:1628671958:{\"container\": null, \"state\": \"destroy\", \"type\": \"docker\", \"id\": \"0f7bfee7f449aa24fff25cceb3dd994d9fc65a2e59a859acd9ce49c5a0356c1f\"}",
        "container:all:1628671958:{\"container\": \"DockerTestAPI2\", \"state\": \"disconnect\", \"type\": \"docker\", \"id\": \"0f7bfee7f449aa24fff25cceb3dd994d9fc65a2e59a859acd9ce49c5a0356c1f\"}",
        "container:all:1628671958:{\"container\": \"DockerTestAPI2\", \"state\": \"die\", \"type\": \"docker\", \"id\": \"0f7bfee7f449aa24fff25cceb3dd994d9fc65a2e59a859acd9ce49c5a0356c1f\"}",
        "container:all:1628671954:{\"container\": \"utest\", \"state\": \"destroy\", \"type\": \"lxc\"}",
        "container:all:1628671951:{\"container\": \"utest\", \"state\": \"stop\", \"type\": \"lxc\"}",
        "container:all:1628671950:{\"container\": \"DockerTestAPI\", \"state\": \"disconnect\", \"type\": \"docker\", \"id\": \"5b4b96c56fd7990fdc2ac65578677d4178a510a470e14e756b0d73e099b28535\"}",
        "container:all:1628671950:{\"container\": \"DockerTestAPI\", \"state\": \"die\", \"type\": \"docker\", \"id\": \"5b4b96c56fd7990fdc2ac65578677d4178a510a470e14e756b0d73e099b28535\"}",
        "container:all:1628671950:{\"container\": \"DockerTestAPI\", \"state\": \"restart\", \"type\": \"docker\", \"id\": \"5b4b96c56fd7990fdc2ac65578677d4178a510a470e14e756b0d73e099b28535\"}",
        "container:all:1628671950:{\"container\": \"DockerTestAPI\", \"state\": \"start\", \"type\": \"docker\", \"id\": \"5b4b96c56fd7990fdc2ac65578677d4178a510a470e14e756b0d73e099b28535\"}",
        "container:all:1628671950:{\"container\": \"DockerTestAPI\", \"state\": \"connect\", \"type\": \"docker\", \"id\": \"5b4b96c56fd7990fdc2ac65578677d4178a510a470e14e756b0d73e099b28535\"}",
        "container:all:1628671946:{\"container\": \"utest\", \"type\": \"lxc\", \"port\": \"add\"}",
        "container:all:1628671945:{\"container\": \"utest\", \"state\": \"start\", \"type\": \"lxc\"}",
        "container:all:1628671944:{\"container\": \"utest\", \"state\": \"restart\", \"type\": \"lxc\"}",
        "container:all:1628671943:{\"container\": \"utest\", \"state\": \"stop\", \"type\": \"lxc\"}",
        "container:all:1628671943:{\"container\": \"DockerTestAPI\", \"state\": \"disconnect\", \"type\": \"docker\", \"id\": \"5b4b96c56fd7990fdc2ac65578677d4178a510a470e14e756b0d73e099b28535\"}",
        "container:all:1628671943:{\"container\": \"DockerTestAPI\", \"state\": \"die\", \"type\": \"docker\", \"id\": \"5b4b96c56fd7990fdc2ac65578677d4178a510a470e14e756b0d73e099b28535\"}"
    ],
    "offset": 121
}
GET /api/v1/event/wait/(string: container_type)/(string: container_id)/(string: state)
Parameters:
  • container_typelxc, docker
  • container_id – container id
  • staterunning, stopped
Query Parameters:
 
  • duration – timeout in seconds (default: 60)

Example request

$ curl -sq -XGET -b cookies.txt "http://${QIP}:${QPORT}/container-station/api/v1/event/wait/lxc/utest/stopped?duration=5"

Example response

{
    "cpu": 0.0005105513955071477,
    "id": "utest",
    "image": "ubuntu-bionic:latest",
    "ipaddress": [
        "10.0.3.241"
    ],
    "memory": 44904448,
    "name": "utest",
    "rx": 393,
    "state": "running",
    "tcpPort": [],
    "tx": 354,
    "type": "lxc"
}