Browse code

xhttp_prom: added prom_counter_dec docbook description

Sergey Safarov authored on 16/09/2021 21:02:21
Showing 1 changed files
... ...
@@ -403,6 +403,43 @@ prom_gauge_reset("cnt01", "push", "192.168.0.1");
403 403
 ...
404 404
 # A metric like this will appear when listing this gauge:
405 405
 kamailio_cnt01 {method="push", IP="192.168.0.1"} 0 1234567890
406
+...
407
+		</programlisting>
408
+			</example>
409
+		</section>
410
+		<section id="xhttp_prom.f.prom_counter_dec">
411
+			<title>
412
+				<function moreinfo="none">prom_counter_dec(name, number, l0, l1, l2)</function>
413
+			</title>
414
+			<para>Get a counter identified by its name and labels and deccrease its value by a
415
+				number. If counter does not exist it creates the counter, initializes it to zero. If
416
+				after decrement resulted value lower then 0, then function return error</para>
417
+			<para>Name is mandatory, number is mandatory. Number has to be positive or zero
418
+				(integer). l0, l1, l2 are values of labels and are optional.</para>
419
+			<para>name value and number of labels have to match a previous counter definition with
420
+				prom_counter.</para>
421
+			<para>This function accepts pseudovariables on its parameters.</para>
422
+			<para>Available via KEMI framework as <emphasis>counter_dec_l0</emphasis>,
423
+					<emphasis>counter_dec_l1</emphasis>, <emphasis>counter_dec_l2</emphasis> and
424
+					<emphasis>counter_dec_l3</emphasis>.</para>
425
+			<example>
426
+				<title><function>prom_counter_dec</function> usage</title>
427
+				<programlisting format="linespecific">
428
+...
429
+# Definition of cnt01 counter with no labels.
430
+modparam("xhttp_prom", "prom_counter", "name=cnt01;");
431
+...
432
+# Decrement 10 from value of cnt01 counter (with no labels) If counter does not exist it gets created.
433
+prom_counter_dec("cnt01", "10");
434
+...
435
+
436
+# Definition of cnt02 counter with two labels method and IP
437
+modparam("xhttp_prom", "prom_counter", "name=cnt02; label=method:IP;");
438
+...
439
+# Decrement 15 from value of cnt02 counter with labels method and IP. It creates the counter if it does not exist.
440
+prom_counter_dec("cnt02", "15", "push", "192.168.0.1");
441
+# When listed the metric it will show a line like this:
442
+kamailio_cnt02 {method="push", IP="192.168.0.1"} 15 1234567890
406 443
 ...
407 444
 		</programlisting>
408 445
 			</example>