github.com/AliyunContainerService/cli@v0.0.0-20181009023821-814ced4b30d0/docs/extend/plugins_metrics.md (about) 1 --- 2 description: "Metrics plugins." 3 keywords: "Examples, Usage, plugins, docker, documentation, user guide, metrics" 4 --- 5 6 <!-- This file is maintained within the docker/cli GitHub 7 repository at https://github.com/docker/cli/. Make all 8 pull requests against that repo. If you see this file in 9 another repository, consider it read-only there, as it will 10 periodically be overwritten by the definitive file. Pull 11 requests which include edits to this file in other repositories 12 will be rejected. 13 --> 14 15 # Docker metrics collector plugins 16 17 Docker exposes internal metrics based on the prometheus format. Metrics plugins 18 enable accessing these metrics in a consistent way by providing a Unix 19 socket at a predefined path where the plugin can scrape the metrics. 20 21 > **Note**: that while the plugin interface for metrics is non-experimental, the naming 22 of the metrics and metric labels is still considered experimental and may change 23 in a future version. 24 25 ## Creating a metrics plugin 26 27 You must currently set `PropagatedMount` in the plugin `config.json` to 28 `/run/docker`. This allows the plugin to receive updated mounts 29 (the bind-mounted socket) from Docker after the plugin is already configured. 30 31 ## MetricsCollector protocol 32 33 Metrics plugins must register as implementing the`MetricsCollector` interface 34 in `config.json`. 35 36 On Unix platforms, the socket is located at `/run/docker/metrics.sock` in the 37 plugin's rootfs. 38 39 `MetricsCollector` must implement two endpoints: 40 41 ### `MetricsCollector.StartMetrics` 42 43 Signals to the plugin that the metrics socket is now available for scraping 44 45 **Request** 46 ```json 47 {} 48 ``` 49 50 The request has no playload. 51 52 **Response** 53 ```json 54 { 55 "Err": "" 56 } 57 ``` 58 59 If an error occurred during this request, add an error message to the `Err` field 60 in the response. If no error then you can either send an empty response (`{}`) 61 or an empty value for the `Err` field. Errors will only be logged. 62 63 ### `MetricsCollector.StopMetrics` 64 65 Signals to the plugin that the metrics socket is no longer available. 66 This may happen when the daemon is shutting down. 67 68 **Request** 69 ```json 70 {} 71 ``` 72 73 The request has no playload. 74 75 **Response** 76 ```json 77 { 78 "Err": "" 79 } 80 ``` 81 82 If an error occurred during this request, add an error message to the `Err` field 83 in the response. If no error then you can either send an empty response (`{}`) 84 or an empty value for the `Err` field. Errors will only be logged.