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 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495
|
'\" t
.\"
.\" Copyright (c) 2013-2022,2025 Red Hat.
.\"
.\" This program is free software; you can redistribute it and/or modify it
.\" under the terms of the GNU General Public License as published by the
.\" Free Software Foundation; either version 2 of the License, or (at your
.\" option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful, but
.\" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
.\" or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
.\" for more details.
.\"
.\"
.TH PMWEBAPI 3 "PCP" "Performance Co-Pilot"
.SH NAME
\f3PMWEBAPI\f1 \- introduction to the Performance Metrics Web Application Programming Interface
.SH HTTP SYNOPSIS
.ft 3
.ad l
.hy 0
GET /metrics
.br
GET /series/...
.br
GET /search/...
.br
GET /pmapi/...
.br
POST /logger/...
.hy
.ad
.ft 1
.SH C SYNOPSIS
.ft 3
.ad l
.hy 0
#include <pcp/pmwebapi.h>
.sp
.ft 1
\& ... assorted routines ...
.ft 3
.sp
cc ... \-lpcp_web \-lpcp
.hy
.ad
.ft 1
.SH DESCRIPTION
.de SAMPLE
.PP
.RS 2n
.nf
.nh
..
.de ESAMPLE
.hy
.fi
.RE
..
The PMWEBAPI is a collection of interfaces providing
Performance Co-Pilot services for web applications.
It consists of APIs for web applications querying
and analysing both live and historical performance
data, as well as APIs used by web servers.
.PP
The usual HTTP URL-encoded optional parameter rules
apply and PMWEBAPI REST requests always follow the
convention:
.P
\fI/api/endpoint\fR?\fIparameter1\fR=\fIvalue1\fR&\fIparameter2\fR=\fIvalue2\fR
.PP
Examples in all following sections use the
.BR curl (1)
command line utility with a local
.BR pmproxy (1)
server listening on port 44322 (default port).
The
.BR pmjson (1)
utility is used to neatly format any JSON output,
as opposed to the compact (minimal whitespace) form
provided by default.
The examples in the scalable time series section use
historical data recorded by the
.BR pmlogger (1)
service, in conjunction with a local key-value server.
.SH OPEN METRICS AND OPEN TELEMETRY
Exporting of live performance metrics in either Open Metrics (\c
.IR https://openmetrics.io )
or Open Telemetry (\c
.IR https://opentelemetry.io )
formats is available.
.PP
All requests are performed on the web server host by default,
unless a
.I hostspec
parameter is provided.
.SS GET /metrics
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
names string T{
Comma-separated list of metric names
T}
filter string T{
Comma-separated list of excluded metric names
T}
match string T{
Pattern matching style (exact, glob or regex)
T}
times boolean T{
Append sample times (milliseconds since epoch)
T}
_
hostspec string T{
Host specification as described in \f(CBPCPIntro\fR(1)
T}
.TE
.P
Fetches current values and metadata for all metrics, or only
metrics indicated by a comma-separated list of
.IR names .
.PP
For all numeric metrics with the given NAME prefixes, create
an open text export format giving their current value and
related metadata.
.PP
Choice of output format is selected using the HTTP
.I Accept
header.
With no header, the default response format is Open Metrics
.IR text .
Using the header with value
.I application/json
switches the response to the Open Telemetry JSON format.
.PP
In Open Telemetry response mode, sample timestamps are always
included and are reported using nanosecond precision.
.SAMPLE
$ curl -H Accept:application/json -s http://localhost:44322/metrics?names=disk.dev,filesys | pmjson
{
"resourceMetrics": [
{
"resource": {
"attributes": [ ... ]
},
"scopeMetrics": [
{
"scope": { ... },
"metrics": [
{
"name": "disk.dev.total.bytes",
"description": "per-disk count of total bytes read and written",
"unit": "KiBy",
"sum": {
"aggregationTemporality": "CUMULATIVE",
"isMonotonic": true,
"dataPoints": [
{
"attributes": [ ... ]
"timeUnixNano": "1753934255798173",
"asInt": "68927569"
}
]
}
},
...
.ESAMPLE
.PP
In Open Metrics response mode, the native PCP metric metadata
(metric name, type, indom, semantics and units) is first output
for each metric with
.B # PCP
prefix.
The metadata reported is of the form described on
.BR pmTypeStr (3),
.BR pmInDomStr (3),
.BR pmSemStr (3)
and
.BR pmUnitsStr (3)
respectively.
If the
.BR pmUnitsStr (3)
units string is empty, then
.B none
is output.
The units metadata string may contain spaces and extends to
the end of the line.
.PP
PCP metric names are mapped so that the \fB.\fP separators
are exchanged with \fB_\fP (':' in back-compatibility mode,
where "# PCP" is the identifying line suffix).
Both metric labels and instances are represented as Open Metrics
labels, with external instance names being quoted and the
flattened PCP label hierarchy being presented with each value.
.PP
When metric
.I names
pattern matching is performed using the
.I filter
option, the default mode is glob-based matching.
The
.I match
option can be used to instead request regex-based or
exact-match metric filtering.
.SAMPLE
$ curl -s http://localhost:44322/metrics?names=proc.nprocs,kernel.pernode.cpu.intr,filesys.blocksize
# PCP5 proc.nprocs 3.8.99 u32 PM_INDOM_NULL instant none
# HELP proc_nprocs instantaneous number of processes
# TYPE proc_nprocs gauge
proc_nprocs {hostname="app1"} 7
# PCP5 kernel.pernode.cpu.intr 60.0.66 u64 60.19 counter millisec
# HELP kernel_pernode_cpu_intr total interrupt CPU [...]
# TYPE kernel_pernode_cpu_intr counter
kernel_pernode_cpu_intr{hostname="app1",instname="node0"} 25603
# PCP5 filesys.blocksize 60.5.9 u32 60.5 instant byte
# HELP filesys_blocksize Size of each block on mounted file[...]
# TYPE filesys_blocksize gauge
filesys_blocksize{hostname="app1",instname="/dev/sda1"} 4096
filesys_blocksize{hostname="app1",instname="/dev/sda2"} 4096
.ESAMPLE
.SH SCALABLE TIME SERIES
The fast, scalable time series query capabilities
provided by the
.BR pmseries (1)
command are also available through a REST API.
These queries provide access to performance data
(metric metadata and values) from multiple hosts
simultaneously, and in a fashion suited to efficient
retrieval by any number of web applications.
.PP
All requests in this group can be accompanied by an optional
.IR client
parameter.
The value passed in the request will be sent back in the
response \- all responses will be in JSON object form in
this case, with top level "client" and "result" fields.
.PP
REST API clients can optionally submit an URL-encoded query string
in the body of the HTTP request unless otherwise noted.
In this case the POST method must be used instead of the GET method.
.SS GET \fI/series/ping\fR
Simple liveness test for clients to check whether the server is up
and supports the \fI/series\fR API.
.SS GET \fI/series/query\fR \- \fBpmSeriesQuery\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
expr string Query string in \f(CBpmseries\fR(1) format
client string Request identifier sent back with response
.TE
.PP
Performs a time series query for either matching identifiers,
or matching identifiers with series of time-stamped values.
.PP
The query is in the format described in
.BR pmseries (1)
and is passed to the server via either the
.I expr
parameter (HTTP GET) or via the message body (HTTP POST).
.PP
When querying for time series matches only, no time window
options are specified and matching series identifiers are
returned in a JSON array.
.SAMPLE
$ curl -s 'http://localhost:44322/series/query?expr=disk.dev.read*' | pmjson
[
"9d8c7fb51ce160eb82e3669aac74ba675dfa8900",
"ddff1bfe286a3b18cebcbadc1678a68a964fbe9d",
"605fc77742cd0317597291329561ac4e50c0dd12"
]
.ESAMPLE
.PP
When querying for time series values as well, a time
window must be specified as part of the query string.
The simplest form is to just request the most recent
sample.
.SAMPLE
$ curl -s 'http://localhost:44322/series/query?expr=disk.dev.read*[samples:1]' | pmjson
[
{
"series": "9d8c7fb51ce160eb82e3669aac74ba675dfa8900",
"instance": "c3795d8b757506a2901c6b08b489ba56cae7f0d4",
"timestamp": 1547483646.2147431,
"value": "12499"
}, {
"series": "ddff1bfe286a3b18cebcbadc1678a68a964fbe9d",
"instance": "6b08b489ba56cae7f0d4c3795d8b757506a2901c",
"timestamp": 1547485701.7431218,
"value": "1118623"
}, {
"series": "605fc77742cd0317597291329561ac4e50c0dd12",
"instance": "c3795d8b757506a2901c6b08b489ba56cae7f0d4",
"timestamp": 1547483646.2147431,
"value": "71661"
}
]
.ESAMPLE
.SS GET \fI/series/values\fR \- \fBpmSeriesValues\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
series string Comma-separated list of series identifiers
client string Request identifier sent back with response
_
samples number Count of samples to return
interval string Time between successive samples
start string Sample window start time
finish string Sample window end time
offset string Sample window offset
align string Sample time alignment
zone string Time window timezone
.TE
.P
Performs values retrievals for one or more time series
identifiers.
The JSON response contains the same information as the
\fBpmseries\fR \-\fBq\fR/\-\-\fBquery\fR option using
any of the time window parameters described on
.BR pmseries (1).
If no time window parameters are specified, the single
most recent value observed is retrieved.
.SAMPLE
$ curl -s http://localhost:44322/series/values?series=605fc77742cd0317597291329561ac4e50c0dd12 | pmjson
[
{
"series": "605fc77742cd0317597291329561ac4e50c0dd12",
"timestamp": 1317633022959.959241041,
"value": "71660"
}
]
.ESAMPLE
.SS GET \fI/series/descs\fR \- \fBpmSeriesDescs\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
series string Comma-separated list of series identifiers
client string Request identifier sent back with response
.TE
.P
Performs a descriptor lookup for one or more time series
identifiers.
The JSON response contains the same information as the
\fBpmseries\fR \-\fBd\fR/\-\-\fBdesc\fR option.
.SAMPLE
$ curl -s http://localhost:44322/series/descs?series=605fc77742cd0317597291329561ac4e50c0dd12 | pmjson
[
{
"series": "605fc77742cd0317597291329561ac4e50c0dd12",
"source": "f5ca7481da8c038325d15612bb1c6473ce1ef16f",
"pmid": "60.0.4",
"indom": "60.1",
"semantics": "counter",
"type": "u32",
"units": "count",
}
]
.SS GET \fI/series/labels\fR \- \fBpmSeriesLabels\fR(3), \fBpmSeriesLabelValues\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
series string Comma-separated list of series identifiers
match string Glob pattern string to match on all labels
name string Find all known label values for given name
names string Comma-separated list of label names
client string Request identifier sent back with response
.TE
.P
This command operates in one of three modes.
It can perform a label set lookup for one or more time
series identifiers, when given the
.I series
parameter).
It can produce a list of all known label names, in the
absence of
.IR name ,
.I names
or
.I series
parameters.
The JSON responses for these modes contains the same information
as the \fBpmseries\fR \-\fBl\fR/\-\-\fBlabels\fR option.
.P
Alternatively, it can produce a list of all known label
values for a given label
.I name
or
.IR names .
The JSON response for this mode contains the same information
as the \fBpmseries\fR \-\fBv\fR/\-\-\fBvalues\fR option.
.SAMPLE
$ curl -s http://localhost:44322/series/labels?series=605fc77742cd0317597291329561ac4e50c0dd12 | pmjson
[
{
"series": "605fc77742cd0317597291329561ac4e50c0dd12",
"labels": {
"agent": "linux",
"domainname": "acme.com",
"groupid": 1000,
"hostname": "www.acme.com",
"latitude": -25.28496,
"longitude": 152.87886,
"machineid": "295b16e3b6074cc8bdbda8bf96f6930a",
"platform": "dev",
"userid": 1000
}
}
]
.ESAMPLE
.P
Alternatively, with no
.IR name ,
.I names
or
.I series
parameters, return the list of all known label names.
.SAMPLE
$ curl -s http://localhost:44322/series/labels | pmjson
[
"agent",
"appversion",
"domainname",
"groupid",
"hostname",
"jobid",
"latitude",
"longitude",
"machineid",
"platform",
"userid"
]
.ESAMPLE
.P
Use the
.I name
or
.I names
parameters to find all possible label values for the given name(s).
.SAMPLE
$ curl -s http://localhost:44322/series/labels?names=hostname,domainname | pmjson
{
"hostname": [ "app", "nas" ],
"domainname": [ "acme.com" ]
}
.ESAMPLE
.SS GET \fI/series/metrics\fR \- \fBpmSeriesMetrics\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
series string Comma-separated list of series identifiers
match string Glob pattern string to match on all names
client string Request identifier sent back with response
.TE
.P
Performs a metric name lookup for one or more time series
identifiers.
The JSON response contains the same information as the
\fBpmseries\fR \-\fBm\fR/\-\-\fBmetrics\fR option.
.SAMPLE
$ curl -s http://localhost:44322/series/metrics?series=605fc77742cd0317597291329561ac4e50c0dd12 | pmjson
[
{
"series": "605fc77742cd0317597291329561ac4e50c0dd12",
"name": "disk.dev.read_bytes"
}
]
.ESAMPLE
.P
Alternatively, with no
.I series
argument, this request will return the list of all known
metric names.
.SAMPLE
$ curl -s http://localhost:44322/series/metrics | pmjson
[
"disk.dev.read",
"disk.dev.read_bytes",
"disk.dev.read_merge",
"kernel.all.load",
"kernel.all.pswitch",
...
]
.ESAMPLE
.SS GET \fI/series/sources\fR \- \fBpmSeriesSources\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
series string Comma-separated list of source identifiers
match string Glob pattern string to match on all sources
client string Request identifier sent back with response
.TE
.P
Performs a lookup for one or more time series sources,
returning an array of all PMAPI context names used to
access the time series from that source.
The JSON response contains the same information as the
\fBpmseries\fR \-\fBS\fR/\-\-\fBsource\fR option.
.SAMPLE
$ curl -s http://localhost:44322/series/sources?source=2cd6a38f9339f2dd1f0b4775bda89a9e7244def6 | pmjson
[
{
"source": "2cd6a38f9339f2dd1f0b4775bda89a9e7244def6",
"context": [
"/var/log/pcp/pmlogger/acme",
"www.acme.com"
]
}
]
.ESAMPLE
.SS GET \fI/series/instances\fR \- \fBpmSeriesInstances\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | lx.
Parameters Type Explanation
_
series string T{
.hy 0
.ad l
Comma-separated list of series identifiers
T}
match string T{
.hy 0
.ad l
Glob pattern string to match on all instances
T}
client string T{
.hy 0
.ad l
Request identifier sent back with response
T}
.TE
.P
Provide instance identifiers and names for one or more
time series identifiers.
The JSON response contains the same information as the
\fBpmseries\fR \-\fBi\fR/\-\-\fBinstance\fR option.
.SAMPLE
$ curl -s http://localhost:44322/series/instances?series=605fc77742cd0317597291329561ac4e50c0dd12 | pmjson
[
{
"series": "605fc77742cd0317597291329561ac4e50c0dd12",
"source": "97261ac7742cd4e50c0d03175913295d12605fc7",
"instance": "c3795d8b757506a2901c6b08b489ba56cae7f0d4"
"id": 1,
"name": "sda",
}, {
"series": "605fc77742cd0317597291329561ac4e50c0dd12",
"source": "97261ac7742cd4e50c0d03175913295d12605fc7",
"instance": "57506a2901c6b08b489ba56cae7f0d4c3795d8b7"
"id": 2,
"name": "sdb",
}
]
.ESAMPLE
.P
Alternatively, with no
.I series
argument, this request will return the list of all known
instance names.
.SAMPLE
$ curl -s http://localhost:44322/series/instances | pmjson
[
"1 minute",
"5 minute",
"15 minute",
"cpu0",
"cpu1",
"cpu2",
"cpu3",
"node0",
"node1",
"sda",
"sdb",
...
]
.ESAMPLE
.SS GET \fI/series/load\fR \- \fBpmSeriesLoad\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
expr string Source load string in \f(CBpmseries\fR(1) format
client string Request identifier sent back with response
.TE
.PP
Load time series performance data from the specified source
into the key-value server cache.
This request is equivalent to the \fBpmseries\fR \-\fBl\fR/\-\-\fBload\fR
option.
.SAMPLE
$ curl -s http://localhost:44322/series/load?expr={source.name:"/var/log/pcp/pmlogger/acme"}
{
"success": true
}
.ESAMPLE
.SH FULL TEXT SEARCH
The full text search capabilities
provided by the
.BR pmsearch (1)
command are also available through a REST API.
These queries provide access to an index over performance
metric names, instances, instance domains and help text,
suitable for a metric search engine, and in a fashion suited
to efficient querying by any number of web applications.
.PP
In order to use this functionality, the optional
.I ValkeySearch
module must be loaded in the key-value server at the time
.B pmproxy
is started, such that metrics, instances and help text it
discovers can be automatically indexed.
.SS GET \fI/search/text\fR \- \fBpmSearchTextQuery\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
query string Query string in \f(CBpmsearch\fR(1) format
highlight fields Include matching markup in response fields
offset number Result offset cursor for pagination
limit number Maximum results to include in response
field fields Queried fields (defaults to all)
return fields Fields to actually return (defaults to all)
type types Entity types to filter (defaults to all)
.TE
.PP
Performs a text search query across metrics and instance
domains \- all forms of names and help texts.
.PP
The mandatory search string is further described in
.BR pmsearch (1)
and is passed to the server via the
.I query
parameter (HTTP GET).
.SAMPLE
$ curl -s http://localhost:44322/search/text?query=halt | pmjson
{
"total": 2,
"offset": 0,
"limit": 10,
"elapsed": 0.000504,
"results": [
{
"name": "kvm.halt_exits",
"type": "metric",
"indom": "95.0.4",
"oneline": "Number of guest exits due to halt calls.",
"helptext": "This type of exit is usually seen when a guest is idle."
},
{
"name": "kvm.halt_wakeup",
"type": "metric",
"indom": "95.0.6",
"oneline": "Number of wakeups from a halt.",
}
]
}
.ESAMPLE
.PP
The available search entity
.I types
are
.IR metric ,
.IR indom
and
.IR instance .
Query parameters
.IR highlight
and
.IR field
take
.IR name ,
.IR oneline
and
.IR helptext .
.PP
Query parameter
.IR return
takes
.IR name ,
.IR type ,
.IR oneline ,
.IR helptext ,
.IR indom .
There is typically both a name and help text associated with
metrics. Contents of these are then matched against
.IR query .
An instance domain has help text and a numeric identifier,
while instances have a name only (which can be searched).
.SS GET \fI/search/suggest\fR \- \fBpmSearchTextSuggest\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
query string Search query for search engine
limit number Max results to include in response
.TE
.PP
Provides search query suggestions, that is, metric and instance names.
.PP
The mandatory search string is further described in
.BR pmsearch (1)
and is passed to the server via the
.I query
parameter (HTTP GET).
.SAMPLE
$ curl -s http://localhost:44322/search/suggest?query=disk&limit=4 | pmjson
[
"disk.all.avactive",
"disk.all.aveq",
"disk.all.blkread",
"disk.all.blktotal"
]
.ESAMPLE
.SS GET \fI/search/indom\fR \- \fBpmSearchTextInDom\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
query string Target indom for search engine
offset number Result offset cursor for pagination
limit number M results to include in response
.TE
.PP
Provides all entities (instances, metrics) related to indom, including itself, that is passed to the server via the
.I query
parameter.
.SS GET \fI/search/info\fR \- \fBpmSearchInfo\fR(3)
Provides metrics relating to operation of the search engine,
in particular showing document and text record counts.
.SAMPLE
$ curl -s http://localhost:44322/search/info | pmjson
{
"docs": 1589,
"terms": 3855,
"records": 116831,
"records_per_doc_avg": 73.52,
"bytes_per_record_avg": 6.36,
"inverted_sz_mb": 0.71,
"inverted_cap_mb": 0.00,
"inverted_cap_ovh": 0.00,
"skip_index_size_mb": 0.00,
"score_index_size_mb": 0.00,
"offsets_per_term_avg": 9.41,
"offset_bits_per_record_avg": 8.00
}
.ESAMPLE
.SH PMAPI HOST SERVICES
The live performance collection facilities available from
.BR pmcd (1)
can also be accessed through a REST API.
.PP
All requests are performed on the web server host by default,
unless either a
.I hostspec
or
.I context
parameter is provided.
.I hostname
can be used in place of
.IR hostspec .
.PP
Context identifiers are used as a persistent way to refer to
PMAPI contexts across related web requests.
These contexts expire after a configurable period of disuse,
and are either explicitly allocated using the
.I /pmapi/context
interface, or implicitly allocated using other interfaces.
.PP
The timeout interval is configurable at context creation time,
and as such the
.I polltimeout
parameter can be used anywhere the
.I hostspec
is specified.
It sets the context timeout in terms of length of inactive time.
The unit for the timeout value is seconds and the default is 5.
.PP
To specify a specific existing context in any PMAPI web request,
the endpoints can be accessed with either the
.I context
parameter or embedded in the endpoint URL itself, such as
.BR /pmapi/[number]/fetch .
.SS GET \fI/pmapi/context\fR \- \fBpmNewContext\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
hostspec string T{
Host specification as described in \f(CBPCPIntro\fR(1)
T}
polltimeout number T{
Seconds of inactivity before closing context
T}
client string T{
Request identifier sent back with response
T}
.TE
.P
To create a context for live sampling, a web client can access any
.I /pmapi
URL (optionally using the
.I hostspec
or
.I context
parameter).
If no context exists, a new one will be created for that web
client, and its identifier returned for future accesses.
.PP
However,
.I /pmapi/context
is provided as a dedicated URL for applications wishing to
explicitly create the contexts they use.
.PP
If successful, the server responds with a HTTP 200 (OK) code
and JSON message body of the form:
.SAMPLE
$ curl -s http://localhost:44322/pmapi/context?hostspec=www.acme.com&polltimeout=0.5 | pmjson
{
"context": 348734,
"source": "05af7f3eb840277fd3cfa91f90ef0067199743c",
"hostspec": "www.acme.com",
"labels": {
"domainname": "acme.com",
"groupid": 1000,
"hostname": "www.acme.com",
"machineid": "295b7623b6074cc8bdbda8bf96f6930a"
"platform": "dev",
"userid": 1000
}
}
.ESAMPLE
.PP
The context (a 32-bit unsigned decimal number) can then be
used with all later requests.
.PP
In the case of a
.I hostspec
containing authentication information, such as a username,
the server will follow the HTTP Basic Authentication protocol
to ascertain necessary authentication details from the user,
providing the client web application an opportunity to request
these from the user.
.SS GET \fI/pmapi/metric\fR \- \fBpmLookupDesc\fR(3), \fBpmLookupLabels\fR(3), \fBpmLookupName\fR(3), \fBpmLookupText\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
name string T{
An individual metric name
T}
names string T{
Comma-separated list of metric names
T}
pmid pmID T{
Numeric or \f(CBpmIDStr\fR(3) metric identifier
T}
pmids string T{
Comma-separated numeric or \f(CBpmIDStr\fR(3) pmIDs
T}
prefix string T{
Metric namespace component as in \f(CBPMNS\fR(5)
T}
_
hostspec string T{
Host specification as described in \f(CBPCPIntro\fR(1)
T}
context number T{
Web context number (optional like hostspec)
T}
polltimeout number T{
Seconds of inactivity before context closed
T}
client string T{
Request identifier sent back with response
T}
.TE
.P
The
.I metric
endpoint provides detailed PMAPI metric metadata for one or
more metrics.
If no parameters are supplied, the response will be for all
metrics found when traversing the entire Performance Metrics
Name Space (PMNS).
.PP
The
.I prefix
parameter can be used to specify a subtree of the PMNS for
traversal.
Alternatively, a specific metric or comma-separated list of
metrics can be specified using either
.I name
or
.I names
.PP
The server response is a JSON document that provides metric
metadata as an array.
.SAMPLE
$ curl -s http://localhost:44322/pmapi/metric?names=kernel.all.load,disk.all.read | pmjson
{
"context": 348734,
"metrics": [
{
"name": "kernel.all.load",
"pmid": "60.2.0",
"indom": "60.2",
"type": "FLOAT",
"sem": "instant",
"units": "none",
"series": "d2b28c7f6dc0d69ffd21dba7ba955e78c37719b",
"source": "05af7f3eb840277fd3cfa91f90ef0067199743c",
"labels": {
"agent": "linux",
"domainname": "acme.com",
"groupid": 1000,
"hostname": "www.acme.com",
"platform": "dev",
"userid": 1000
},
"text-oneline": "1, 5 and 15 minute load average"
},
{
"name": "disk.all.read",
"pmid": "60.0.24",
"type": "U64",
"sem": "counter",
"units": "count",
"series": "d2b28c7f6dc0d69ffd21dba7ba955e78c37719b",
"source": "05af7f3eb840277fd3cfa91f90ef0067199743c",
"labels": {
"agent": "linux",
"domainname": "acme.com",
"groupid": 1000,
"hostname": "www.acme.com",
"platform": "dev",
"userid": 1000
},
"text-oneline": "total read operations, summed for all disks",
"text-help": "Cumulative number of disk read operations [...]"
}
]
}
.ESAMPLE
Most of the fields are directly transcribed from the PMAPI calls
for metric descriptors, labels and help text mentioned above and
are exactly as would be observed using the
.BR pminfo (1)
command with the \-\fBdlmstT\fR options.
.PP
The semantics, type and units fields are as returned by
.BR pmTypeStr (3),
.BR pmUnitsStr (3)
and
.BR pmSemStr (3).
.SS GET \fI/pmapi/fetch\fR \- \fBpmFetch\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
delta string T{
Sampling interval in \f(CBpmParseInterval\fR(3) form
T}
name string T{
An individual metric name
T}
names string T{
Comma-separated list of metric names
T}
pmid pmID T{
Numeric or \f(CBpmIDStr\fR(3) metric identifier
T}
pmids string T{
Comma-separated numeric or \f(CBpmIDStr\fR(3) pmIDs
T}
_
hostspec string T{
Host specification as described in \f(CBPCPIntro\fR(1)
T}
context number T{
Web context number (optional like hostspec)
T}
polltimeout number T{
Seconds of inactivity before context closed
T}
client string T{
Request identifier sent back with response
T}
.TE
.P
This request fetches (samples) current values for given metrics.
.PP
If any of the names or pmids provided are valid, the response is a JSON
document that provides the values for all instances of the metrics, unless
a instance profile has been set for the web context (see section on InDom
profiles below).
.SAMPLE
$ curl -s http://localhost:44322/pmapi/fetch?names=kernel.all.load,disk.all.read | pmjson
{
"context": 348734,
"timestamp": 1547483646.2147431,
"values": [
{
"pmid": "60.2.0",
"name": "kernel.all.load",
"instances:" [
{ "instance": 1, "value": 0.1 },
{ "instance": 5, "value": 0.17 },
{ "instance": 15, "value": 0.22 }
]
},
{
"pmid":"60.0.24",
"name":"disk.all.read",
"instances:" [
{ "instance": null, "value": 639231 }
]
}
]
}
.ESAMPLE
The response fields map directly to fields from the underlying
.BR pmFetch (3)
sampling interface.
.PP
Numeric metric types are represented as JSON integer or floating-point
values.
Strings are passed verbatim, except that non-ASCII values are replaced
with a Unicode 0xFFFD replacement character code.
.PP
In backward compatibility mode the timestamp is presented as a JSON
map with second (sec) and microsecond (us) fields, instead of using
the more compact floating point representation shown above.
.SS GET \fI/pmapi/children\fR \- \fBpmGetChildren\fR(3), \fBpmGetChildrenStatus\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
prefix string T{
Metric namespace component as in \f(CBPMNS\fR(5)
T}
_
hostspec string T{
Host specification as described in \f(CBPCPIntro\fR(1)
T}
context number T{
Web context number (optional like hostspec)
T}
polltimeout number T{
Seconds of inactivity before context closed
T}
client string T{
Request identifier sent back with response
T}
.TE
.P
The
.I children
endpoint provides iterative namespace traversal for a context.
If no parameters are supplied, the response will describe the
direct descendants of the Performance Metrics Name Space (PMNS) root.
.PP
The
.I prefix
parameter can be used to specify a subtree of the PMNS for
traversal.
.PP
The server response is a JSON document that provides the set
of leaf and non-leaf nodes below the given namespace node or
root.
.SAMPLE
$ curl -s http://localhost:44322/pmapi/children?prefix=mem | pmjson
{
"context": 348734,
"name": "mem",
"leaf": [
"physmem",
"freemem"
],
"nonleaf": [
"util",
"numa",
"vmstat",
"buddyinfo",
"slabinfo",
"zoneinfo",
"ksm"
]
}
.ESAMPLE
.SS GET \fI/pmapi/indom\fR \- \fBpmGetInDom\fR(3), \fBpmNameInDom\fR(3), \fBpmLookupInDom\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
iname string T{
Comma-separated list of instance names
T}
indom pmInDom T{
Numeric or \f(CBpmInDomStr\fR(3) instance domain
T}
instance number T{
Comma-separated list of instance numbers
T}
match string T{
Pattern matching style (exact, glob or regex)
T}
name string T{
An individual metric name
T}
_
hostspec string T{
Host specification as described in \f(CBPCPIntro\fR(1)
T}
context number T{
Web context number (optional like hostspec)
T}
polltimeout number T{
Seconds of inactivity before context closed
T}
client string T{
Request identifier sent back with response
T}
.TE
.P
This request lists the current instances of an instance domain.
The instance domain is either specified directly (in numeric or
string form) or indirectly, by association with the specified
metric.
.PP
The request can be further qualified with a comma-separated list
of the instances to report on, either by name or number, using the
.I instance
and
.I iname
parameters.
.PP
In the case of instance name qualifiers, these will be matched by
exact string comparison by default.
Alternatively, the match parameter can be used to specify that
regular expression or glob pattern matching should be used instead.
.PP
The response is a JSON document that provides the instance domain
metadata as an array.
.SAMPLE
$ curl -s http://localhost:44322/pmapi/indom?name=kernel.all.load | pmjson
{
"context": 348734,
"indom": "60.2",
"labels": {
"domainname": "acme.com",
"groupid": 1000,
"hostname": "www.acme.com",
"machineid": "295b7623b6074cc8bdbda8bf96f6930a"
"platform": "dev",
"userid": 1000
},
"instances": [
{
"instance": 1,
"name": "1 minute"
"labels": { ... },
},
{
"instance": 5,
"name": "5 minute"
"labels": { ... },
},
{
"instance": 15,
"name": "15 minute"
"labels": { ... },
}
]
}
.ESAMPLE
.SS GET \fI/pmapi/profile\fR \- \fBpmAddProfile\fR(3), \fBpmDelProfile\fR(3)
.TS
box,center;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
iname string T{
Comma-separated list of instance names
T}
indom pmInDom T{
Numeric or \f(CBpmInDomStr\fR(3) instance domain
T}
instance number T{
Comma-separated list of instance numbers
T}
expr string T{
One of "add" or "del" (mandatory).
T}
match string T{
Pattern matching style (exact, glob or regex)
T}
_
hostspec string T{
Host specification as described in \f(CBPCPIntro\fR(1)
T}
context number T{
Web context number (optional like hostspec)
T}
polltimeout number T{
Seconds of inactivity before context closed
T}
client string T{
Request identifier sent back with response
T}
.TE
.P
Some PMAPI operations can be performed with an active instance
domain profile which restricts (filters) the set of resulting
instances returned, as described on
.BR pmAddProfile (3).
.SAMPLE
$ curl -s http://localhost:44322/pmapi/profile?expr=add,indom=60.2,iname=1%20minute
{ "context": 348734, "success": true }
.ESAMPLE
.SS GET \fI/pmapi/store\fR \- \fBpmStore\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
iname string Comma-separated list of instance names
instance number Comma-separated list of instance numbers
name string An individual metric name
value (any) New value for the given metric instance(s)
_
hostspec string T{
Host specification as described in \f(CBPCPIntro\fR(1)
T}
context number T{
Web context number (optional like hostspec)
T}
polltimeout number T{
Seconds of inactivity before context closed
T}
client string T{
Request identifier sent back with response
T}
.TE
.P
Some performance metrics allow their value to be modified,
for example to re-initialize counters or to modify control
variables.
.PP
This operation takes a single metric
.I name
to modify, and optionally
specific
.IR instance s.
The mandatory
.I value
will be interpreted according to the type of the metric
being modified.
.PP
If successful, the response from these requests is a JSON document of the form:
.SAMPLE
$ curl -s http://localhost:44322/pmapi/store?name=pmcd.control.timeout&value=10
{
"context": 348734,
"success": true
}
.ESAMPLE
.SS GET \fI/pmapi/derive\fR: \fBpmAddDerived\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
expr string Derived metric expression
name string New derived metric name
_
hostspec string T{
Host specification as described in \f(CBPCPIntro\fR(1)
T}
context number T{
Web context number (optional like hostspec)
T}
polltimeout number T{
Seconds of inactivity before context closed
T}
client string T{
Request identifier sent back with response
T}
.TE
.P
Create a new derived metric, as defined by the
.BR pmAddDerived (3)
metric interface.
Derived metrics are associated with the named context, or a new
context is created and returned in the result.
.PP
This interface is one of the few that allows a POST to be used
in place of a GET.
In this case the HTTP POST request body may be used to provide
one or more derived metrics specifications (all at once, across
multiple lines, as a convenience).
.SAMPLE
$ curl -s http://localhost:44322/pmapi/derive?name=blkio.avgsz&expr=disk.all.blktotal/disk.all.total | pmjson
{
"context": 348734,
"success": true
}
$ curl -s http://localhost:44322/pmapi/fetch?name=blkio.avgsz&samples=2 | pmjson
{
"context": 348734,
"timestamp": 1547483648.2147428,
"values": [
{
"pmid": "511.0.27",
"name": "blkio.avgsz",
"instances:" [
{
"instance": null,
"value": 9231
}
]
}
]
}
.ESAMPLE
.SS GET \fI/pmapi/metrics\fR: \fBpmLookupDesc\fR(3),\fBpmLookupLabels\fR(3), \fBpmFetch\fR(3)
.TS
box;
c | c | cw(2.4i)
lf(CR) | l | l.
Parameters Type Explanation
_
names string T{
Comma-separated list of metric names
T}
times boolean T{
Append sample times (milliseconds since epoch)
T}
_
context number T{
Web context number (optional like hostspec)
T}
hostspec string T{
Host specification as described in \f(CBPCPIntro\fR(1)
T}
polltimeout number T{
Seconds of inactivity before context closed
T}
client string T{
Request identifier sent back with response
T}
.TE
.P
This request is a subset of the style described in the
``OPEN METRICS AND OPEN TELEMETRY'' section, allowing a web
context identifier to be passed as a parameter.
It is otherwise very similar in terms of parameters
and response handling, please refer to the earlier section
for details.
.SH ARCHIVE WEBHOOK \- \fBLOGARCHIVE\fR(5)
Remote archive push functionality is available via the
.BR pmlogger (1)
and
.BR pmlogpush (1)
utilities.
This is achieved through a series of HTTP POST operations to
the API endpoints described here.
.PP
All requests in this group can be accompanied by an optional
.IR client
parameter.
The value passed in the request will be sent back in the
response \- all responses are in JSON object form and will
include an additional top level "client" field.
.SS GET \fI/logger/ping\fR
Basic liveness test for clients to check whether the server is up
and supports the \fI/logger\fR API.
.SS POST \fI/logger/label\fR
The body of this API is the machine-agnostic binary (on-disk)
representation of a PCP archive label as described in
.BR LOGARCHIVE (5).
Either version 2 and 3 are accepted, and the
.I volume
field of this stucture will be ignored \- one API call suffices
for all of the volumes of an archive,
.B pmproxy
ensures correct content is written for each.
.P
This API returns a numeric token (LOGID) that must be used in all
subsequent API interactions for this archive as described below.
.SS POST \fI/logger/meta/LOGID\fR
The request body contains metadata file records as described in
.BR LOGARCHIVE .
.SS POST \fI/logger/index/LOGID\fR
The request body contains temporal index records as described in
.BR LOGARCHIVE .
.SS POST \fI/logger/volume/VOLID/LOGID\fR
The request body contains timestamped metric value samples, as
described in
.BR LOGARCHIVE .
The numeric volume (VOLID) to which these records is to be
written is a mandatory part of the API endpoint.
.SH NOTES
For the REST APIs, errors generally result in HTTP-level
error responses.
Wherever possible, any PMAPI error string will also be
provided in a message along with the response.
.PP
All responses will be returned using HTTP 1.1 protocol and
with chunked encoding being used to stream responses that
are larger than a configured maximum size.
Compression will be used on responses whenever the client
indicates appropriate support.
.PP
An
.nh
.I Access-Control-Allow-Origin: *
.hy
header is added to all REST API responses.
.SH SEE ALSO
.BR PCPIntro (1),
.BR curl (1),
.BR pmcd (1),
.BR pmdaopenmetrics (1),
.BR pminfo (1),
.BR pmjson (1),
.BR pmlogger (1),
.BR pmlogpush (1),
.BR pmproxy (1),
.BR pmseries (1),
.BR PCPIntro (3),
.BR PMAPI (3)
and
.BR LOGARCHIVE (5)
.\" control lines for scripts/man-spell
.\" +ok+ offset_bits_per_record_avg kernel_pernode_cpu_intr
.\" +ok+ offsets_per_term_avg bytes_per_record_avg score_index_size_mb
.\" +ok+ records_per_doc_avg skip_index_size_mb filesys_blocksize
.\" +ok+ inverted_cap_ovh inverted_cap_mb inverted_sz_mb halt_wakeup
.\" +ok+ polltimeout proc_nprocs halt_exits read_bytes read_merge ValkeySearch
.\" +ok+ domainname appversion prometheus machineid blocksize
.\" +ok+ buddyinfo cebcbadc helptext slabinfo blktotal instname
.\" +ok+ hostspec avactive wakeups pernode physmem filesys blkread oneline
.\" +ok+ nonleaf freemem groupid pswitch dlmstT vmstat nprocs userid bdbda
.\" +ok+ descs xFFFD linux blkio pmIDs iname jobid avgsz ddff desc intr numa
.\" +ok+ aveq aac cae nas dba fbe bda sda sdb def del sem cfa dfa ffd bfe
.\" +ok+ api app ksm kvm ba ca da bb eb fb ac dc fc dd fd ce af bf ef
|