1PMWEBAPI(3)                Library Functions Manual                PMWEBAPI(3)
2
3
4

NAME

6       PMWEBAPI - introduction to the Performance Metrics Web Application Pro‐
7       gramming Interface
8

HTTP SYNOPSIS

10       GET /metrics
11       GET /series/...
12       GET /search/...
13       GET /pmapi/...
14

C SYNOPSIS

16       #include <pcp/pmwebapi.h>
17
18        ... assorted routines ...
19
20       cc ... -lpcp_web -lpcp
21

DESCRIPTION

23       The PMWEBAPI is a collection of interfaces  providing  Performance  Co-
24       Pilot  services  for  web  applications.   It  consists of APIs for web
25       applications querying and analysing both live  and  historical  perfor‐
26       mance data, as well as APIs used by web servers.
27
28       The  usual HTTP URL-encoded optional parameter rules apply and PMWEBAPI
29       REST requests always follow the convention:
30
31       /api/endpoint?parameter1=value1&parameter2=value2
32
33       Examples in all following sections use the curl(1) command line utility
34       with  a local pmproxy(1) server listening on port 44322 (default port).
35       The pmjson(1) utility is used to neatly  format  any  JSON  output,  as
36       opposed  to  the compact (minimal whitespace) form provided by default.
37       The examples in the scalable time series section  use  historical  data
38       recorded by the pmlogger(1) service, in conjunction with a local redis-
39       server(1).
40

OPEN METRICS

