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