Skip to content

Commit ca1d2c2

Browse files
simon-dewsarahlwelton
authored andcommitted
DOC-12312: streaming completed requests to local files (#273)
* Add Streaming Completed Requests * Try to make tabs sync with only partial success * Add system:completed_requests_history to sysinfo * Add links to Admin REST API * Update table formatting for sysinfo * Add links to gzip and jq
1 parent ee3fd8c commit ca1d2c2

File tree

2 files changed

+111
-9
lines changed

2 files changed

+111
-9
lines changed

modules/n1ql/pages/n1ql-intro/sysinfo.adoc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,31 @@
33
:description: {sqlpp} has a system namespace that stores metadata about data containers, the Query service, and the system as a whole. \
44
You can query the system namespace to get this information.
55

6+
// Pass through HTML table styles for this page
7+
8+
ifdef::basebackend-html[]
9+
++++
10+
<style type="text/css">
11+
/* No maximum width for table cells */
12+
.doc table.spread > tbody > tr > *,
13+
.doc table.stretch > tbody > tr > * {
14+
max-width: none !important;
15+
}
16+
17+
/* Ignore fixed column widths */
18+
table:not(.fixed-width) col{
19+
width: auto !important;
20+
}
21+
22+
/* Do not hyphenate words in the table */
23+
td.tableblock p,
24+
p.tableblock{
25+
hyphens: manual !important;
26+
}
27+
</style>
28+
++++
29+
endif::[]
30+
631
[abstract]
732
{description}
833

@@ -29,6 +54,7 @@ xref:n1ql:n1ql-manage/monitoring-n1ql-query.adoc#vitals[system:vitals]
2954
xref:n1ql:n1ql-manage/monitoring-n1ql-query.adoc#sys-active-req[system:active_requests]
3055
xref:n1ql:n1ql-manage/monitoring-n1ql-query.adoc#sys-prepared[system:prepareds]
3156
xref:n1ql:n1ql-manage/monitoring-n1ql-query.adoc#sys-completed-req[system:completed_requests]
57+
xref:n1ql:n1ql-manage/monitoring-n1ql-query.adoc#sys-history[system:completed_requests_history]
3258

3359
a| [%hardbreaks]
3460
<<sys_my-user-info,system:my_user_info>>

modules/n1ql/pages/n1ql-manage/monitoring-n1ql-query.adoc

Lines changed: 85 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ This information can be very useful to assess the current workload and performan
5252
[#sys-vitals-get]
5353
=== Get System Vitals
5454

55-
To view system vitals, use the Admin REST API or a {sqlpp} query.
55+
To view system vitals, use the xref:n1ql:n1ql-rest-api/admin.adoc[Admin REST API] or a {sqlpp} query.
5656

5757
[tabs]
5858
====
@@ -126,7 +126,7 @@ The `system:active_requests` catalog lists all currently executing active reques
126126
[[sys-active-get]]
127127
=== Get Active Requests
128128

129-
To view active requests, use the Admin REST API or a {sqlpp} query.
129+
To view active requests, use the xref:n1ql:n1ql-rest-api/admin.adoc[Admin REST API] or a {sqlpp} query.
130130

131131
[tabs]
132132
====
@@ -173,7 +173,7 @@ SELECT *, meta().plan FROM system:active_requests;
173173
[[sys-active-delete]]
174174
=== Terminate an Active Request
175175

176-
The DELETE command can be used to terminate an active request, for instance, a non-responding or a long-running query.
176+
To terminate an active request, for instance, a non-responding or a long-running query, use the xref:n1ql:n1ql-rest-api/admin.adoc[Admin REST API] or a {sqlpp} query.
177177

178178
[tabs]
179179
====
@@ -272,7 +272,7 @@ When there are multiple prepared statements with the same name in different quer
272272
[[sys-prepared-get]]
273273
=== Get Prepared Statements
274274

275-
To get a list of all known prepared statements, use the Admin REST API or a {sqlpp} query.
275+
To get a list of all known prepared statements, use the xref:n1ql:n1ql-rest-api/admin.adoc[Admin REST API] or a {sqlpp} query.
276276

277277
[tabs]
278278
====
@@ -346,7 +346,7 @@ SELECT *, meta().plan FROM system:prepareds;
346346
[[sys-prepared-delete]]
347347
=== Delete Prepared Statements
348348

349-
To delete a specific prepared statement, use the Admin REST API or a {sqlpp} query.
349+
To delete a specific prepared statement, use the xref:n1ql:n1ql-rest-api/admin.adoc[Admin REST API] or a {sqlpp} query.
350350

351351
[tabs]
352352
====
@@ -492,7 +492,7 @@ This information provides a general insight into the health and performance of t
492492
[[sys-completed-get]]
493493
=== Get Completed Requests
494494

495-
To get a list of all logged completed requests, use the Admin REST API or a {sqlpp} query.
495+
To get a list of all logged completed requests, use the xref:n1ql:n1ql-rest-api/admin.adoc[Admin REST API] or a {sqlpp} query.
496496

497497
[tabs]
498498
====
@@ -559,7 +559,7 @@ SELECT *, meta().plan FROM system:completed_requests;
559559
[[sys-completed-delete]]
560560
=== Purge the Completed Requests
561561

562-
To purge a specific completed request, use the Admin REST API or a {sqlpp} query.
562+
To purge a specific completed request, use the xref:n1ql:n1ql-rest-api/admin.adoc[Admin REST API] or a {sqlpp} query.
563563

564564
[tabs]
565565
====
@@ -690,9 +690,9 @@ For field names and meanings, see xref:n1ql-rest-admin:index.adoc#Requests[Reque
690690
For query plan field names and meanings, see <<monitor-profile-details>>.
691691

692692
[[sys-completed-config]]
693-
== Configure the Completed Requests
693+
== Configure Completed Requests
694694

695-
You can configure the `system:completed_requests` keyspace by specifying parameters through the Admin API `/admin/settings` endpoint.
695+
You can configure the `system:completed_requests` keyspace by specifying parameters through the xref:n1ql:n1ql-rest-api/admin.adoc[Admin REST API] `/admin/settings` endpoint.
696696

697697
You can specify the conditions for completed request logging using the `completed` field.
698698
This field takes a JSON object containing the names and values of logging qualifiers.
@@ -819,6 +819,82 @@ curl $BASE_URL/admin/settings -u $USER:$PASSWORD \
819819
-d '{"completed-limit":1000}'
820820
----
821821

822+
[[sys-history]]
823+
== Stream Completed Requests
824+
825+
[.status]#Couchbase Server 7.6.4#
826+
827+
In Couchbase Server 7.6.4 and later, you can stream completed requests to disk.
828+
829+
To enable completed request streaming, use the xref:n1ql:n1ql-rest-api/admin.adoc[Admin REST API] `/admin/settings` endpoint to specify the `completed_stream_size` property.
830+
831+
[source,sh]
832+
----
833+
curl $BASE_URL/admin/settings -u $USER:$PASSWORD \
834+
-H 'Content-Type: application/json' \
835+
-d '{"completed_stream_size":500}'
836+
----
837+
838+
This property is a file size in MiB.
839+
When set to `0` (the default), completed request streaming is disabled.
840+
841+
When set to any size greater than `0`, completed requests are streamed to archive files.
842+
The value of this property determines the size of the data to retain, per node.
843+
The configuration for completed requests determines which requests are saved.
844+
845+
NOTE: The additional processing required to save completed requests to disk may limit overall request throughput on a Query node, but typically only when every completed request is being recorded, and requests are very small or short-lived.
846+
The speed of the file system on which the server logs directory resides naturally affects the potential impact too.
847+
848+
[#sys-history-files]
849+
=== Archived Request Files
850+
851+
When streaming is enabled, completed requests are saved to GZIP archives with the prefix `local_request_log` in the Couchbase Server `logs` directory.
852+
Each saved GZIP archive file contains multiple JSON entries, one for each for each recorded completed request.
853+
854+
Couchbase Server writes multiple archive files in parallel, so whilst the order of requests in a file is sequential, a single given file may not contain a contiguous sequence of requests.
855+
856+
When an archive file reaches or exceeds 100 MiB, it is finalized and saved to disk.
857+
This is not a hard limit -- entries are not truncated to adhere to it.
858+
Files may also be finalized with less content, if nothing has been written to them for an extended period.
859+
Files that are actively being written are not available for reading, and they don't count towards the configured size limit until they're finalized.
860+
861+
Couchbase Server tries to manage and retain archive files such that the total disk space used by the files is within the specified limit for the node.
862+
When the specified limit is reached, older files are removed as necessary to make space for newly finalized files.
863+
When a file is removed, it isn't guaranteed that only the oldest requests are evicted, given that Couchbase Server writes to multiple archive files in parallel.
864+
865+
[#sys-history-view]
866+
=== View Archived Requests
867+
868+
To view archived completed requests, use https://www.gnu.org/software/gzip[gzip] and https://jqlang.github.io/jq[jq] on the command line, or a {sqlpp} query.
869+
870+
[tabs,sync-group-id="REST API|{sqlpp}"]
871+
====
872+
Command Line::
873+
+
874+
--
875+
To view all archived completed requests in `$FILE`:
876+
877+
[source,sh]
878+
----
879+
gzip -qdc $FILE | jq .
880+
----
881+
--
882+
883+
{sqlpp}::
884+
+
885+
--
886+
To get a list of archived completed requests using {sqlpp}:
887+
888+
[source,sqlpp]
889+
----
890+
SELECT * FROM system:completed_requests_history;
891+
----
892+
--
893+
====
894+
895+
The `system:completed_requests_history` keyspace is provided for {sqlpp} access to the archived files, but as they are external GZIP archives performance is restricted, particularly with large histories on clusters with multiple Query service nodes.
896+
Directly reading the files may be more useful in some cases.
897+
822898
[#query-monitoring-settings]
823899
== Query Profiling
824900

0 commit comments

Comments
 (0)