42       Exporting of live performance metrics in  an  Open  Metrics  compatible
43       format  (as  described at https://openmetrics.io and popularized by the
44       https://prometheus.io project) is available.
45
46   GET /metrics
47       ┌───────────┬─────────┬────────────────────────────────────────────────┐
48       │Parameters │  Type   │                  Explanation                   │
49       ├───────────┼─────────┼────────────────────────────────────────────────┤
50       │names      │ string  │ Comma-separated list of metric names           │
51       │times      │ boolean │ Append sample times (milliseconds since epoch) │
52       └───────────┴─────────┴────────────────────────────────────────────────┘
53       Fetches current values and metadata for all metrics,  or  only  metrics
54       indicated by a comma-separated list of names.
55
56       For  all  numeric  metrics with the given NAME prefixes, create an Open
57       Metrics (Prometheus) text export format giving their current value  and
58       related metadata.
59
60       The  response  has plain text type rather than JSON commonly used else‐
61       where in the REST API.  This format can be injested by many open source
62       monitoring tools, including Prometheus and pmdaopenmetrics(1).
63
64       The native PCP metric metadata (metric name, type, indom, semantics and
65       units) is first output for each metric with # PCP prefix.  The metadata
66       reported  is  of  the  form  described  on pmTypeStr(3), pmInDomStr(3),
67       pmSemStr(3) and pmUnitsStr(3) respectively.  If the pmUnitsStr(3) units
68       string  is  empty,  then none is output.  The units metadata string may
69       contain spaces and extends to the end of the line.
70
71       PCP metric names are mapped so that the . separators are exchanged with
72       _  (':'  in  back-compatibility  mode, where "# PCP" is the identifying
73       line suffix).  Both metric labels  and  instances  are  represented  as
74       Prometheus  labels,  with  external instance names being quoted and the
75       flattened PCP metric hierarchy being presented with each value.
76
77         $ curl -s http://localhost:44322/metrics?names=proc.nprocs,kernel.pernode.cpu.intr,filesys.blocksize
78
79         # PCP5 proc.nprocs 3.8.99 u32 PM_INDOM_NULL instant none
80         # HELP proc_nprocs instantaneous number of processes
81         # TYPE proc_nprocs gauge
82         proc_nprocs {hostname="app1"} 7
83
84         # PCP5 kernel.pernode.cpu.intr 60.0.66 u64 60.19 counter millisec
85         # HELP kernel_pernode_cpu_intr total interrupt CPU [...]
86         # TYPE kernel_pernode_cpu_intr counter
87         kernel_pernode_cpu_intr{hostname="app1",instname="node0"} 25603
88
89         # PCP5 filesys.blocksize 60.5.9 u32 60.5 instant byte
90         # HELP filesys_blocksize Size of each block on mounted file[...]
91         # TYPE filesys_blocksize gauge
92         filesys_blocksize{hostname="app1",instname="/dev/sda1"} 4096
93         filesys_blocksize{hostname="app1",instname="/dev/sda2"} 4096
94

SCALABLE TIME SERIES

96       The fast, scalable time series query capabilities provided by  the  pm‐
97       series(1) command are also available through a REST API.  These queries
98       provide access to performance data (metric metadata  and  values)  from
99       multiple hosts simultaneously, and in a fashion suited to efficient re‐
100       trieval by any number of web applications.
101
102       All requests in this group can be accompanied by an optional client pa‐
103       rameter.   The value passed in the request will be sent back in the re‐
104       sponse - all responses will be in JSON object form in this  case,  with
105       top level "client" and "result" fields.
106
107   GET /series/query - pmSeriesQuery(3)
108       ┌───────────┬────────┬────────────────────────────────────────────┐
109       │Parameters │  Type  │                Explanation                 │
110       ├───────────┼────────┼────────────────────────────────────────────┤
111       │expr       │ string │ Query string in pmseries(1) format         │
112       │client     │ string │ Request identifier sent back with response │
113       └───────────┴────────┴────────────────────────────────────────────┘
114       Performs a time series query for either matching identifiers, or match‐
115       ing identifiers with series of time-stamped values.
116
117       The query is in the format described in pmseries(1) and  is  passed  to
118       the  server via either the expr parameter (HTTP GET) or via the message
119       body (HTTP POST).
120
121       When querying for time series matches only, no time window options  are
122       specified and matching series identifiers are returned in a JSON array.
123
124         $ curl -s 'http://localhost:44322/series/query?expr=disk.dev.read*' | pmjson
125         [
126           "9d8c7fb51ce160eb82e3669aac74ba675dfa8900",
127           "ddff1bfe286a3b18cebcbadc1678a68a964fbe9d",
128           "605fc77742cd0317597291329561ac4e50c0dd12"
129         ]
130
131       When  querying  for  time  series values as well, a time window must be
132       specified as part of the query string.  The simplest form  is  to  just
133       request the most recent sample.
134
135         $ curl -s 'http://localhost:44322/series/query?expr=disk.dev.read*[samples:1]' | pmjson
136         [
137           {
138             "series": "9d8c7fb51ce160eb82e3669aac74ba675dfa8900",
139             "instance": "c3795d8b757506a2901c6b08b489ba56cae7f0d4",
140             "timestamp": 1547483646.2147431,
141             "value": "12499"
142           }, {
143             "series": "ddff1bfe286a3b18cebcbadc1678a68a964fbe9d",
144             "instance": "6b08b489ba56cae7f0d4c3795d8b757506a2901c",
145             "timestamp": 1547485701.7431218,
146             "value": "1118623"
147           }, {
148             "series": "605fc77742cd0317597291329561ac4e50c0dd12",
149             "instance": "c3795d8b757506a2901c6b08b489ba56cae7f0d4",
150             "timestamp": 1547483646.2147431,
151             "value": "71661"
152           }
153         ]
154
155   GET /series/values - pmSeriesValues(3)
156       ┌───────────┬────────┬────────────────────────────────────────────┐
157       │Parameters │  Type  │                Explanation                 │
158       ├───────────┼────────┼────────────────────────────────────────────┤
159       │series     │ string │ Comma-separated list of series identifiers │
160       │client     │ string │ Request identifier sent back with response │
161       ├───────────┼────────┼────────────────────────────────────────────┤
162       │samples    │ number │ Count of samples to return                 │
163       │interval   │ string │ Time between successive samples            │
164       │start      │ string │ Sample window start time                   │
165       │finish     │ string │ Sample window end time                     │
166       │offset     │ string │ Sample window offset                       │
167       │align      │ string │ Sample time alignment                      │
168       │zone       │ string │ Time window timezone                       │
169       └───────────┴────────┴────────────────────────────────────────────┘
170       Performs  values  retrievals  for  one or more time series identifiers.
171       The JSON  response  contains  the  same  information  as  the  pmseries
172       -q/--query  option using any of the time window parameters described on
173       pmseries(1).  If no time window parameters are  specified,  the  single
174       most recent value observed is retrieved.
175
176         $ curl -s http://localhost:44322/series/values?series=605fc77742cd0317597291329561ac4e50c0dd12 | pmjson
177         [
178           {
179             "series": "605fc77742cd0317597291329561ac4e50c0dd12",
180             "timestamp": 1317633022959.959241041,
181             "value": "71660"
182           }
183         ]
184
185   GET /series/descs - pmSeriesDescs(3)
186       ┌───────────┬────────┬────────────────────────────────────────────┐
187       │Parameters │  Type  │                Explanation                 │
188       ├───────────┼────────┼────────────────────────────────────────────┤
189       │series     │ string │ Comma-separated list of series identifiers │
190       │client     │ string │ Request identifier sent back with response │
191       └───────────┴────────┴────────────────────────────────────────────┘
192       Performs  a  descriptor lookup for one or more time series identifiers.
193       The JSON  response  contains  the  same  information  as  the  pmseries
194       -d/--desc option.
195
196         $ curl -s http://localhost:44322/series/descs?series=605fc77742cd0317597291329561ac4e50c0dd12 | pmjson
197         [
198           {
199             "series": "605fc77742cd0317597291329561ac4e50c0dd12",
200             "source": "f5ca7481da8c038325d15612bb1c6473ce1ef16f",
201             "pmid": "60.0.4",
202             "indom": "60.1",
203             "semantics": "counter",
204             "type": "u32",
205             "units": "count",
206           }
207         ]
208
209   GET /series/labels - pmSeriesLabels(3), pmSeriesLabelValues(3)
210       ┌───────────┬────────┬────────────────────────────────────────────┐
211       │Parameters │  Type  │                Explanation                 │
212       ├───────────┼────────┼────────────────────────────────────────────┤
213       │series     │ string │ Comma-separated list of series identifiers │
214       │match      │ string │ Glob pattern string to match on all labels │
215       │name       │ string │ Find all known label values for given name │
216       │names      │ string │ Comma-separated list of label names        │
217       │client     │ string │ Request identifier sent back with response │
218       └───────────┴────────┴────────────────────────────────────────────┘
219       This  command  operates  in one of three modes.  It can perform a label
220       set lookup for one or more time  series  identifiers,  when  given  the
221       series  parameter).  It can produce a list of all known label names, in
222       the absence of name, names or series parameters.   The  JSON  responses
223       for   these  modes  contains  the  same  information  as  the  pmseries
224       -l/--labels option.
225
226       Alternatively, it can produce a list of all known label  values  for  a
227       given  label  name  or names.  The JSON response for this mode contains
228       the same information as the pmseries -v/--values option.
229
230         $ curl -s http://localhost:44322/series/labels?series=605fc77742cd0317597291329561ac4e50c0dd12 | pmjson
231         [
232           {
233             "series": "605fc77742cd0317597291329561ac4e50c0dd12",
234             "labels": {
235               "agent": "linux",
236               "domainname": "acme.com",
237               "groupid": 1000,
238               "hostname": "www.acme.com",
239               "latitude": -25.28496,
240               "longitude": 152.87886,
241               "machineid": "295b16e3b6074cc8bdbda8bf96f6930a",
242               "platform": "dev",
243               "userid": 1000
244             }
245           }
246         ]
247
248       Alternatively, with no name, names or  series  parameters,  return  the
249       list of all known label names.
250
251         $ curl -s http://localhost:44322/series/labels | pmjson
252         [
253             "agent",
254             "appversion",
255             "domainname",
256             "groupid",
257             "hostname",
258             "jobid",
259             "latitude",
260             "longitude",
261             "machineid",
262             "platform",
263             "userid"
264         ]
265
266       Use  the name or names parameters to find all possible label values for
267       the given name(s).
268
269         $ curl -s http://localhost:44322/series/labels?names=hostname,domainname | pmjson
270         {
271             "hostname": [ "app", "nas" ],
272             "domainname": [ "acme.com" ]
273         }
274
275   GET /series/metrics - pmSeriesMetrics(3)
276       ┌───────────┬────────┬────────────────────────────────────────────┐
277       │Parameters │  Type  │                Explanation                 │
278       ├───────────┼────────┼────────────────────────────────────────────┤
279       │series     │ string │ Comma-separated list of series identifiers │
280       │match      │ string │ Glob pattern string to match on all names  │
281       │client     │ string │ Request identifier sent back with response │
282       └───────────┴────────┴────────────────────────────────────────────┘
283       Performs a metric name lookup for one or more time series  identifiers.
284       The  JSON  response  contains  the  same  information  as  the pmseries
285       -m/--metrics option.
286
287         $ curl -s http://localhost:44322/series/metrics?series=605fc77742cd0317597291329561ac4e50c0dd12 | pmjson
288         [
289           {
290             "series": "605fc77742cd0317597291329561ac4e50c0dd12",
291             "name": "disk.dev.read_bytes"
292           }
293         ]
294
295       Alternatively, with no series argument, this request  will  return  the
296       list of all known metric names.
297
298         $ curl -s http://localhost:44322/series/metrics | pmjson
299         [
300             "disk.dev.read",
301             "disk.dev.read_bytes",
302             "disk.dev.read_merge",
303             "kernel.all.load",
304             "kernel.all.pswitch",
305             ...
306         ]
307
308   GET /series/sources - pmSeriesSources(3)
309       ┌───────────┬────────┬─────────────────────────────────────────────┐
310       │Parameters │  Type  │                 Explanation                 │
311       ├───────────┼────────┼─────────────────────────────────────────────┤
312       │series     │ string │ Comma-separated list of source identifiers  │
313       │match      │ string │ Glob pattern string to match on all sources │
314       │client     │ string │ Request identifier sent back with response  │
315       └───────────┴────────┴─────────────────────────────────────────────┘
316       Performs a lookup for one or more time series sources, returning an ar‐
317       ray of all PMAPI context names used to access the time series from that
318       source.   The  JSON  response  contains the same information as the pm‐
319       series -S/--source option.
320
321         $ curl -s http://localhost:44322/series/sources?source=2cd6a38f9339f2dd1f0b4775bda89a9e7244def6 | pmjson
322         [
323           {
324             "source": "2cd6a38f9339f2dd1f0b4775bda89a9e7244def6",
325             "context": [
326               "/var/log/pcp/pmlogger/acme",
327               "www.acme.com"
328             ]
329           }
330         ]
331
332   GET /series/instances - pmSeriesInstances(3)
333       ┌───────────┬────────┬───────────────────────────────────────────────┐
334       │Parameters │  Type  │                  Explanation                  │
335       ├───────────┼────────┼───────────────────────────────────────────────┤
336       │series     │ string │ Comma-separated list of series identifiers    │
337       │match      │ string │ Glob pattern string to match on all instances │
338       │client     │ string │ Request identifier sent back with response    │
339       └───────────┴────────┴───────────────────────────────────────────────┘
340       Provide instance identifiers and names for  one  or  more  time  series
341       identifiers.   The  JSON  response contains the same information as the
342       pmseries -i/--instance option.
343
344         $ curl -s http://localhost:44322/series/instances?series=605fc77742cd0317597291329561ac4e50c0dd12 | pmjson
345         [
346           {
347             "series": "605fc77742cd0317597291329561ac4e50c0dd12",
348             "source": "97261ac7742cd4e50c0d03175913295d12605fc7",
349             "instance": "c3795d8b757506a2901c6b08b489ba56cae7f0d4"
350             "id": 1,
351             "name": "sda",
352           }, {
353             "series": "605fc77742cd0317597291329561ac4e50c0dd12",
354             "source": "97261ac7742cd4e50c0d03175913295d12605fc7",
355             "instance": "57506a2901c6b08b489ba56cae7f0d4c3795d8b7"
356             "id": 2,
357             "name": "sdb",
358           }
359         ]
360
361       Alternatively, with no series argument, this request  will  return  the
362       list of all known instance names.
363
364         $ curl -s http://localhost:44322/series/instances | pmjson
365         [
366             "1 minute",
367             "5 minute",
368             "15 minute",
369             "cpu0",
370             "cpu1",
371             "cpu2",
372             "cpu3",
373             "node0",
374             "node1",
375             "sda",
376             "sdb",
377             ...
378         ]
379
380   GET /series/load - pmSeriesLoad(3)
381       ┌───────────┬────────┬────────────────────────────────────────────┐
382       │Parameters │  Type  │                Explanation                 │
383       ├───────────┼────────┼────────────────────────────────────────────┤
384       │expr       │ string │ Source load string in pmseries(1) format   │
385       │client     │ string │ Request identifier sent back with response │
386       └───────────┴────────┴────────────────────────────────────────────┘
387       Load  time  series  performance data from the specified source into the
388       redis-server  cache.   This  request  is  equivalent  to  the  pmseries
389       -l/--load option.
390
391         $ curl -s http://localhost:44322/series/load?expr={source.name:"/var/log/pcp/pmlogger/acme"}
392         {
393           "success": true
394         }
395
397       The  full  text search capabilities provided by the pmsearch(1) command
398       are also available through a REST API.  These queries provide access to
399       an index over performance metric names, instances, instance domains and
400       help text, suitable for a metric search engine, and in a fashion suited
401       to efficient querying by any number of web applications.
402
403       In order to use this functionality, the optional RediSearch module must
404       be loaded in the redis-server at the time pmproxy is started, such that
405       metrics,  instances and help text it discovers can be automatically in‐
406       dexed.
407
408
409   GET /search/text - pmSearchTextQuery(3)
410       ┌───────────┬────────┬─────────────────────────────────────────────┐
411       │Parameters │  Type  │                 Explanation                 │
412       ├───────────┼────────┼─────────────────────────────────────────────┤
413       │query      │ string │ Query string in pmsearch(1) format          │
414       │highlight  │ fields │ Include matching markup in response fields  │
415       │offset     │ number │ Result offset cursor for pagination         │
416       │limit      │ number │ Maximum results to include in response      │
417       │field      │ fields │ Queried fields (defaults to all)            │
418       │return     │ fields │ Fields to actually return (defaults to all) │
419       │type       │ types  │ Entity types to filter (defaults to all)    │
420       └───────────┴────────┴─────────────────────────────────────────────┘
421       Performs a text search query across metrics and instance domains -  all
422       forms of names and help texts.
423
424       The  mandatory search string is further described in pmsearch(1) and is
425       passed to the server via the query parameter (HTTP GET).
426
427         $ curl -s http://localhost:44322/search/text?query=halt | pmjson
428         {
429           "total": 2,
430           "offset": 0,
431           "limit": 10,
432           "elapsed": 0.000504,
433           "results": [
434             {
435               "name": "kvm.halt_exits",
436               "type": "metric",
437               "indom": "95.0.4",
438               "oneline": "Number of guest exits due to halt calls.",
439               "helptext": "This type of exit is usually seen when a guest is idle."
440             },
441             {
442               "name": "kvm.halt_wakeup",
443               "type": "metric",
444               "indom": "95.0.6",
445               "oneline": "Number of wakeups from a halt.",
446             }
447           ]
448         }
449
450       The available search entity  types  are  metric,  indom  and  instance.
451       Query parameters highlight and field take name, oneline and helptext.
452
453       Query  parameter  return  takes  name,  type, oneline, helptext, indom.
454       There is typically both a name and help text associated  with  metrics.
455       Contents  of  these are then matched against query.  An instance domain
456       has help text and a numeric identifier, while instances have a name on‐
457       ly (which can be searched).
458
459   GET /search/suggest - pmSearchTextSuggest(3)
460       ┌───────────┬────────┬────────────────────────────────────┐
461       │Parameters │  Type  │            Explanation             │
462       ├───────────┼────────┼────────────────────────────────────┤
463       │query      │ string │ Search query for search engine     │
464       │limit      │ number │ Max results to include in response │
465       └───────────┴────────┴────────────────────────────────────┘
466       Provides search query suggestions, that is, metric and instance names.
467
468       The  mandatory search string is further described in pmsearch(1) and is
469       passed to the server via the query parameter (HTTP GET).
470
471         $ curl -s http://localhost:44322/search/suggest?query=disk&limit=4 | pmjson
472         [
473             "disk.all.avactive",
474             "disk.all.aveq",
475             "disk.all.blkread",
476             "disk.all.blktotal"
477         ]
478
479   GET /search/indom - pmSearchTextInDom(3)
480       ┌───────────┬────────┬─────────────────────────────────────┐
481       │Parameters │  Type  │             Explanation             │
482       ├───────────┼────────┼─────────────────────────────────────┤
483       │query      │ string │ Target indom for search engine      │
484       │offset     │ number │ Result offset cursor for pagination │
485       │limit      │ number │ M results to include in response    │
486       └───────────┴────────┴─────────────────────────────────────┘
487       Provides all entities (instances, metrics) related to indom,  including
488       itself, that is passed to the server via the query parameter.
489
490   GET /search/info - pmSearchInfo(3)
491       Provides metrics relating to operation of the search engine, in partic‐
492       ular showing document and text record counts.
493
494         $ curl -s http://localhost:44322/search/info | pmjson
495         {
496             "docs": 1589,
497             "terms": 3855,
498             "records": 116831,
499             "records_per_doc_avg": 73.52,
500             "bytes_per_record_avg": 6.36,
501             "inverted_sz_mb": 0.71,
502             "inverted_cap_mb": 0.00,
503             "inverted_cap_ovh": 0.00,
504             "skip_index_size_mb": 0.00,
505             "score_index_size_mb": 0.00,
506             "offsets_per_term_avg": 9.41,
507             "offset_bits_per_record_avg": 8.00
508         }
509

