|  |  |  | Cockpit Guide |  | 
|---|
| cockpit.js: Metricscockpit.js: Metrics — Reading and streaming metric data | 
Metrics about the system can be retrieved from several sources using
      cockpit.metrics() metrics channels.
      The metrics are made available as series data, and can be used with the
      cockpit.series() and
      cockpit.grid() facilities.
metrics = cockpit.metrics(interval, options, cache)
Opens a new metrics channel. The data retrieved will be available in the
      metrics.series series sink, and can
      be used together with cockpit.grid() objects.
The interval is in milliseconds, and is the granularity of the series data
      retrieved. Any grids consuming the data must have the same interval.
The cache argument is a cache identifier. If
      specified, then this metrics channel will share data with other
      metrics channels of the same identifier. Make sure to use a
      globally unique string.
The options argument is either a javascript
      plain object, or an array of those.  Each object can have the
      following fields.
| 
 | An array of full metric descriptions, as javascript objects. The specifics of these, and how to determine which ones to use, can unfortunately only be found in the low-level protocol documentation. This option is required. | 
| 
 | The source to use for real-time data.  This
          is used by the  | 
| 
 | The source to use for retrieving historical
          data.  This is used by the  | 
When the options argument is an array of
      javascript objects, then the metrics channel tries to use them in
      order until one succeeds.  This way, you can prefer PCP as the
      source but fall back to internal metrics when PCP is not
      available, for example.  The channel gives no indication which
      of the options has been used, and fetch and
      follow might use different entries from the
      list.