~jderose/ubuntu/utopic/couchdb/1.6.0

« back to all changes in this revision

Viewing changes to share/doc/src/api/misc.rst

  • Committer: Package Import Robot
  • Author(s): Jason Gerard DeRose
  • Date: 2013-08-28 16:28:32 UTC
  • mfrom: (1.3.4)
  • Revision ID: package-import@ubuntu.com-20130828162832-gp22vmgpfzhk2zyu
Tags: 1.4.0-0ubuntu1
* New upstream release (LP: #1212481)
* Switch from CDBS to pure debhelper (compat 9)
* Bump Standards-Version to 3.9.4
* Use an Upstart job instead of the upstream SysV init.d script
* Remove Build-Depends: cdbs, libreadline-dev
* Add Build-Depends: erlang-os-mon, erlang-syntax-tools, python-sphinx,
  texlive-latex-base, texlive-latex-recommended, texlive-latex-extra,
  texlive-fonts-recommended, texinfo
* Remove couchdb-bin Depends: procps, lsb-base (needed for SysV init.d script)
* Remove couchdb-bin Depends: libjs-jquery (1.7.2 is in Saucy, but the
  internal CouchDB jquery is now at version 1.8.3)
* Simplify Erlang couchdb-bin Depends to just:
  ${erlang-abi:Depends}, ${erlang:Depends}
* Add couchdb Depends: upstart
* Remove deprecated couchdb-bin.postrm
* Thanks to the Upstart job, couchdb.postrm no longer needs `sleep 3` hack,
  nor needs to `rm -r -f "/var/run/couchdb"`
* Stop using versioned database_dir /var/lib/couchdb/VERSION as this isn't
  done upstream and CouchDB is no longer considered alpha software
* Remove README.Debian, README.source as they're no longer applicable
* Drop patches superseded upstream for CVE-2012-5649, CVE-2012-5650:
  - improve_parsing_of_mochiweb_relative_paths.patch
  - improve_script_url_validation.patch
  - include_a_comment_before_jsonp_output.patch
* Because of the switch to Upstart, drop unneeded SysV init.d script patches:
  - force-reload.patch
  - couchdb_own_rundir.patch
  - wait_for_couchdb_stop.patch
* Drop couchdb_sighup.patch, superseded upstream
* Drop logrotate_as_couchdb.patch as it doesn't make sense for the CouchDB
  daemon to be able to modify its own archived log files
* Move static data and docs in "/usr/share/couchdb" from `couchdb-bin` into
  new `couchdb-common` Architecture:all package
* Add couchdb-bin Depends: couchdb-common (= ${source:Version})
* debian/watch: point to current download location
* debian/rules: replace `get-orig-source` with `get-packaged-orig-source`

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.. Licensed under the Apache License, Version 2.0 (the "License"); you may not
 
2
.. use this file except in compliance with the License. You may obtain a copy of
 
3
.. the License at
 
4
..
 
5
..   http://www.apache.org/licenses/LICENSE-2.0
 
6
..
 
7
.. Unless required by applicable law or agreed to in writing, software
 
8
.. distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
9
.. WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
10
.. License for the specific language governing permissions and limitations under
 
11
.. the License.
 
12
 
 
13
.. _api-misc:
 
14
 
 
15
=====================
 
16
Miscellaneous Methods
 
17
=====================
 
18
 
 
19
The CouchDB Miscellaneous interface provides the basic interface to a
 
20
CouchDB server for obtaining CouchDB information and getting and setting
 
21
configuration information.
 
22
 
 
23
A list of the available methods and URL paths are provided below:
 
24
 
 
25
+--------+-------------------------+-------------------------------------------+
 
26
| Method | Path                    | Description                               |
 
27
+========+=========================+===========================================+
 
28
| GET    | /                       |  Get the welcome message and version      |
 
29
|        |                         |  information                              |
 
30
+--------+-------------------------+-------------------------------------------+
 
31
| GET    | /_active_tasks          |  Obtain a list of the tasks running in the|
 
32
|        |                         |  server                                   |
 
33
+--------+-------------------------+-------------------------------------------+
 
34
| GET    | /_all_dbs               |  Get a list of all the DBs                |
 
35
+--------+-------------------------+-------------------------------------------+
 
36
| GET    | /_db_updates            |  A feed of database events                |
 
37
+--------+-------------------------+-------------------------------------------+
 
38
| GET    | /_log                   |  Return the server log file               |
 
39
+--------+-------------------------+-------------------------------------------+
 
40
| POST   | /_replicate             |  Set or cancel replication                |
 
41
+--------+-------------------------+-------------------------------------------+
 
42
| POST   | /_restart               |  Restart the server                       |
 
43
+--------+-------------------------+-------------------------------------------+
 
44
| GET    | /_stats                 |  Return server statistics                 |
 
45
+--------+-------------------------+-------------------------------------------+
 
46
| GET    | /_utils                 |  CouchDB administration interface (Futon) |
 
47
+--------+-------------------------+-------------------------------------------+
 
48
| GET    | /_uuids                 |  Get generated UUIDs from the server      |
 
49
+--------+-------------------------+-------------------------------------------+
 
50
| GET    | /favicon.ico            |  Get the site icon                        |
 
51
+--------+-------------------------+-------------------------------------------+
 
52
 
 
53
``GET /``
 
54
=========
 
55
 
 
56
* **Method**: ``GET /``
 
57
* **Request**: None
 
58
* **Response**: Welcome message and version
 
59
* **Admin Privileges Required**: no
 
60
* **Return Codes**:
 
61
 
 
62
  * **200**:
 
63
    Request completed successfully.
 
64
 
 
65
Accessing the root of a CouchDB instance returns meta information about
 
66
the instance. The response is a JSON structure containing information
 
67
about the server, including a welcome message and the version of the
 
68
server.
 
69
 
 
70
.. code-block:: javascript
 
71
 
 
72
    {
 
73
       "couchdb" : "Welcome",
 
74
       "version" : "1.0.1"
 
75
    }
 
76
 
 
77
.. _active-tasks:
 
78
 
 
79
``GET /_active_tasks``
 
80
======================
 
81
 
 
82
* **Method**: ``GET /_active_tasks``
 
83
* **Request**: None
 
84
* **Response**: List of running tasks, including the task type, name, status
 
85
  and process ID
 
86
* **Admin Privileges Required**: yes
 
87
* **Return Codes**:
 
88
 
 
89
  * **200**:
 
90
    Request completed successfully.
 
91
 
 
92
You can obtain a list of active tasks by using the ``/_active_tasks``
 
93
URL. The result is a JSON array of the currently running tasks, with
 
94
each task being described with a single object. For example:
 
95
 
 
96
.. code-block:: javascript
 
97
 
 
98
    [
 
99
       {
 
100
        "pid" : "<0.11599.0>",
 
101
        "status" : "Copied 0 of 18369 changes (0%)",
 
102
        "task" : "recipes",
 
103
        "type" : "Database Compaction"
 
104
        }
 
105
    ]
 
106
 
 
107
The returned structure includes the following fields for each task:
 
108
 
 
109
* **tasks** [array]: Active Task
 
110
 
 
111
  * **pid**:Process ID
 
112
  * **status**: Task status message
 
113
  * **task**: Task name
 
114
  * **type**: Operation Type
 
115
 
 
116
For operation type, valid values include:
 
117
 
 
118
-  ``Database Compaction``
 
119
 
 
120
-  ``Replication``
 
121
 
 
122
-  ``View Group Compaction``
 
123
 
 
124
-  ``View Group Indexer``
 
125
 
 
126
``GET /_all_dbs``
 
127
=================
 
128
 
 
129
* **Method**: ``GET /_all_dbs``
 
130
* **Request**: None
 
131
* **Response**: JSON list of DBs
 
132
* **Admin Privileges Required**: no
 
133
* **Return Codes**:
 
134
 
 
135
  * **200**:
 
136
    Request completed successfully.
 
137
 
 
138
Returns a list of all the databases in the CouchDB instance. For
 
139
example:
 
140
 
 
141
.. code-block:: http
 
142
 
 
143
    GET http://couchdb:5984/_all_dbs
 
144
    Accept: application/json
 
145
 
 
146
The return is a JSON array:
 
147
 
 
148
.. code-block:: javascript
 
149
 
 
150
    [
 
151
       "_users",
 
152
       "contacts",
 
153
       "docs",
 
154
       "invoices",
 
155
       "locations"
 
156
    ]
 
157
 
 
158
``GET /_db_updates``
 
159
====================
 
160
 
 
161
* **Method**: ``GET /_db_updates``
 
162
* **Request**: None
 
163
* **Admin Privileges Required**: yes
 
164
* **Query ARguments**:
 
165
 
 
166
  * **Argument**: feed
 
167
 
 
168
    * **Descroption**: Format of the response feed
 
169
    * **Optional**: yes
 
170
    * **Type**: string
 
171
    * **Default**: longpoll
 
172
    * **Supported Values**:
 
173
 
 
174
      * **longpoll**: Closes the connection after the first event.
 
175
      * **continuous**: Send a line of JSON per event. Keeps the socket open until ``timeout``.
 
176
      * **eventsource**: Like, ``continuous``, but sends the events in EventSource format. See http://dev.w3.org/html5/eventsource/ for details,
 
177
 
 
178
  * **Argument**: timeout
 
179
 
 
180
    * **Descroption**: Number of seconds until CouchDB closes the connection.
 
181
    * **Optional**: yes
 
182
    * **Type**: numeric
 
183
    * **Default**: 60
 
184
 
 
185
  * **Argument**: heartbeat
 
186
 
 
187
    * **Descroption**: Whether CouchDB will send a newline character (``\n``) on ``timeout``.
 
188
    * **Optional**: yes
 
189
    * **Type**: boolean
 
190
    * **Default**: true
 
191
 
 
192
* **Return Codes**:
 
193
 
 
194
  * **200**
 
195
    Request completed successfully.
 
196
 
 
197
Returns a list of all database events in the CouchDB instance.
 
198
 
 
199
A database event is one of `created`, `updated`, `deleted`.
 
200
 
 
201
For example:
 
202
 
 
203
.. code-block:: http
 
204
 
 
205
    GET http://couchdb:5984/_db_events?feed=continuous
 
206
    Accept: application/json
 
207
 
 
208
.. code-block:: javascript
 
209
 
 
210
    {"dbname":"my-database", "type":"created"}
 
211
    {"dbname":"my-database", "type":"updated"}
 
212
    {"dbname":"another-database", "type":"created"}
 
213
    {"dbname":"my-database", "type":"deleted"}
 
214
    {"dbname":"another-database", "type":"updated"}
 
215
 
 
216
 
 
217
 
 
218
``GET /_log``
 
219
=============
 
220
 
 
221
* **Method**: ``GET /_log``
 
222
* **Request**: None
 
223
* **Response**: Log content
 
224
* **Admin Privileges Required**: yes
 
225
* **Query Arguments**:
 
226
 
 
227
  * **Argument**: bytes
 
228
 
 
229
    * **Description**:  Bytes to be returned
 
230
    * **Optional**: yes
 
231
    * **Type**: numeric
 
232
    * **Default**: 1000
 
233
 
 
234
  * **Argument**: offset
 
235
 
 
236
    * **Description**:  Offset in bytes where the log tail should be started
 
237
    * **Optional**: yes
 
238
    * **Type**: numeric
 
239
    * **Default**: 0
 
240
 
 
241
* **Return Codes**:
 
242
 
 
243
  * **200**:
 
244
    Request completed successfully.
 
245
 
 
246
Gets the CouchDB log, equivalent to accessing the local log file of the
 
247
corresponding CouchDB instance.
 
248
 
 
249
When you request the log, the response is returned as plain (UTF-8)
 
250
text, with an HTTP ``Content-type`` header as ``text/plain``.
 
251
 
 
252
For example, the request:
 
253
 
 
254
.. code-block:: http
 
255
 
 
256
    GET http://couchdb:5984/_log
 
257
    Accept: */*
 
258
 
 
259
The raw text is returned:
 
260
 
 
261
.. code-block:: text
 
262
 
 
263
    [Wed, 27 Oct 2010 10:49:42 GMT] [info] [<0.23338.2>] 192.168.0.2 - - 'PUT' /authdb 401
 
264
    [Wed, 27 Oct 2010 11:02:19 GMT] [info] [<0.23428.2>] 192.168.0.116 - - 'GET' /recipes/FishStew 200
 
265
    [Wed, 27 Oct 2010 11:02:19 GMT] [info] [<0.23428.2>] 192.168.0.116 - - 'GET' /_session 200
 
266
    [Wed, 27 Oct 2010 11:02:19 GMT] [info] [<0.24199.2>] 192.168.0.116 - - 'GET' / 200
 
267
    [Wed, 27 Oct 2010 13:03:38 GMT] [info] [<0.24207.2>] 192.168.0.116 - - 'GET' /_log?offset=5 200
 
268
 
 
269
If you want to pick out specific parts of the log information you can
 
270
use the ``bytes`` argument, which specifies the number of bytes to be
 
271
returned, and ``offset``, which specifies where the reading of the log
 
272
should start, counted back from the end. For example, if you use the
 
273
following request:
 
274
 
 
275
.. code-block:: http
 
276
 
 
277
    GET /_log?bytes=500&offset=2000
 
278
 
 
279
Reading of the log will start at 2000 bytes from the end of the log, and
 
280
500 bytes will be shown.
 
281
 
 
282
.. _replicate:
 
283
 
 
284
``POST /_replicate``
 
285
====================
 
286
 
 
287
.. todo:: POST /_replicate :: what response is?
 
288
 
 
289
* **Method**: ``POST /_replicate``
 
290
* **Request**: Replication specification
 
291
* **Response**: TBD
 
292
* **Admin Privileges Required**: yes
 
293
* **Query Arguments**:
 
294
 
 
295
  * **Argument**: bytes
 
296
 
 
297
    * **Description**:  Bytes to be returned
 
298
    * **Optional**: yes
 
299
    * **Type**: numeric
 
300
    * **Default**: 1000
 
301
 
 
302
  * **Argument**: offset
 
303
 
 
304
    * **Description**:  Offset in bytes where the log tail should be started
 
305
    * **Optional**: yes
 
306
    * **Type**: numeric
 
307
    * **Default**: 0
 
308
 
 
309
* **Return Codes**:
 
310
 
 
311
  * **200**:
 
312
    Replication request successfully completed
 
313
  * **202**:
 
314
    Continuous replication request has been accepted
 
315
  * **404**:
 
316
    Either the source or target DB is not found
 
317
  * **500**:
 
318
    JSON specification was invalid
 
319
 
 
320
Request, configure, or stop, a replication operation.
 
321
 
 
322
The specification of the replication request is controlled through the
 
323
JSON content of the request. The JSON should be an object with the
 
324
fields defining the source, target and other options. The fields of the
 
325
JSON request are shown in the table below:
 
326
 
 
327
* **cancel (optional)**:  Cancels the replication
 
328
* **continuous (optional)**:  Configure the replication to be continuous
 
329
* **create_target (optional)**:  Creates the target database
 
330
* **doc_ids (optional)**:  Array of document IDs to be synchronized
 
331
* **proxy (optional)**:  Address of a proxy server through which replication
 
332
  should occur
 
333
* **source**:  Source database name or URL
 
334
* **target**:  Target database name or URL
 
335
 
 
336
Replication Operation
 
337
---------------------
 
338
 
 
339
The aim of the replication is that at the end of the process, all active
 
340
documents on the source database are also in the destination database
 
341
and all documents that were deleted in the source databases are also
 
342
deleted (if they exist) on the destination database.
 
343
 
 
344
Replication can be described as either push or pull replication:
 
345
 
 
346
-  *Pull replication* is where the ``source`` is the remote CouchDB
 
347
   instance, and the ``destination`` is the local database.
 
348
 
 
349
   Pull replication is the most useful solution to use if your source
 
350
   database has a permanent IP address, and your destination (local)
 
351
   database may have a dynamically assigned IP address (for example,
 
352
   through DHCP). This is particularly important if you are replicating
 
353
   to a mobile or other device from a central server.
 
354
 
 
355
-  *Push replication* is where the ``source`` is a local database, and
 
356
   ``destination`` is a remote database.
 
357
 
 
358
Specifying the Source and Target Database
 
359
-----------------------------------------
 
360
 
 
361
You must use the URL specification of the CouchDB database if you want
 
362
to perform replication in either of the following two situations:
 
363
 
 
364
-  Replication with a remote database (i.e. another instance of CouchDB
 
365
   on the same host, or a different host)
 
366
 
 
367
-  Replication with a database that requires authentication
 
368
 
 
369
For example, to request replication between a database local to the
 
370
CouchDB instance to which you send the request, and a remote database
 
371
you might use the following request:
 
372
 
 
373
.. code-block:: http
 
374
 
 
375
    POST http://couchdb:5984/_replicate
 
376
    Content-Type: application/json
 
377
    Accept: application/json
 
378
 
 
379
    {
 
380
       "source" : "recipes",
 
381
       "target" : "http://coucdb-remote:5984/recipes",
 
382
    }
 
383
 
 
384
 
 
385
In all cases, the requested databases in the ``source`` and ``target``
 
386
specification must exist. If they do not, an error will be returned
 
387
within the JSON object:
 
388
 
 
389
.. code-block:: javascript
 
390
 
 
391
    {
 
392
       "error" : "db_not_found"
 
393
       "reason" : "could not open http://couchdb-remote:5984/ol1ka/",
 
394
    }
 
395
 
 
396
You can create the target database (providing your user credentials
 
397
allow it) by adding the ``create_target`` field to the request object:
 
398
 
 
399
.. code-block:: http
 
400
 
 
401
    POST http://couchdb:5984/_replicate
 
402
    Content-Type: application/json
 
403
    Accept: application/json
 
404
 
 
405
    {
 
406
       "create_target" : true
 
407
       "source" : "recipes",
 
408
       "target" : "http://couchdb-remote:5984/recipes",
 
409
    }
 
410
 
 
411
The ``create_target`` field is not destructive. If the database already
 
412
exists, the replication proceeds as normal.
 
413
 
 
414
Single Replication
 
415
------------------
 
416
 
 
417
You can request replication of a database so that the two databases can
 
418
be synchronized. By default, the replication process occurs one time and
 
419
synchronizes the two databases together. For example, you can request a
 
420
single synchronization between two databases by supplying the ``source``
 
421
and ``target`` fields within the request JSON content.
 
422
 
 
423
.. code-block:: http
 
424
 
 
425
    POST http://couchdb:5984/_replicate
 
426
    Content-Type: application/json
 
427
    Accept: application/json
 
428
 
 
429
    {
 
430
       "source" : "recipes",
 
431
       "target" : "recipes-snapshot",
 
432
    }
 
433
 
 
434
In the above example, the databases ``recipes`` and ``recipes-snapshot``
 
435
will be synchronized. These databases are local to the CouchDB instance
 
436
where the request was made. The response will be a JSON structure
 
437
containing the success (or failure) of the synchronization process, and
 
438
statistics about the process:
 
439
 
 
440
.. code-block:: javascript
 
441
 
 
442
    {
 
443
       "ok" : true,
 
444
       "history" : [
 
445
          {
 
446
             "docs_read" : 1000,
 
447
             "session_id" : "52c2370f5027043d286daca4de247db0",
 
448
             "recorded_seq" : 1000,
 
449
             "end_last_seq" : 1000,
 
450
             "doc_write_failures" : 0,
 
451
             "start_time" : "Thu, 28 Oct 2010 10:24:13 GMT",
 
452
             "start_last_seq" : 0,
 
453
             "end_time" : "Thu, 28 Oct 2010 10:24:14 GMT",
 
454
             "missing_checked" : 0,
 
455
             "docs_written" : 1000,
 
456
             "missing_found" : 1000
 
457
          }
 
458
       ],
 
459
       "session_id" : "52c2370f5027043d286daca4de247db0",
 
460
       "source_last_seq" : 1000
 
461
    }
 
462
 
 
463
The structure defines the replication status, as described in the table
 
464
below:
 
465
 
 
466
* **history [array]**:  Replication History
 
467
 
 
468
  * **doc_write_failures**:  Number of document write failures
 
469
  * **docs_read**:  Number of documents read
 
470
  * **docs_written**:  Number of documents written to target
 
471
  * **end_last_seq**:  Last sequence number in changes stream
 
472
  * **end_time**:  Date/Time replication operation completed
 
473
  * **missing_checked**:  Number of missing documents checked
 
474
  * **missing_found**:  Number of missing documents found
 
475
  * **recorded_seq**:  Last recorded sequence number
 
476
  * **session_id**:  Session ID for this replication operation
 
477
  * **start_last_seq**:  First sequence number in changes stream
 
478
  * **start_time**:  Date/Time replication operation started
 
479
 
 
480
* **ok**:  Replication status
 
481
* **session_id**:  Unique session ID
 
482
* **source_last_seq**:  Last sequence number read from source database
 
483
 
 
484
Continuous Replication
 
485
----------------------
 
486
 
 
487
Synchronization of a database with the previously noted methods happens
 
488
only once, at the time the replicate request is made. To have the target
 
489
database permanently replicated from the source, you must set the
 
490
``continuous`` field of the JSON object within the request to true.
 
491
 
 
492
With continuous replication changes in the source database are
 
493
replicated to the target database in perpetuity until you specifically
 
494
request that replication ceases.
 
495
 
 
496
.. code-block:: http
 
497
 
 
498
    POST http://couchdb:5984/_replicate
 
499
    Content-Type: application/json
 
500
    Accept: application/json
 
501
 
 
502
    {
 
503
       "continuous" : true
 
504
       "source" : "recipes",
 
505
       "target" : "http://couchdb-remote:5984/recipes",
 
506
    }
 
507
 
 
508
Changes will be replicated between the two databases as long as a
 
509
network connection is available between the two instances.
 
510
 
 
511
.. note::
 
512
   Two keep two databases synchronized with each other, you need to set
 
513
   replication in both directions; that is, you must replicate from
 
514
   ``databasea`` to ``databaseb``, and separately from ``databaseb`` to
 
515
   ``databasea``.
 
516
 
 
517
Canceling Continuous Replication
 
518
--------------------------------
 
519
 
 
520
You can cancel continuous replication by adding the ``cancel`` field to
 
521
the JSON request object and setting the value to true. Note that the
 
522
structure of the request must be identical to the original for the
 
523
cancellation request to be honoured. For example, if you requested
 
524
continuous replication, the cancellation request must also contain the
 
525
``continuous`` field.
 
526
 
 
527
For example, the replication request:
 
528
 
 
529
.. code-block:: http
 
530
 
 
531
    POST http://couchdb:5984/_replicate
 
532
    Content-Type: application/json
 
533
    Accept: application/json
 
534
 
 
535
    {
 
536
       "source" : "recipes",
 
537
       "target" : "http://couchdb-remote:5984/recipes",
 
538
       "create_target" : true,
 
539
       "continuous" : true
 
540
    }
 
541
 
 
542
Must be canceled using the request:
 
543
 
 
544
.. code-block:: http
 
545
 
 
546
    POST http://couchdb:5984/_replicate
 
547
    Content-Type: application/json
 
548
    Accept: application/json
 
549
 
 
550
    {
 
551
        "cancel" : true,
 
552
        "continuous" : true
 
553
        "create_target" : true,
 
554
        "source" : "recipes",
 
555
        "target" : "http://couchdb-remote:5984/recipes",
 
556
    }
 
557
 
 
558
Requesting cancellation of a replication that does not exist results in
 
559
a 404 error.
 
560
 
 
561
``POST /_restart``
 
562
==================
 
563
 
 
564
* **Method**: ``POST /_restart``
 
565
* **Request**: None
 
566
* **Response**: JSON status message
 
567
* **Admin Privileges Required**: yes
 
568
* **HTTP Headers**:
 
569
 
 
570
  * **Header**: ``Content-Type``
 
571
 
 
572
    * **Description**: Request content type
 
573
    * **Optional**: no
 
574
    * **Value**: :mimetype:`application/json`
 
575
 
 
576
* **Return Codes**:
 
577
 
 
578
  * **200**:
 
579
    Replication request successfully completed
 
580
 
 
581
Restarts the CouchDB instance. You must be authenticated as a user with
 
582
administration privileges for this to work.
 
583
 
 
584
For example:
 
585
 
 
586
.. code-block:: http
 
587
 
 
588
    POST http://admin:password@couchdb:5984/_restart
 
589
 
 
590
The return value (if the server has not already restarted) is a JSON
 
591
status object indicating that the request has been received:
 
592
 
 
593
.. code-block:: javascript
 
594
 
 
595
    {
 
596
       "ok" : true,
 
597
    }
 
598
 
 
599
If the server has already restarted, the header may be returned, but no
 
600
actual data is contained in the response.
 
601
 
 
602
``GET /_stats``
 
603
===============
 
604
 
 
605
* **Method**: ``GET /_stats``
 
606
* **Request**: None
 
607
* **Response**: Server statistics
 
608
* **Admin Privileges Required**: no
 
609
* **Return Codes**:
 
610
 
 
611
  * **200**:
 
612
    Request completed successfully.
 
613
 
 
614
The ``_stats`` method returns a JSON object containing the statistics
 
615
for the running server. The object is structured with top-level sections
 
616
collating the statistics for a range of entries, with each individual
 
617
statistic being easily identified, and the content of each statistic is
 
618
self-describing. For example, the request time statistics, within the
 
619
``couchdb`` section are structured as follows:
 
620
 
 
621
.. code-block:: javascript
 
622
 
 
623
    {
 
624
       "couchdb" : {
 
625
    ...
 
626
          "request_time" : {
 
627
             "stddev" : "27.509",
 
628
             "min" : "0.333333333333333",
 
629
             "max" : "152",
 
630
             "current" : "400.976",
 
631
             "mean" : "10.837",
 
632
             "sum" : "400.976",
 
633
             "description" : "length of a request inside CouchDB without MochiWeb"
 
634
          },
 
635
    ...
 
636
        }
 
637
    }
 
638
 
 
639
 
 
640
The fields provide the current, minimum and maximum, and a collection of
 
641
statistical means and quantities. The quantity in each case is not
 
642
defined, but the descriptions below provide
 
643
 
 
644
The statistics are divided into the following top-level sections:
 
645
 
 
646
-  ``couchdb``: Describes statistics specific to the internals of CouchDB.
 
647
 
 
648
   +-------------------------+-------------------------------------------------------+----------------+
 
649
   | Statistic ID            | Description                                           | Unit           |
 
650
   +=========================+=======================================================+================+
 
651
   | ``auth_cache_hits``     | Number of authentication cache hits                   | number         |
 
652
   +-------------------------+-------------------------------------------------------+----------------+
 
653
   | ``auth_cache_misses``   | Number of authentication cache misses                 | number         |
 
654
   +-------------------------+-------------------------------------------------------+----------------+
 
655
   | ``database_reads``      | Number of times a document was read from a database   | number         |
 
656
   +-------------------------+-------------------------------------------------------+----------------+
 
657
   | ``database_writes``     | Number of times a database was changed                | number         |
 
658
   +-------------------------+-------------------------------------------------------+----------------+
 
659
   | ``open_databases``      | Number of open databases                              | number         |
 
660
   +-------------------------+-------------------------------------------------------+----------------+
 
661
   | ``open_os_files``       | Number of file descriptors CouchDB has open           | number         |
 
662
   +-------------------------+-------------------------------------------------------+----------------+
 
663
   | ``request_time``        | Length of a request inside CouchDB without MochiWeb   | milliseconds   |
 
664
   +-------------------------+-------------------------------------------------------+----------------+
 
665
 
 
666
-  ``httpd_request_methods``
 
667
 
 
668
   +----------------+----------------------------------+----------+
 
669
   | Statistic ID   | Description                      | Unit     |
 
670
   +================+==================================+==========+
 
671
   | ``COPY``       | Number of HTTP COPY requests     | number   |
 
672
   +----------------+----------------------------------+----------+
 
673
   | ``DELETE``     | Number of HTTP DELETE requests   | number   |
 
674
   +----------------+----------------------------------+----------+
 
675
   | ``GET``        | Number of HTTP GET requests      | number   |
 
676
   +----------------+----------------------------------+----------+
 
677
   | ``HEAD``       | Number of HTTP HEAD requests     | number   |
 
678
   +----------------+----------------------------------+----------+
 
679
   | ``POST``       | Number of HTTP POST requests     | number   |
 
680
   +----------------+----------------------------------+----------+
 
681
   | ``PUT``        | Number of HTTP PUT requests      | number   |
 
682
   +----------------+----------------------------------+----------+
 
683
 
 
684
-  ``httpd_status_codes``
 
685
 
 
686
   +----------------+------------------------------------------------------+----------+
 
687
   | Statistic ID   | Description                                          | Unit     |
 
688
   +================+======================================================+==========+
 
689
   | ``200``        | Number of HTTP 200 OK responses                      | number   |
 
690
   +----------------+------------------------------------------------------+----------+
 
691
   | ``201``        | Number of HTTP 201 Created responses                 | number   |
 
692
   +----------------+------------------------------------------------------+----------+
 
693
   | ``202``        | Number of HTTP 202 Accepted responses                | number   |
 
694
   +----------------+------------------------------------------------------+----------+
 
695
   | ``301``        | Number of HTTP 301 Moved Permanently responses       | number   |
 
696
   +----------------+------------------------------------------------------+----------+
 
697
   | ``304``        | Number of HTTP 304 Not Modified responses            | number   |
 
698
   +----------------+------------------------------------------------------+----------+
 
699
   | ``400``        | Number of HTTP 400 Bad Request responses             | number   |
 
700
   +----------------+------------------------------------------------------+----------+
 
701
   | ``401``        | Number of HTTP 401 Unauthorized responses            | number   |
 
702
   +----------------+------------------------------------------------------+----------+
 
703
   | ``403``        | Number of HTTP 403 Forbidden responses               | number   |
 
704
   +----------------+------------------------------------------------------+----------+
 
705
   | ``404``        | Number of HTTP 404 Not Found responses               | number   |
 
706
   +----------------+------------------------------------------------------+----------+
 
707
   | ``405``        | Number of HTTP 405 Method Not Allowed responses      | number   |
 
708
   +----------------+------------------------------------------------------+----------+
 
709
   | ``409``        | Number of HTTP 409 Conflict responses                | number   |
 
710
   +----------------+------------------------------------------------------+----------+
 
711
   | ``412``        | Number of HTTP 412 Precondition Failed responses     | number   |
 
712
   +----------------+------------------------------------------------------+----------+
 
713
   | ``500``        | Number of HTTP 500 Internal Server Error responses   | number   |
 
714
   +----------------+------------------------------------------------------+----------+
 
715
 
 
716
-  ``httpd``
 
717
 
 
718
   +----------------------------------+----------------------------------------------+----------+
 
719
   | Statistic ID                     | Description                                  | Unit     |
 
720
   +==================================+==============================================+==========+
 
721
   | ``bulk_requests``                | Number of bulk requests                      | number   |
 
722
   +----------------------------------+----------------------------------------------+----------+
 
723
   | ``clients_requesting_changes``   | Number of clients for continuous _changes    | number   |
 
724
   +----------------------------------+----------------------------------------------+----------+
 
725
   | ``requests``                     | Number of HTTP requests                      | number   |
 
726
   +----------------------------------+----------------------------------------------+----------+
 
727
   | ``temporary_view_reads``         | Number of temporary view reads               | number   |
 
728
   +----------------------------------+----------------------------------------------+----------+
 
729
   | ``view_reads``                   | Number of view reads                         | number   |
 
730
   +----------------------------------+----------------------------------------------+----------+
 
731
 
 
732
You can also access individual statistics by quoting the statistics
 
733
sections and statistic ID as part of the URL path. For example, to get
 
734
the ``request_time`` statistics, you can use:
 
735
 
 
736
.. code-block:: http
 
737
 
 
738
    GET /_stats/couchdb/request_time
 
739
 
 
740
This returns an entire statistics object, as with the full request, but
 
741
containing only the request individual statistic. Hence, the returned
 
742
structure is as follows:
 
743
 
 
744
.. code-block:: javascript
 
745
 
 
746
    {
 
747
       "couchdb" : {
 
748
          "request_time" : {
 
749
             "stddev" : 7454.305,
 
750
             "min" : 1,
 
751
             "max" : 34185,
 
752
             "current" : 34697.803,
 
753
             "mean" : 1652.276,
 
754
             "sum" : 34697.803,
 
755
             "description" : "length of a request inside CouchDB without MochiWeb"
 
756
          }
 
757
       }
 
758
    }
 
759
 
 
760
 
 
761
``GET /_utils``
 
762
===============
 
763
 
 
764
* **Method**: ``GET /_utils``
 
765
* **Request**: None
 
766
* **Response**: Administration interface
 
767
* **Admin Privileges Required**: no
 
768
 
 
769
Accesses the built-in Futon administration interface for CouchDB.
 
770
 
 
771
``GET /_uuids``
 
772
===============
 
773
 
 
774
* **Method**: ``GET /_uuids``
 
775
* **Request**: None
 
776
* **Response**: List of UUIDs
 
777
* **Admin Privileges Required**: no
 
778
* **Query Arguments**:
 
779
 
 
780
  * **Argument**: count
 
781
 
 
782
    * **Description**:  Number of UUIDs to return
 
783
    * **Optional**: yes
 
784
    * **Type**: numeric
 
785
 
 
786
* **Return Codes**:
 
787
 
 
788
  * **200**:
 
789
    Request completed successfully.
 
790
 
 
791
Requests one or more Universally Unique Identifiers (UUIDs) from the
 
792
CouchDB instance. The response is a JSON object providing a list of
 
793
UUIDs. For example:
 
794
 
 
795
.. code-block:: javascript
 
796
 
 
797
    {
 
798
       "uuids" : [
 
799
          "7e4b5a14b22ec1cf8e58b9cdd0000da3"
 
800
       ]
 
801
    }
 
802
 
 
803
You can use the ``count`` argument to specify the number of UUIDs to be
 
804
returned. For example:
 
805
 
 
806
.. code-block:: http
 
807
 
 
808
    GET http://couchdb:5984/_uuids?count=5
 
809
 
 
810
Returns:
 
811
 
 
812
.. code-block:: javascript
 
813
 
 
814
    {
 
815
       "uuids" : [
 
816
          "c9df0cdf4442f993fc5570225b405a80",
 
817
          "c9df0cdf4442f993fc5570225b405bd2",
 
818
          "c9df0cdf4442f993fc5570225b405e42",
 
819
          "c9df0cdf4442f993fc5570225b4061a0",
 
820
          "c9df0cdf4442f993fc5570225b406a20"
 
821
       ]
 
822
    }
 
823
 
 
824
The UUID type is determined by the UUID type setting in the CouchDB
 
825
configuration. See :ref:`api-put-config`.
 
826
 
 
827
For example, changing the UUID type to ``random``:
 
828
 
 
829
.. code-block:: http
 
830
 
 
831
    PUT http://couchdb:5984/_config/uuids/algorithm
 
832
    Content-Type: application/json
 
833
    Accept: */*
 
834
 
 
835
    "random"
 
836
 
 
837
When obtaining a list of UUIDs:
 
838
 
 
839
.. code-block:: javascript
 
840
 
 
841
    {
 
842
       "uuids" : [
 
843
          "031aad7b469956cf2826fcb2a9260492",
 
844
          "6ec875e15e6b385120938df18ee8e496",
 
845
          "cff9e881516483911aa2f0e98949092d",
 
846
          "b89d37509d39dd712546f9510d4a9271",
 
847
          "2e0dbf7f6c4ad716f21938a016e4e59f"
 
848
       ]
 
849
    }
 
850
 
 
851
``GET /favicon.ico``
 
852
====================
 
853
 
 
854
* **Method**: ``GET /favicon.ico``
 
855
* **Request**: None
 
856
* **Response**: Binary content for the `favicon.ico` site icon
 
857
* **Admin Privileges Required**: no
 
858
* **Return Codes**:
 
859
 
 
860
  * **200**:
 
861
    Request completed successfully.
 
862
  * **404**:
 
863
    The requested content could not be found. The returned content will include
 
864
    further information, as a JSON object, if available.
 
865
 
 
866
Returns the site icon. The return ``Content-Type`` header is
 
867
:mimetype:`image/x-icon`, and the content stream is the image data.