query.rst 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. .. _monitor_query_api:
  2. Monitor Query API
  3. =================
  4. The monitor extension provides a simple HTTP-based API for querying request information.
  5. It allows retrieving individual request records or sets of request records, in either HTML or CSV format.
  6. Records can be filtered by time range and the result set sorted by any field.
  7. Large result sets can be paged over multiple queries.
  8. Examples
  9. --------
  10. The following examples show the syntax for common Monitoring queries.
  11. All requests as HTML
  12. ^^^^^^^^^^^^^^^^^^^^
  13. The simplest query is to retrieve an HTML document containing information
  14. about all requests::
  15. GET http://localhost:8080/geoserver/rest/monitor/requests.html
  16. All requests as CSV
  17. ^^^^^^^^^^^^^^^^^^^
  18. Request information can be returned in CSV format, for easier post-processing::
  19. GET http://localhost:8080/geoserver/rest/monitor/requests.csv
  20. Request bodies containing newlines are handled with quoted text. If your CSV reader doesn't handle quoted newlines, it will not work correctly.
  21. All requests as PKZip
  22. ^^^^^^^^^^^^^^^^^^^^^
  23. A PKZip archive containing the CSV file above, with all the request bodies and errors as separate files::
  24. GET http://localhost:8080/geoserver/rest/monitor/requests.zip
  25. All requests as MS Excel
  26. ^^^^^^^^^^^^^^^^^^^^^^^^
  27. A Microsoft Excel spreadsheet containing the same information as the CSV file::
  28. GET http://localhost:8080/geoserver/rest/monitor/requests.xls
  29. Requests during a time period
  30. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  31. Requests can be filtered by date and time range::
  32. GET http://localhost:8080/geoserver/rest/monitor/requests.html?from=2010-06-20&to=2010-07-20
  33. GET http://localhost:8080/geoserver/rest/monitor/requests.html?from=2010-06-20T2:00:00&to=2010-06-20T16:00:00
  34. Request set paging
  35. ^^^^^^^^^^^^^^^^^^
  36. Large result sets can be paged over multiple queries::
  37. GET http://localhost:8080/geoserver/rest/monitor/requests.html?count=100
  38. GET http://localhost:8080/geoserver/rest/monitor/requests.html?count=100&offset=100
  39. GET http://localhost:8080/geoserver/rest/monitor/requests.html?count=100&offset=200
  40. GET http://localhost:8080/geoserver/rest/monitor/requests.html?count=100&offset=300
  41. Single request
  42. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  43. An individual request can be retrieved by specifying its ID::
  44. GET http://localhost:8080/geoserver/rest/monitor/requests/12345.html
  45. API Reference
  46. -------------
  47. There are two kinds of query: one for single requests, and one for sets of requests.
  48. Single Request Query
  49. ^^^^^^^^^^^^^^^^^^^^
  50. A query for a single request record has the structure::
  51. GET http://<host>:<port>/geoserver/rest/monitor/requests/<id>.<format>
  52. where ``id`` is the numeric identifier of a single request,
  53. and ``format`` specifies the representation of the returned result as one of:
  54. * ``html`` - an HTML table.
  55. * ``csv`` - a Comma Separated Values table.
  56. * ``zip`` - PKZip archive containing CSV as above, plus plain text of errors and request body.
  57. * ``xls`` - Microsoft Excel spreadsheet.
  58. .. note::
  59. An alternative to specifying the returned representation with the
  60. ``format`` extension is to use the http ``Accept`` header and specify
  61. the MIME type as one of:
  62. * ``text/html``
  63. * ``application/csv``
  64. * ``application/zip``
  65. * ``application/vnd.ms-excel``
  66. See the `HTTP specification <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html>`_
  67. for more information about the ``Accept`` header.
  68. Request Set Query
  69. ^^^^^^^^^^^^^^^^^
  70. The structure of a query for a set of requests is::
  71. GET http://<host>:<port>/geoserver/rest/monitor/requests.<format>[?parameter{&parameter}]
  72. where ``format`` is as described above,
  73. and ``parameter`` is one or more of the parameters listed below.
  74. The request set query accepts various parameters
  75. that control what requests are returned and how they are sorted.
  76. The available parameters are:
  77. count Parameter
  78. ^^^^^^^^^^^^^^^
  79. Specifies how many records should be returned.
  80. .. list-table::
  81. :header-rows: 1
  82. :widths: 40 60
  83. * - Syntax
  84. - Example
  85. * - ``count=<integer>``
  86. - requests.html?count=100
  87. offset Parameter
  88. ^^^^^^^^^^^^^^^^
  89. Specifies where in the result set records should be returned from.
  90. .. list-table::
  91. :header-rows: 1
  92. :widths: 40 60
  93. * - Syntax
  94. - Example
  95. * - ``offset=<integer>``
  96. - requests.html?count=100&offset=500
  97. live Parameter
  98. ^^^^^^^^^^^^^^
  99. Specifies that only live (currently executing) requests be returned.
  100. .. list-table::
  101. :header-rows: 1
  102. :widths: 40 60
  103. * - Syntax
  104. - Example
  105. * - ``live=<yes|no|true|false>``
  106. - requests.html?live=yes
  107. This parameter relies on a :ref:`monitor_mode` being used that maintains real time
  108. request information (either **live** or **mixed**).
  109. from Parameter
  110. ^^^^^^^^^^^^^^
  111. Specifies an inclusive lower bound on the timestamp for the start of a request.
  112. The timestamp can be specified to any desired precision.
  113. .. list-table::
  114. :header-rows: 1
  115. :widths: 40 60
  116. * - Syntax
  117. - Example
  118. * - ``from=<timestamp>``
  119. - requests.html?from=2010-07-23T16:16:44
  120. * -
  121. - requests.html?from=2010-07-23
  122. to Parameter
  123. ^^^^^^^^^^^^^
  124. Specifies an inclusive upper bound on the timestamp for the start of a request.
  125. The timestamp can be specified to any desired precision.
  126. .. list-table::
  127. :header-rows: 1
  128. :widths: 40 60
  129. * - Syntax
  130. - Example
  131. * - ``to=<timestamp>``
  132. - requests.html?to=2010-07-24T00:00:00
  133. * -
  134. - requests.html?to=2010-07-24
  135. order Parameter
  136. ^^^^^^^^^^^^^^^
  137. Specifies which request attribute to sort by, and optionally specifies the sort direction.
  138. .. list-table::
  139. :header-rows: 1
  140. :widths: 40 60
  141. * - Syntax
  142. - Example
  143. * - ``order=<attribute>[;<ASC|DESC>]``
  144. - requests.html?order=path
  145. * -
  146. - requests.html?order=startTime;DESC
  147. * -
  148. - requests.html?order=totalTime;ASC