summaryrefslogtreecommitdiffstats
path: root/doc/sphinx/arm/stats.rst
blob: b37b37a68c68c24cbfa86364e602688a5569f234 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
.. _stats:

**********
Statistics
**********

Statistics Overview
===================

Both Kea DHCP servers support statistics gathering. A working DHCP
server encounters various events that can cause certain statistics to be
collected. For example, a DHCPv4 server may receive a packet
(the ``pkt4-received`` statistic increases by one) that after parsing is
identified as a DHCPDISCOVER (``pkt4-discover-received``). The server
processes it and decides to send a DHCPOFFER representing its answer
(the ``pkt4-offer-sent`` and ``pkt4-sent statistics`` increase by one). Such
events happen frequently, so it is not uncommon for the statistics to have
values in the high thousands. They can serve as an easy and powerful
tool for observing a server's and a network's health. For example, if
the ``pkt4-received`` statistic stops growing, it means that the clients'
packets are not reaching the server.

There are four types of statistics:

-  *integer* - this is the most common type. It is implemented as a
   64-bit integer (int64_t in C++), so it can hold any value between
   -2^63 to 2^63-1.

-  *big integer* - this type is inteded for holding large numbers. It is
   implemented as a 128-bit integer (boost::multiprecision::int128_t in C++), so
   it can hold any value between -2^127 to 2^127-1.

-  *floating point* - this type is intended to store floating-point
   precision. It is implemented as a C++ double type.