PMAPI HOST SERVICES

511       The live performance collection facilities available from  pmcd(1)  can
512       also be accessed through a REST API.
513
514       All  requests  are  performed on the web server host by default, unless
515       either a hostspec or context parameter is provided.   hostname  can  be
516       used in place of hostspec.
517
518       Context identifiers are used as a persistent way to refer to PMAPI con‐
519       texts across related web requests.  These contexts expire after a  con‐
520       figurable  period  of disuse, and are either explicitly allocated using
521       the /pmapi/context interface, or implicitly allocated using  other  in‐
522       terfaces.
523
524       The  timeout  interval is configurable at context creation time, and as
525       such the polltime parameter can be used anywhere the hostspec is speci‐
526       fied.  It sets the context timeout in terms of length of inactive time.
527       The unit for the timeout value is seconds and the default is 5.
528
529       To specify a specific existing context in any PMAPI  web  request,  the
530       endpoints can be accessed with either the context parameter or embedded
531       in the endpoint URL itself, such as /pmapi/[number]/fetch.
532
533   GET /pmapi/context - pmNewContext(3)
534       ┌────────────┬────────┬────────────────────────────────────────────────┐
535       │Parameters  │  Type  │                  Explanation                   │
536       ├────────────┼────────┼────────────────────────────────────────────────┤
537       │hostspec    │ string │ Host specification as described in PCPIntro(1)
538       │polltimeout │ number │ Seconds of inactivity before closing context   │
539       │client      │ string │ Request identifier sent back with response     │
540       └────────────┴────────┴────────────────────────────────────────────────┘
541       To create a context for live sampling, a  web  client  can  access  any
542       /pmapi URL (optionally using the hostspec or context parameter).  If no
543       context exists, a new one will be created for that web client, and  its
544       identifier returned for future accesses.
545
546       However, /pmapi/context is provided as a dedicated URL for applications
547       wishing to explicitly create the contexts they use.
548
549       If successful, the server responds with a HTTP 200 (OK) code  and  JSON
550       message body of the form:
551
552         $ curl -s http://localhost:44322/pmapi/context?hostspec=www.acme.com&polltime=500 | pmjson
553         {
554           "context": 348734,
555           "source": "05af7f3eb840277fd3cfa91f90ef0067199743c",
556           "hostspec": "www.acme.com",
557           "labels": {
558             "domainname": "acme.com",
559             "groupid": 1000,
560             "hostname": "www.acme.com",
561             "machineid": "295b7623b6074cc8bdbda8bf96f6930a"
562             "platform": "dev",
563             "userid": 1000
564           }
565         }
566
567       The  context  (a  32-bit unsigned decimal number) can then be used with
568       all later requests.
569
570       In the case of a hostspec containing authentication  information,  such
571       as  a  username,  the  server will follow the HTTP Basic Authentication
572       protocol to ascertain necessary authentication details from  the  user,
573       providing  the  client  web application an opportunity to request these
574       from the user.
575
576   GET /pmapi/metric -  pmLookupDesc(3),  pmLookupLabels(3),  pmLookupName(3),
577       pmLookupText(3)
578       ┌────────────┬────────┬────────────────────────────────────────────────┐
579       │Parameters  │  Type  │                  Explanation                   │
580       ├────────────┼────────┼────────────────────────────────────────────────┤
581       │name        │ string │ An individual metric name                      │
582       │names       │ string │ Comma-separated list of metric names           │
583       │pmid        │ pmID   │ Numeric or pmIDStr(3) metric identifier        │
584       │pmids       │ string │ Comma-separated numeric or pmIDStr(3) pmIDs    │
585       │prefix      │ string │ Metric namespace component as in PMNS(5)
586       ├────────────┼────────┼────────────────────────────────────────────────┤
587       │hostspec    │ string │ Host specification as described in PCPIntro(1)
588       │context     │ number │ Web context number (optional like hostspec)    │
589       │polltimeout │ number │ Seconds of inactivity before context closed    │
590       │client      │ string │ Request identifier sent back with response     │
591       └────────────┴────────┴────────────────────────────────────────────────┘
592       The  metric endpoint provides detailed PMAPI metric metadata for one or
593       more metrics.  If no parameters are supplied, the response will be  for
594       all  metrics  found when traversing the entire Performance Metrics Name
595       Space (PMNS).
596
597       The prefix parameter can be used to specify a subtree of the  PMNS  for
598       traversal.  Alternatively, a specific metric or comma-separated list of
599       metrics can be specified using either name or names
600
601       The server response is a JSON document that provides metric metadata as
602       an array.
603
604         $ curl -s http://localhost:44322/pmapi/metric?names=kernel.all.load,disk.all.read | pmjson
605         {
606           "context": 348734,
607           "metrics": [
608             {
609               "name": "kernel.all.load",
610               "pmid": "60.2.0",
611               "indom": "60.2",
612               "type": "FLOAT",
613               "sem": "instant",
614               "units": "none",
615               "series": "d2b28c7f6dc0d69ffd21dba7ba955e78c37719b",
616               "source": "05af7f3eb840277fd3cfa91f90ef0067199743c",
617               "labels": {
618                 "agent": "linux",
619                 "domainname": "acme.com",
620                 "groupid": 1000,
621                 "hostname": "www.acme.com",
622                 "platform": "dev",
623                 "userid": 1000
624               },
625               "text-oneline": "1, 5 and 15 minute load average"
626             },
627             {
628               "name": "disk.all.read",
629               "pmid": "60.0.24",
630               "type": "U64",
631               "sem": "counter",
632               "units": "count",
633               "series": "d2b28c7f6dc0d69ffd21dba7ba955e78c37719b",
634               "source": "05af7f3eb840277fd3cfa91f90ef0067199743c",
635               "labels": {
636                 "agent": "linux",
637                 "domainname": "acme.com",
638                 "groupid": 1000,
639                 "hostname": "www.acme.com",
640                 "platform": "dev",
641                 "userid": 1000
642               },
643               "text-oneline": "total read operations, summed for all disks",
644               "text-help": "Cumulative number of disk read operations [...]"
645             }
646           ]
647         }
648       Most  of  the  fields are directly transcribed from the PMAPI calls for
649       metric descriptors, labels and help text mentioned above and are exact‐
650       ly  as  would  be observed using the pminfo(1) command with the -dlmstT
651       options.
652
653       The semantics, type and units fields are as returned  by  pmTypeStr(3),
654       pmUnitsStr(3) and pmSemStr(3).
655
656   GET /pmapi/fetch - pmFetch(3)
657       ┌────────────┬────────┬────────────────────────────────────────────────┐
658       │Parameters  │  Type  │                  Explanation                   │
659       ├────────────┼────────┼────────────────────────────────────────────────┤
660       │delta       │ string │ Sampling interval in pmParseInterval(3) form   │
661       │name        │ string │ An individual metric name                      │
662       │names       │ string │ Comma-separated list of metric names           │
663       │pmid        │ pmID   │ Numeric or pmIDStr(3) metric identifier        │
664       │pmids       │ string │ Comma-separated numeric or pmIDStr(3) pmIDs    │
665       ├────────────┼────────┼────────────────────────────────────────────────┤
666       │hostspec    │ string │ Host specification as described in PCPIntro(1)
667       │context     │ number │ Web context number (optional like hostspec)    │
668       │polltimeout │ number │ Seconds of inactivity before context closed    │
669       │client      │ string │ Request identifier sent back with response     │
670       └────────────┴────────┴────────────────────────────────────────────────┘
671       This request fetches (samples) current values for given metrics.
672
673       If any of the names or pmids provided are valid, the response is a JSON
674       document that provides the values for all instances of the metrics, un‐
675       less  a  instance profile has been set for the web context (see section
676       on InDom profiles below).
677
678         $ curl -s http://localhost:44322/pmapi/fetch?names=kernel.all.load,disk.all.read | pmjson
679         {
680           "context": 348734,
681           "timestamp": 1547483646.2147431,
682           "values": [
683             {
684               "pmid": "60.2.0",
685               "name": "kernel.all.load",
686               "instances:" [
687                 { "instance": 1, "value": 0.1 },
688                 { "instance": 5, "value": 0.17 },
689                 { "instance": 15, "value": 0.22 }
690               ]
691             },
692             {
693               "pmid":"60.0.24",
694               "name":"disk.all.read",
695               "instances:" [
696                 { "instance": null, "value": 639231 }
697               ]
698             }
699           ]
700         }
701       The response fields map directly to  fields  from  the  underlying  pm‐
702       Fetch(3) sampling interface.
703
704       Numeric  metric types are represented as JSON integer or floating-point
705       values.  Strings are passed verbatim, except that non-ASCII values  are
706       replaced with a Unicode 0xFFFD replacement character code.
707
708       In backward compatibility mode the timestamp is presented as a JSON map
709       with second (sec) and microsecond (us) fields,  instead  of  using  the
710       more compact floating point representation shown above.
711
712   GET /pmapi/children - pmGetChildren(3), pmGetChildrenStatus(3)
713       ┌────────────┬────────┬────────────────────────────────────────────────┐
714       │Parameters  │  Type  │                  Explanation                   │
715       ├────────────┼────────┼────────────────────────────────────────────────┤
716       │prefix      │ string │ Metric namespace component as in PMNS(5)
717       ├────────────┼────────┼────────────────────────────────────────────────┤
718       │hostspec    │ string │ Host specification as described in PCPIntro(1)
719       │context     │ number │ Web context number (optional like hostspec)    │
720       │polltimeout │ number │ Seconds of inactivity before context closed    │
721       │client      │ string │ Request identifier sent back with response     │
722       └────────────┴────────┴────────────────────────────────────────────────┘
723       The children endpoint provides iterative namespace traversal for a con‐
724       text.  If no parameters are supplied, the response  will  describe  the
725       direct descendants of the Performance Metrics Name Space (PMNS) root.
726
727       The  prefix  parameter can be used to specify a subtree of the PMNS for
728       traversal.
729
730       The server response is a JSON document that provides the  set  of  leaf
731       and non-leaf nodes below the given namespace node or root.
732
733         $ curl -s http://localhost:44322/pmapi/children?prefix=mem | pmjson
734         {
735           "context": 348734,
736           "name": "mem",
737           "leaf": [
738             "physmem",
739             "freemem"
740           ],
741           "nonleaf": [
742             "util",
743             "numa",
744             "vmstat",
745             "buddyinfo",
746             "slabinfo",
747             "zoneinfo",
748             "ksm"
749           ]
750         }
751
752   GET /pmapi/indom - pmGetInDom(3), pmNameInDom(3), pmLookupInDom(3)
753       ┌────────────┬─────────┬────────────────────────────────────────────────┐
754       │Parameters  │  Type   │                  Explanation                   │
755       ├────────────┼─────────┼────────────────────────────────────────────────┤
756       │iname       │ string  │ Comma-separated list of instance names         │
757       │indom       │ pmInDom │ Numeric or pmInDomStr(3) instance domain       │
758       │instance    │ number  │ Comma-separated list of instance numbers       │
759       │match       │ string  │ Pattern matching style (exact, glob or regex)  │
760       │name        │ string  │ An individual metric name                      │
761       ├────────────┼─────────┼────────────────────────────────────────────────┤
762       │hostspec    │ string  │ Host specification as described in PCPIntro(1)
763       │context     │ number  │ Web context number (optional like hostspec)    │
764       │polltimeout │ number  │ Seconds of inactivity before context closed    │
765       │client      │ string  │ Request identifier sent back with response     │
766       └────────────┴─────────┴────────────────────────────────────────────────┘
767       This  request  lists  the current instances of an instance domain.  The
768       instance domain is either specified  directly  (in  numeric  or  string
769       form) or indirectly, by association with the specified metric.
770
771       The request can be further qualified with a comma-separated list of the
772       instances to report on, either by name or number,  using  the  instance
773       and iname parameters.
774
775       In the case of instance name qualifiers, these will be matched by exact
776       string comparison by default.  Alternatively, the match  parameter  can
777       be  used  to  specify  that regular expression or glob pattern matching
778       should be used instead.
779
780       The response is a JSON document that provides the instance domain meta‐
781       data as an array.
782
783         $ curl -s http://localhost:44322/pmapi/indom?name=kernel.all.load | pmjson
784         {
785           "context": 348734,
786           "indom": "60.2",
787           "labels": {
788             "domainname": "acme.com",
789             "groupid": 1000,
790             "hostname": "www.acme.com",
791             "machineid": "295b7623b6074cc8bdbda8bf96f6930a"
792             "platform": "dev",
793             "userid": 1000
794           },
795           "instances": [
796             {
797               "instance": 1,
798               "name": "1 minute"
799               "labels": { ... },
800             },
801             {
802               "instance": 5,
803               "name": "5 minute"
804               "labels": { ... },
805             },
806             {
807               "instance": 15,
808               "name": "15 minute"
809               "labels": { ...  },
810             }
811           ]
812         }
813
814   GET /pmapi/profile - pmAddProfile(3), pmDelProfile(3)
815       ┌────────────┬─────────┬────────────────────────────────────────────────┐
816       │Parameters  │  Type   │                  Explanation                   │
817       ├────────────┼─────────┼────────────────────────────────────────────────┤
818       │iname       │ string  │ Comma-separated list of instance names         │
819       │indom       │ pmInDom │ Numeric or pmInDomStr(3) instance domain       │
820       │instance    │ number  │ Comma-separated list of instance numbers       │
821       │expr        │ string  │ One of "add" or "del" (mandatory).             │
822       │match       │ string  │ Pattern matching style (exact, glob or regex)  │
823       ├────────────┼─────────┼────────────────────────────────────────────────┤
824       │hostspec    │ string  │ Host specification as described in PCPIntro(1)
825       │context     │ number  │ Web context number (optional like hostspec)    │
826       │polltimeout │ number  │ Seconds of inactivity before context closed    │
827       │client      │ string  │ Request identifier sent back with response     │
828       └────────────┴─────────┴────────────────────────────────────────────────┘
829       Some  PMAPI  operations can be performed with an active instance domain
830       profile which restricts (filters) the set of  resulting  instances  re‐
831       turned, as described on pmAddProfile(3).
832
833         $ curl -s http://localhost:44322/pmapi/profile?expr=add,indom=60.2,iname=1%20minute
834         { "context": 348734, "success": true }
835
836   GET /pmapi/store - pmStore(3)
837       ┌────────────┬────────┬────────────────────────────────────────────────┐
838       │Parameters  │  Type  │                  Explanation                   │
839       ├────────────┼────────┼────────────────────────────────────────────────┤
840       │iname       │ string │ Comma-separated list of instance names         │
841       │instance    │ number │ Comma-separated list of instance numbers       │
842       │name        │ string │ An individual metric name                      │
843       │value       │ (any)  │ New value for the given metric instance(s)     │
844       ├────────────┼────────┼────────────────────────────────────────────────┤
845       │hostspec    │ string │ Host specification as described in PCPIntro(1)
846       │context     │ number │ Web context number (optional like hostspec)    │
847       │polltimeout │ number │ Seconds of inactivity before context closed    │
848       │client      │ string │ Request identifier sent back with response     │
849       └────────────┴────────┴────────────────────────────────────────────────┘
850       Some  performance metrics allow their value to be modified, for example
851       to re-initialize counters or to modify control variables.
852
853       This operation takes a single metric name  to  modify,  and  optionally
854       specific  instances.  The mandatory value will be interpreted according
855       to the type of the metric being modified.
856
857       If successful, the response from these requests is a JSON  document  of
858       the form:
859
860         $ curl -s http://localhost:44322/pmapi/store?name=pmcd.control.timeout&value=10
861         {
862           "context": 348734,
863           "success": true
864         }
865
866   GET /pmapi/derive: pmAddDerived(3)
867       ┌────────────┬────────┬────────────────────────────────────────────────┐
868       │Parameters  │  Type  │                  Explanation                   │
869       ├────────────┼────────┼────────────────────────────────────────────────┤
870       │expr        │ string │ Derived metric expression                      │
871       │name        │ string │ New derived metric name                        │
872       ├────────────┼────────┼────────────────────────────────────────────────┤
873       │hostspec    │ string │ Host specification as described in PCPIntro(1)
874       │context     │ number │ Web context number (optional like hostspec)    │
875       │polltimeout │ number │ Seconds of inactivity before context closed    │
876       │client      │ string │ Request identifier sent back with response     │
877       └────────────┴────────┴────────────────────────────────────────────────┘
878       Create  a  new derived metric, as defined by the pmAddDerived(3) metric
879       interface.  Derived metrics are associated with the named context, or a
880       new context is created and returned in the result.
881
882       This interface is one of the few that allows a POST to be used in place
883       of a GET.  In this case the HTTP POST request body may be used to  pro‐
884       vide  one  or  more derived metrics specifications (all at once, across
885       multiple lines, as a convenience).
886
887         $ curl -s http://localhost:44322/pmapi/derive?name=blkio.avgsz&expr=disk.all.blktotal/disk.all.total | pmjson
888         {
889           "context": 348734,
890           "success": true
891         }
892
893         $ curl -s http://localhost:44322/pmapi/fetch?name=blkio.avgsz&samples=2 | pmjson
894         {
895           "context": 348734,
896           "timestamp": 1547483648.2147428,
897           "values": [
898             {
899               "pmid": "511.0.27",
900               "name": "blkio.avgsz",
901               "instances:" [
902                 {
903                   "instance": null,
904                   "value": 9231
905                 }
906               ]
907             }
908           ]
909         }
910
911   GET /pmapi/metrics: pmLookupDesc(3),pmLookupLabels(3), pmFetch(3)
912       ┌────────────┬─────────┬────────────────────────────────────────────────┐
913       │Parameters  │  Type   │                  Explanation                   │
914       ├────────────┼─────────┼────────────────────────────────────────────────┤
915       │names       │ string  │ Comma-separated list of metric names           │
916       │times       │ boolean │ Append sample times (milliseconds since epoch) │
917       ├────────────┼─────────┼────────────────────────────────────────────────┤
918       │context     │ number  │ Web context number (optional like hostspec)    │
919       │hostspec    │ string  │ Host specification as described in PCPIntro(1)
920       │polltimeout │ number  │ Seconds of inactivity before context closed    │
921       │client      │ string  │ Request identifier sent back with response     │
922       └────────────┴─────────┴────────────────────────────────────────────────┘
923       This request is a subset of the style described in the ``OPEN METRICS''
924       section, allowing a web context identifier to be passed as a parameter.
925       It is otherwise very similar in terms of parameters and  response  han‐
926       dling, please refer to the earlier section for details.
927

NOTES

929       For the REST APIs, errors generally result in HTTP-level error respons‐
930       es.  Wherever possible, any PMAPI error string will also be provided in
931       a message along with the response.
932
933       All responses will be returned using HTTP 1.1 protocol and with chunked
934       encoding being used to stream responses that are larger than a  config‐
935       ured  maximum size.  Compression will be used on responses whenever the
936       client indicates appropriate support.
937
938       An Access-Control-Allow-Origin: * header is added to all REST  API  re‐
939       sponses.
940

SEE ALSO

942       PCPIntro(1),  curl(1),  pmcd(1),  pmdaopenmetrics(1),  pminfo(1),  pmj‐
943       son(1), pmlogger(1), pmproxy(1), pmseries(1),  redis-server(1),  PCPIn‐
944       tro(3) and PMAPI(3)
945
946
947
948Performance Co-Pilot                  PCP                          PMWEBAPI(3)
Impressum