You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/plugins/README.md
+65-62Lines changed: 65 additions & 62 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,39 +8,40 @@ The list of the current running plugins is displayed next to the label `PLUGINS`
8
8
9
9
## Official Plugins
10
10
11
-
You can find all the official plugins at [Weaveworks Plugins](https://github.com/weaveworks-plugins).
11
+
Official Weave Scope plugins can be found at [Weaveworks Plugins](https://github.com/weaveworks-plugins).
12
12
13
-
*[IOWait](https://github.com/weaveworks-plugins/scope-iowait): a Go plugin using[iostat](https://en.wikipedia.org/wiki/Iostat) to provide host-level CPU IO wait or idle metrics.
13
+
*[IOWait](https://github.com/weaveworks-plugins/scope-iowait): is a Go plugin that uses[iostat](https://en.wikipedia.org/wiki/Iostat) to provide host-level CPU IO wait or idle metrics.
14
14
15
-
*[HTTP Statistics](https://github.com/weaveworks-plugins/scope-http-statistics): A Python plugin using [bcc](http://iovisor.github.io/bcc/) to track multiple metrics about HTTP per process, without any application-level instrumentation requirements and negligible performance toll. This plugin is a work in progress, as of now it implements two metrics (for more information read the [plugin documentation](https://github.com/weaveworks-plugins/scope-http-statistics)):
15
+
*[HTTP Statistics](https://github.com/weaveworks-plugins/scope-http-statistics): is a Python plugin that uses [bcc](http://iovisor.github.io/bcc/) to track multiple metrics about HTTP per process. It does this without any application-level instrumentation requirements and with a negligible performance toll. This plugin is a work in progress, and implements the following (for more information read the [plugin documentation](https://github.com/weaveworks-plugins/scope-http-statistics)):
16
16
* Number of HTTP requests per seconds.
17
17
* Number of HTTP responses code per second (per code).
18
18
19
-
*[Traffic Control](https://github.com/weaveworks-plugins/scope-traffic-control): This plugin allows the user to modify latency and packet loss for a specific container via buttons in the UI's container detailed view.
19
+
*[Traffic Control](https://github.com/weaveworks-plugins/scope-traffic-control): This plugin allows you to modify latency and packet loss for a specific container via controls from the container's detailed view in the Scope user interface.
20
20
21
-
*[Volume Count](https://github.com/weaveworks-plugins/scope-volume-count): This plugin is a Python application that asks docker for the the number of mounted volumes for each container, providing container-level count.
21
+
*[Volume Count](https://github.com/weaveworks-plugins/scope-volume-count): This plugin (written in Python) requests the number of mounted volumes for each container, and provides a container-level count.
22
22
23
-
## Plugins Internals
23
+
## How Plugins Communicate with Scope
24
24
This section explains the fundamental parts of the plugins structure necessary to understand how a plugin communicates with Scope.
25
25
You can find more practical examples in [Weaveworks Plugins](https://github.com/weaveworks-plugins) repositories.
26
26
27
-
### Plugin ID
27
+
### Plugin IDs
28
28
29
-
Each plugin should have an unique ID. It is forbidden to change it
30
-
during the plugin's lifetime. The scope probe will get the plugin's ID
31
-
from the plugin's socket filename. For example, the socket named
32
-
`my-plugin.sock`, the scope probe will deduce the ID as
33
-
`my-plugin`. IDs can only contain alphanumeric sequences, optionally
34
-
separated with a dash.
29
+
Each plugin must have a unique ID and this ID must not change
30
+
during the plugin's lifetime. Scope probes retrieve the plugin's ID
31
+
from the plugin's socket filename. For example, if a socket is named
32
+
`my-plugin.sock`, the scope probe deduces the ID as
33
+
`my-plugin`. IDs may contain only alphanumeric sequences that are optionally
34
+
separated by a dash.
35
35
36
-
### Plugin registration
36
+
### Registering Plugins
37
37
38
-
All plugins should listen for HTTP connections on a unix socket in the
39
-
`/var/run/scope/plugins` directory. The scope probe will recursively
40
-
scan that directory every 5 seconds, to look for sockets being added
41
-
(or removed). It is also valid to put the plugin unix socket in a
42
-
sub-directory, in case you want to apply some permissions, or store
43
-
other information with the socket.
38
+
All plugins listen for HTTP connections on a UNIX socket in the `/var/run/scope/plugins` directory. The Scope probe recursively scans that directory every 5 seconds and looks for any added or removed sockets.
39
+
40
+
If you want to run permissions or store any other information with the socket, you can also put the plugin UNIX socket into a sub-directory.
41
+
42
+
When a new plugin is detected, the Scope probe begins requesting reports from it via GET /report. It is therefore important that **every plugin implements the report interface**. Implementing the report interface also means handling specific requests.
43
+
44
+
All plugin endpoints are expected to respond within 500ms, and must respond using the JSON format.
44
45
45
46
### Protocol
46
47
@@ -57,9 +58,9 @@ Implementing this interface means listening for HTTP requests at `/report`.
57
58
58
59
#### Report
59
60
60
-
When the scope probe discovers a new plugin unix socket it will begin
61
+
When a scope probe discovers a new plugin UNIX socket it will begin
61
62
periodically making a `GET` request to the `/report` endpoint. The
62
-
report data structure returned from this will be merged into the
63
+
report data structure returned from this is merged into the
63
64
probe's report and sent to the app. An example of the report structure
64
65
can be viewed at the `/api/report` endpoint of any scope app.
65
66
@@ -86,30 +87,30 @@ For example:
86
87
Note that the `Plugins` section includes exactly one plugin
87
88
description. The plugin description fields are:
88
89
89
-
*`id`is used to check for duplicate plugins. It is
90
+
*`id`- checks for duplicate plugins. It is
90
91
required. Described in [the Plugin ID section](#plugin-id).
91
-
*`label`is a human readable plugin label displayed in the UI. It is
92
+
*`label`- a human readable plugin label displayed in the UI. It is
92
93
required.
93
-
*`description`is displayed in the UI.
94
-
*`interfaces`is a list of interfaces which this plugin supports. It
94
+
*`description`- displayed in the UI.
95
+
*`interfaces`- a list of interfaces which this plugin supports. It
95
96
is required, and must contain at least `["reporter"]`.
96
-
*`api_version`is used to ensure both the plugin and the scope probe
97
+
*`api_version`- ensure both the plugin and the scope probe
97
98
can speak to each other. It is required, and must match the probe.
98
99
99
100
#### Controller interface
100
101
101
-
Plugins _may_ implement the controller interface. Implementing the
102
+
Plugins _may_also implement the controller interface. Implementing the
102
103
controller interface means that the plugin can react to HTTP `POST`
103
-
control requests sent by the app. The plugin will receive them only
104
-
for controls it exposed in its reports. The requests will come to the
104
+
control requests sent by the app. The plugin receives them only
105
+
for the controls it exposed in its reports. All such requests come to the
105
106
`/control` endpoint.
106
107
107
108
Add the "controller" string to the `interfaces` field in the plugin
108
109
specification.
109
110
110
111
#### Control
111
112
112
-
The `POST` requests will have a JSON-encoded body with the following contents:
113
+
The `POST` requests contain a JSON-encoded body with the following contents:
113
114
114
115
```json
115
116
{
@@ -119,10 +120,10 @@ The `POST` requests will have a JSON-encoded body with the following contents:
119
120
}
120
121
```
121
122
122
-
The body of the response should also be a JSON-encoded data. Usually
123
-
the body would be an empty JSON object (so, "{}" after
124
-
serialization). If some error happens during handling the control,
125
-
then the plugin can send a response with an `error` field set, for
123
+
The body of the response should also be a JSON-encoded data. In most cases,
124
+
the body is an empty JSON object (so, "{}" after
125
+
serialization). If an error happens when handling the control,
126
+
then the plugin sends a response with an `error` field set, for
126
127
example:
127
128
128
129
```json
@@ -131,11 +132,11 @@ example:
131
132
}
132
133
```
133
134
134
-
Sometimes the control activation can make the control obsolete, so the
135
+
Sometimes the control activation can make the control obsolete, and so the
135
136
plugin may want to hide it (for example, control for stopping the
136
137
container should be hidden after the container is stopped). For this
137
-
to work, the plugin can send a shortcut report by filling the
138
-
`ShortcutReport` field in the response, like for example:
138
+
to work, the plugin sends a shortcut report by filling the
139
+
`ShortcutReport` field in the response, like so:
139
140
140
141
```json
141
142
{
@@ -145,11 +146,10 @@ to work, the plugin can send a shortcut report by filling the
145
146
146
147
##### How to expose controls
147
148
148
-
Each topology in the report (be it host, pod, endpoint and so on) has
149
-
a set of available controls a node in the topology may want to
149
+
Each topology in the report (be it host, pod, endpoint and so on) contains
150
+
a set of available controls that a node in the topology may want to
150
151
show. The following (rather artificial) example shows a topology with
151
-
two controls (`ctrl-one` and `ctrl-two`) and two nodes, each having a
152
-
different control from the two:
152
+
two controls (`ctrl-one` and `ctrl-two`) and two nodes, each with a different control defined:
153
153
154
154
```json
155
155
{
@@ -194,8 +194,8 @@ different control from the two:
194
194
}
195
195
```
196
196
197
-
When control "ctrl-one" is activated, the plugin will receive a
198
-
request like:
197
+
When control "ctrl-one" is activated, the plugin receives a
198
+
request as follows:
199
199
200
200
```json
201
201
{
@@ -209,30 +209,31 @@ A short note about the "icon" field of the topology control - the
209
209
value for it can be taken from [Font Awesome
210
210
Cheatsheet](http://fontawesome.io/cheatsheet/)
211
211
212
-
##### Node naming
212
+
##### Naming Nodes
213
213
214
-
Very often the controller plugin wants to add some controls to already
215
-
existing nodes (like controls for network traffic management to nodes
214
+
Often the controller plugin may want to add some controls to already
215
+
existing nodes (for example add controls for network traffic management to nodes
216
216
representing the running Docker container). To achieve that, it is
217
217
important to make sure that the node ID in the plugin's report matches
218
218
the ID of the node created by the probe. The ID is a
219
219
semicolon-separated list of strings.
220
220
221
-
For containers, images, hosts and others the ID is usually formatted
221
+
For containers, images, hosts and others, the ID is usually formatted
222
222
as `${name};<${tag}>`. The `${name}` variable is usually a name of a
223
223
thing the node represents, like an ID of the Docker container or the
224
-
hostname. The `${tag}` denotes the type of the node. There is a fixed
225
-
set of tags used by the probe:
224
+
hostname. The `${tag}` denotes the type of the node.
URL, you can find the `example.com;<host>` which is an ID of the node
256
257
representing the host.
257
-
- Mentally substitute the `<SLASH>` with `/`. This can appear in
258
+
3. Mentally substitute the `<SLASH>` with `/`. This can appear in
258
259
Docker image names, so `docker.io/alpine` in the address bar will
259
260
be `docker.io<SLASH>alpine`.
261
+
262
+
For more detailed information visit [https://www.weave.works/documentation/scope-latest-plugins/](https://www.weave.works/documentation/scope-latest-plugins/)
0 commit comments