-  *duration* - this type is intended for recording time periods. It
   uses the \`boost::posix_time::time_duration type, which stores hours,
   minutes, seconds, and microseconds.

-  *string* - this type is intended for recording statistics in text
   form. It uses the C++ std::string type.

During normal operation, the DHCPv4 and DHCPv6 servers gather
statistics. For a list of DHCPv4 and DHCPv6 statistics, see
:ref:`dhcp4-stats` and :ref:`dhcp6-stats`, respectively.

To extract data from the statistics module, the control channel can be
used. See :ref:`ctrl-channel` for details. It is possible to
retrieve a single statistic or all statistics, reset the statistics (i.e.
set them to a neutral value, typically zero), or even completely remove a
single statistic or all statistics. See the section :ref:`command-stats`
for a list of statistics-oriented commands.

Statistics can be used by external tools to monitor Kea. One example of such a tool is Stork.
See :ref:`stork` for details on how to use it and other data sources to retrieve statistics periodically
to get better insight into Kea's health and operational status.

.. _stats-lifecycle:

Statistics Lifecycle
====================

All of the statistics supported by Kea's servers are initialized upon the servers' startup
and are returned in response to the commands such as
:isccmd:`statistic-get-all`. The runtime statistics concerning DHCP packets
processed are initially set to 0 and are reset upon the server
restart.

Per-subnet statistics are recalculated when reconfiguration takes place.

In general, once a statistic is initialized it is held in the manager until
explicitly removed, via :isccmd:`statistic-remove` or
:isccmd:`statistic-remove-all`,
or when the server is shut down.

Removing a statistic that is updated frequently makes little sense, as
it will be re-added when the server code next records that statistic.
The :isccmd:`statistic-remove` and
:isccmd:`statistic-remove-all` commands are
intended to remove statistics that are not expected to be observed in
the near future. For example, a misconfigured device in a network may
cause clients to report duplicate addresses, so the server will report
increasing values of ``pkt4-decline-received``. Once the problem is found
and the device is removed, the system administrator may want to remove
the ``pkt4-decline-received`` statistic so that it is no longer reported, until
and unless a duplicate address is again detected.

.. isccmd:: stats
.. _command-stats:

Commands for Manipulating Statistics
====================================

There are several commands defined that can be used for accessing
(``-get``), resetting to zero or a neutral value (``-reset``), or removing a
statistic completely (``-remove``). The statistics time-based
limit (``-sample-age-set``) and size-based limit (``-sample-count-set``), which
control how long or how many samples of a given statistic are retained, can also
be changed.

The difference between ``-reset`` and ``-remove`` is somewhat subtle.
The ``-reset`` command sets the value of the statistic to zero or a neutral value,
so that after this operation, the statistic has a value of 0 (integer),
0.0 (float), 0h0m0s0us (duration), or "" (string).
When requested, a statistic with the values mentioned is returned.
``-remove`` removes a statistic completely, so the statistic is no longer
reported. However, the server code may add it back if there is a reason
to record it.

.. note::

   The following sections describe commands that can be sent to the
   server; the examples are not fragments of a configuration file. For
   more information on sending commands to Kea, see
   :ref:`ctrl-channel`.

.. isccmd:: statistic-get
.. _command-statistic-get:

The ``statistic-get`` Command
-----------------------------

The :isccmd:`statistic-get` command retrieves a single statistic. It takes a
single-string parameter called ``name``, which specifies the statistic
name. An example command may look like this:

::

   {
       "command": "statistic-get",
       "arguments": {
           "name": "pkt4-received"
       }
   }

The server returns details of the requested statistic, with a result of
0 indicating success and the specified statistic as the value of the
``arguments`` parameter. If the requested statistic is not found, the
response contains an empty map, i.e. only { } as an argument, but
the status code still indicates success (0).

Here is an example response:

::

   {
       "command": "statistic-get",
       "arguments": {
           "pkt4-received": [ [ 125, "2019-07-30 10:11:19.498739" ], [ 100, "2019-07-30 10:11:19.498662" ] ]
       },
       "result": 0
   }

.. isccmd:: statistic-reset
.. _command-statistic-reset:

The ``statistic-reset`` Command
-------------------------------

The :isccmd:`statistic-reset` command sets the specified statistic to its
neutral value: 0 for integer, 0.0 for float, 0h0m0s0us for time
duration, and "" for string type. It takes a single-string parameter
called ``name``, which specifies the statistic name. An example command
may look like this:

::

   {
       "command": "statistic-reset",
       "arguments": {
           "name": "pkt4-received"
       }
   }

If the specific statistic is found and the reset is successful, the
server responds with a status of 0, indicating success, and an empty
parameters field. If an error is encountered (e.g. the requested
statistic was not found), the server returns a status code of 1 (error)
and the text field contains the error description.

.. isccmd:: statistic-remove
.. _command-statistic-remove:

The ``statistic-remove`` Command
--------------------------------

The :isccmd:`statistic-remove` command deletes a single statistic. It
takes a single-string parameter called ``name``, which specifies the
statistic name. An example command may look like this:

::

   {
       "command": "statistic-remove",
       "arguments": {
           "name": "pkt4-received"
       }
   }

If the specific statistic is found and its removal is successful, the
server responds with a status of 0, indicating success, and an empty
parameters field. If an error is encountered (e.g. the requested
statistic was not found), the server returns a status code of 1 (error)
and the text field contains the error description.

.. isccmd:: statistic-get-all
.. _command-statistic-get-all:

The ``statistic-get-all`` Command
---------------------------------

The :isccmd:`statistic-get-all` command retrieves all statistics recorded. An
example command may look like this:

::

   {
       "command": "statistic-get-all",
       "arguments": { }
   }

The server responds with details of all recorded statistics, with a
result set to 0 to indicate that it iterated over all statistics (even
when the total number of statistics is zero).

Here is an example response returning all collected statistics:

::

   {
       "command": "statistic-get-all",
       "arguments": {
           "cumulative-assigned-addresses": [
               [
                   0,
                   "2023-06-13 20:42:46.836166"
               ]
           ],
           "declined-addresses": [
               [
                   0,
                   "2023-06-13 20:42:46.836156"
               ]
           ],
           "pkt4-ack-received": [
               [
                   0,
                   "2023-06-13 20:42:46.616247"
               ]
           ],
           "pkt4-ack-sent": [
               [
                   0,
                   "2023-06-13 20:42:46.616290"
               ]
           ],
           "pkt4-decline-received": [
               [
                   0,
                   "2023-06-13 20:42:46.616296"
               ]
           ],
           "pkt4-discover-received": [
               [
                   0,
                   "2023-06-13 20:42:46.616303"
               ]
           ],
           "pkt4-inform-received": [
               [
                   0,
                   "2023-06-13 20:42:46.616308"
               ]
           ],
           "pkt4-nak-received": [
               [
                   0,
                   "2023-06-13 20:42:46.616312"
               ]
           ],
           "pkt4-nak-sent": [
               [
                   0,
                   "2023-06-13 20:42:46.616314"
               ]
           ],
           "pkt4-offer-received": [
               [
                   0,
                   "2023-06-13 20:42:46.616318"
               ]
           ],
           "pkt4-offer-sent": [
               [
                   0,
                   "2023-06-13 20:42:46.616323"
               ]
           ],
           "pkt4-parse-failed": [
               [
                   0,
                   "2023-06-13 20:42:46.616326"
               ]
           ],
           "pkt4-receive-drop": [
               [
                   0,
                   "2023-06-13 20:42:46.616330"
               ]
           ],
           "pkt4-received": [
               [
                   0,
                   "2023-06-13 20:42:46.616335"
               ]
           ],
           "pkt4-release-received": [
               [
                   0,
                   "2023-06-13 20:42:46.616339"
               ]
           ],
           "pkt4-request-received": [
               [
                   0,
                   "2023-06-13 20:42:46.616343"
               ]
           ],
           "pkt4-sent": [
               [
                   0,
                   "2023-06-13 20:42:46.616348"
               ]
           ],
           "pkt4-unknown-received": [
               [
                   0,
                   "2023-06-13 20:42:46.616354"
               ]
           ],
           "reclaimed-declined-addresses": [
               [
                   0,
                   "2023-06-13 20:42:46.836159"
               ]
           ],
           "reclaimed-leases": [
               [
                   0,
                   "2023-06-13 20:42:46.836163"
               ]
           ],
           "subnet[1].assigned-addresses": [
               [
                   0,
                   "2023-06-13 20:42:46.836173"
               ]
           ],
           "subnet[1].cumulative-assigned-addresses": [
               [
                   0,
                   "2023-06-13 20:42:46.836098"
               ]
           ],
           "subnet[1].declined-addresses": [
               [
                   0,
                   "2023-06-13 20:42:46.836178"
               ]
           ],
           "subnet[1].pool[0].assigned-addresses": [
               [
                   0,
                   "2023-06-13 20:42:46.836205"
               ]
           ],
           "subnet[1].pool[0].cumulative-assigned-addresses": [
               [
                   0,
                   "2023-06-13 20:42:46.836137"
               ]
           ],
           "subnet[1].pool[0].declined-addresses": [
               [
                   0,
                   "2023-06-13 20:42:46.836213"
               ]
           ],
           "subnet[1].pool[0].reclaimed-declined-addresses": [
               [
                   0,
                   "2023-06-13 20:42:46.836225"
               ]
           ],
           "subnet[1].pool[0].reclaimed-leases": [
               [
                   0,
                   "2023-06-13 20:42:46.836236"
               ]
           ],
           "subnet[1].pool[0].total-addresses": [
               [
                   11010049,
                   "2023-06-13 20:42:46.836128"
               ]
           ],
           "subnet[1].reclaimed-declined-addresses": [
               [
                   0,
                   "2023-06-13 20:42:46.836186"
               ]
           ],
           "subnet[1].reclaimed-leases": [
               [
                   0,
                   "2023-06-13 20:42:46.836194"
               ]
           ],
           "subnet[1].total-addresses": [
               [
                   11010049,
                   "2023-06-13 20:42:46.836083"
               ]
           ],
           "subnet[1].v4-lease-reuses": [
               [
                   0,
                   "2023-06-13 20:42:46.836105"
               ]
           ],
           "subnet[1].v4-reservation-conflicts": [
               [
                   0,
                   "2023-06-13 20:42:46.836111"
               ]
           ],
           "v4-allocation-fail": [
               [
                   0,
                   "2023-06-13 20:42:46.616358"
               ]
           ],
           "v4-allocation-fail-classes": [
               [
                   0,
                   "2023-06-13 20:42:46.616363"
               ]
           ],
           "v4-allocation-fail-no-pools": [
               [
                   0,
                   "2023-06-13 20:42:46.616368"
               ]
           ],
           "v4-allocation-fail-shared-network": [
               [
                   0,
                   "2023-06-13 20:42:46.616372"
               ]
           ],
           "v4-allocation-fail-subnet": [
               [
                   0,
                   "2023-06-13 20:42:46.616376"
               ]
           ],
           "v4-lease-reuses": [
               [
                   0,
                   "2023-06-13 20:42:46.616410"
               ]
           ],
           "v4-reservation-conflicts": [
               [
                   0,
                   "2023-06-13 20:42:46.616412"
               ]
           ]
       },
       "result": 0
   }

or

::

   {
       "command": "statistic-get-all",
       "arguments": {
           "cumulative-assigned-nas": [
               [
                   0,
                   "2023-06-13 21:28:57.196757"
               ]
           ],
           "cumulative-assigned-pds": [
               [
                   0,
                   "2023-06-13 21:28:57.196758"
               ]
           ],
           "declined-addresses": [
               [
                   0,
                   "2023-06-13 21:28:57.196754"
               ]
           ],
           "pkt6-advertise-received": [
               [
                   0,
                   "2023-06-13 21:28:57.177731"
               ]
           ],
           "pkt6-advertise-sent": [
               [
                   0,
                   "2023-06-13 21:28:57.177739"
               ]
           ],
           "pkt6-decline-received": [
               [
                   0,
                   "2023-06-13 21:28:57.177739"
               ]
           ],
           "pkt6-dhcpv4-query-received": [
               [
                   0,
                   "2023-06-13 21:28:57.177740"
               ]
           ],
           "pkt6-dhcpv4-response-received": [
               [
                   0,
                   "2023-06-13 21:28:57.177740"
               ]
           ],
           "pkt6-dhcpv4-response-sent": [
               [
                   0,
                   "2023-06-13 21:28:57.177741"
               ]
           ],
           "pkt6-infrequest-received": [
               [
                   0,
                   "2023-06-13 21:28:57.177742"
               ]
           ],
           "pkt6-parse-failed": [
               [
                   0,
                   "2023-06-13 21:28:57.177742"
               ]
           ],
           "pkt6-rebind-received": [
               [
                   0,
                   "2023-06-13 21:28:57.177743"
               ]
           ],
           "pkt6-receive-drop": [
               [
                   0,
                   "2023-06-13 21:28:57.177743"
               ]
           ],
           "pkt6-received": [
               [
                   0,
                   "2023-06-13 21:28:57.177744"
               ]
           ],
           "pkt6-release-received": [
               [
                   0,
                   "2023-06-13 21:28:57.177744"
               ]
           ],
           "pkt6-renew-received": [
               [
                   0,
                   "2023-06-13 21:28:57.177745"
               ]
           ],
           "pkt6-reply-received": [
               [
                   0,
                   "2023-06-13 21:28:57.177745"
               ]
           ],
           "pkt6-reply-sent": [
               [
                   0,
                   "2023-06-13 21:28:57.177746"
               ]
           ],
           "pkt6-request-received": [
               [
                   0,
                   "2023-06-13 21:28:57.177747"
               ]
           ],
           "pkt6-sent": [
               [
                   0,
                   "2023-06-13 21:28:57.177747"
               ]
           ],
           "pkt6-solicit-received": [
               [
                   0,
                   "2023-06-13 21:28:57.177748"
               ]
           ],
           "pkt6-unknown-received": [
               [
                   0,
                   "2023-06-13 21:28:57.177748"
               ]
           ],
           "reclaimed-declined-addresses": [
               [
                   0,
                   "2023-06-13 21:28:57.196755"
               ]
           ],
           "reclaimed-leases": [
               [
                   0,
                   "2023-06-13 21:28:57.196756"
               ]
           ],
           "subnet[1].assigned-nas": [
               [
                   0,
                   "2023-06-13 21:28:57.196760"
               ]
           ],
           "subnet[1].assigned-pds": [
               [
                   0,
                   "2023-06-13 21:28:57.196761"
               ]
           ],
           "subnet[1].cumulative-assigned-nas": [
               [
                   0,
                   "2023-06-13 21:28:57.196727"
               ]
           ],
           "subnet[1].cumulative-assigned-pds": [
               [
                   0,
                   "2023-06-13 21:28:57.196729"
               ]
           ],
           "subnet[1].declined-addresses": [
               [
                   0,
                   "2023-06-13 21:28:57.196763"
               ]
           ],
           "subnet[1].pd-pool[0].assigned-pds": [
               [
                   0,
                   "2023-06-13 21:28:57.196785"
               ]
           ],
           "subnet[1].pd-pool[0].cumulative-assigned-pds": [
               [
                   0,
                   "2023-06-13 21:28:57.196744"
               ]
           ],
           "subnet[1].pd-pool[0].reclaimed-leases": [
               [
                   0,
                   "2023-06-13 21:28:57.196789"
               ]
           ],
           "subnet[1].pd-pool[0].total-pds": [
               [
                   256,
                   "2023-06-13 21:28:57.196741"
               ]
           ],
           "subnet[1].pool[0].assigned-nas": [
               [
                   0,
                   "2023-06-13 21:28:57.196773"
               ]
           ],
           "subnet[1].pool[0].cumulative-assigned-nas": [
               [
                   0,
                   "2023-06-13 21:28:57.196739"
               ]
           ],
           "subnet[1].pool[0].declined-addresses": [
               [
                   0,
                   "2023-06-13 21:28:57.196775"
               ]
           ],
           "subnet[1].pool[0].reclaimed-declined-addresses": [
               [
                   0,
                   "2023-06-13 21:28:57.196779"
               ]
           ],
           "subnet[1].pool[0].reclaimed-leases": [
               [
                   0,
                   "2023-06-13 21:28:57.196783"
               ]
           ],
           "subnet[1].pool[0].total-nas": [
               [
                   281474976710656,
                   "2023-06-13 21:28:57.196736"
               ]
           ],
           "subnet[1].reclaimed-declined-addresses": [
               [
                   0,
                   "2023-06-13 21:28:57.196766"
               ]
           ],
           "subnet[1].reclaimed-leases": [
               [
                   0,
                   "2023-06-13 21:28:57.196770"
               ]
           ],
           "subnet[1].total-nas": [
               [
                   281474976710656,
                   "2023-06-13 21:28:57.196720"
               ]
           ],
           "subnet[1].total-pds": [
               [
                   256,
                   "2023-06-13 21:28:57.196724"
               ]
           ],
           "subnet[1].v6-ia-na-lease-reuses": [
               [
                   0,
                   "2023-06-13 21:28:57.196731"
               ]
           ],
           "subnet[1].v6-ia-pd-lease-reuses": [
               [
                   0,
                   "2023-06-13 21:28:57.196733"
               ]
           ],
           "v6-allocation-fail": [
               [
                   0,
                   "2023-06-13 21:28:57.177749"
               ]
           ],
           "v6-allocation-fail-classes": [
               [
                   0,
                   "2023-06-13 21:28:57.177755"
               ]
           ],
           "v6-allocation-fail-no-pools": [
               [
                   0,
                   "2023-06-13 21:28:57.177756"
               ]
           ],
           "v6-allocation-fail-shared-network": [
               [
                   0,
                   "2023-06-13 21:28:57.177756"
               ]
           ],
           "v6-allocation-fail-subnet": [
               [
                   0,
                   "2023-06-13 21:28:57.177757"
               ]
           ],
           "v6-ia-na-lease-reuses": [
               [
                   0,
                   "2023-06-13 21:28:57.177757"
               ]
           ],
           "v6-ia-pd-lease-reuses": [
               [
                   0,
                   "2023-06-13 21:28:57.177758"
               ]
           ]
       },
       "result": 0
   }

or

::

   {
       "command": "statistic-get-all",
       "arguments": {
           "ncr-error": [
               [
                   0,
                   "2023-06-13 21:42:54.627751"
               ]
           ],
           "ncr-invalid": [
               [
                   0,
                   "2023-06-13 21:42:54.627749"
               ]
           ],
           "ncr-received": [
               [
                   0,
                   "2023-06-13 21:42:54.627737"
               ]
           ],
           "update-error": [
               [
                   0,
                   "2023-06-13 21:42:54.627759"
               ]
           ],
           "update-sent": [
               [
                   0,
                   "2023-06-13 21:42:54.627752"
               ]
           ],
           "update-signed": [
               [
                   0,
                   "2023-06-13 21:42:54.627753"
               ]
           ],
           "update-success": [
               [
                   0,
                   "2023-06-13 21:42:54.627755"
               ]
           ],
           "update-timeout": [
               [
                   0,
                   "2023-06-13 21:42:54.627757"
               ]
           ],
           "update-unsigned": [
               [
                   0,
                   "2023-06-13 21:42:54.627754"
               ]
           ]
       },
       "result": 0
   }

.. isccmd:: statistic-reset-all
.. _command-statistic-reset-all:

The ``statistic-reset-all`` Command
-----------------------------------

The :isccmd:`statistic-reset` command sets all statistics to their neutral
values: 0 for integer, 0.0 for float, 0h0m0s0us for time duration, and
"" for string type. An example command may look like this:

::

   {
       "command": "statistic-reset-all",
       "arguments": { }
   }

If the operation is successful, the server responds with a status of 0,
indicating success, and an empty parameters field. If an error is
encountered, the server returns a status code of 1 (error) and the text
field contains the error description.

.. isccmd:: statistic-remove-all
.. _command-statistic-remove-all:

The ``statistic-remove-all`` Command
------------------------------------

The :isccmd:`statistic-remove-all` command attempts to delete all statistics. An
example command may look like this:

::

   {
       "command": "statistic-remove-all",
       "arguments": { }
   }

If the removal of all statistics is successful, the server responds with
a status of 0, indicating success, and an empty parameters field. If an
error is encountered, the server returns a status code of 1 (error) and
the text field contains the error description.

.. isccmd:: statistic-sample-age-set
.. _command-statistic-sample-age-set:

The ``statistic-sample-age-set`` Command
----------------------------------------

The :isccmd:`statistic-sample-age-set` command sets a time-based limit
on samples for a given statistic. It takes two parameters: a string
called ``name``, which specifies the statistic name, and an integer value called
``duration``, which specifies the time limit for the given statistic in seconds.
An example command may look like this:

::

   {
       "command": "statistic-sample-age-set",
       "arguments": {
           "name": "pkt4-received",
           "duration": 1245
       }

   }

If the command is successful, the server responds with a status of
0, indicating success,
and an empty parameters field. If an error is encountered (e.g. the
requested statistic was not found), the server returns a status code
of 1 (error) and the text field contains the error description.

.. isccmd:: statistic-sample-age-set-all
.. _command-statistic-sample-age-set-all:

The ``statistic-sample-age-set-all`` Command
--------------------------------------------

The :isccmd:`statistic-sample-age-set-all` command sets time-based limits
on samples for all statistics. It takes a single-integer parameter
called ``duration``, which specifies the time limit for the statistic
in seconds. An example command may look like this:

::

   {
       "command": "statistic-sample-age-set-all",
       "arguments": {
           "duration": 1245
       }

   }

If the command is successful, the server responds with a status of
0, indicating success,
and an empty parameters field. If an error is encountered, the server returns
a status code of 1 (error) and the text field contains the error description.

.. isccmd:: statistic-sample-count-set
.. _command-statistic-sample-count-set:

The ``statistic-sample-count-set`` Command
------------------------------------------

The :isccmd:`statistic-sample-count-set` command sets a size-based limit
on samples for a given statistic. An example command may look
like this:

::

   {
       "command": "statistic-sample-count-set",
       "arguments": {
           "name": "pkt4-received",
           "max-samples": 100
       }

   }

If the command is successful, the server responds with a status of
0, indicating success,
and an empty parameters field. If an error is encountered (e.g. the
requested statistic was not found), the server returns a status code
of 1 (error) and the text field contains the error description.

.. isccmd:: statistic-sample-count-set-all
.. _command-statistic-sample-count-set-all:

The ``statistic-sample-count-set-all`` Command
----------------------------------------------

The :isccmd:`statistic-sample-count-set-all` command sets size-based limits
on samples for all statistics. An example command may look
like this:

::

   {
       "command": "statistic-sample-count-set-all",
       "arguments": {
           "max-samples": 100
       }

   }

If the command is successful, the server responds with a status of
0, indicating success,
and an empty parameters field. If an error is encountered, the server returns
a status code of 1 (error) and the text field contains the error description.

.. _time-series:

Time Series
===========

With certain statistics, a single isolated data point may be useful. However,
some statistics, such as received
packet size, packet processing time, or number of database queries needed to
process a packet, are not cumulative and it is useful to keep many data
points, perhaps to do some statistical analysis afterwards.


Each Kea statistic holds 20 data points; setting such
a limit prevents unlimited memory growth.
There are two ways to define the limits: time-based (e.g. keep samples from
the last 5 minutes) and size-based. The size-based
limit can be changed using one of two commands: :isccmd:`statistic-sample-count-set`,
to set a size limit for a single statistic, and :isccmd:`statistic-sample-count-set-all`,
to set size-based limits for all statistics. To set time-based
limits for a single statistic, use :isccmd:`statistic-sample-age-set`; use
:isccmd:`statistic-sample-age-set-all` to set time-based limits for all statistics.
For a given statistic only one type of limit can be active; storage
is limited by either time or size, not both.