Skip to content

Commit 655e667

Browse files
author
Alessandro Puccetti
committed
docs/plugins: sync docs with changes site changes
This patch applies the same changes from the review of weaveworks#2008
1 parent 953548d commit 655e667

File tree

1 file changed

+65
-62
lines changed

1 file changed

+65
-62
lines changed

examples/plugins/README.md

Lines changed: 65 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,40 @@ The list of the current running plugins is displayed next to the label `PLUGINS`
88

99
## Official Plugins
1010

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).
1212

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.
1414

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)):
1616
* Number of HTTP requests per seconds.
1717
* Number of HTTP responses code per second (per code).
1818

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.
2020

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.
2222

23-
## Plugins Internals
23+
## How Plugins Communicate with Scope
2424
This section explains the fundamental parts of the plugins structure necessary to understand how a plugin communicates with Scope.
2525
You can find more practical examples in [Weaveworks Plugins](https://github.com/weaveworks-plugins) repositories.
2626

27-
### Plugin ID
27+
### Plugin IDs
2828

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.
3535

36-
### Plugin registration
36+
### Registering Plugins
3737

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.
4445

4546
### Protocol
4647

@@ -57,9 +58,9 @@ Implementing this interface means listening for HTTP requests at `/report`.
5758

5859
#### Report
5960

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
6162
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
6364
probe's report and sent to the app. An example of the report structure
6465
can be viewed at the `/api/report` endpoint of any scope app.
6566

@@ -86,30 +87,30 @@ For example:
8687
Note that the `Plugins` section includes exactly one plugin
8788
description. The plugin description fields are:
8889

89-
* `id` is used to check for duplicate plugins. It is
90+
* `id` - checks for duplicate plugins. It is
9091
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
9293
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
9596
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
9798
can speak to each other. It is required, and must match the probe.
9899

99100
#### Controller interface
100101

101-
Plugins _may_ implement the controller interface. Implementing the
102+
Plugins _may_ also implement the controller interface. Implementing the
102103
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
105106
`/control` endpoint.
106107

107108
Add the "controller" string to the `interfaces` field in the plugin
108109
specification.
109110

110111
#### Control
111112

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:
113114

114115
```json
115116
{
@@ -119,10 +120,10 @@ The `POST` requests will have a JSON-encoded body with the following contents:
119120
}
120121
```
121122

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
126127
example:
127128

128129
```json
@@ -131,11 +132,11 @@ example:
131132
}
132133
```
133134

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
135136
plugin may want to hide it (for example, control for stopping the
136137
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:
139140

140141
```json
141142
{
@@ -145,11 +146,10 @@ to work, the plugin can send a shortcut report by filling the
145146

146147
##### How to expose controls
147148

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
150151
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:
153153

154154
```json
155155
{
@@ -194,8 +194,8 @@ different control from the two:
194194
}
195195
```
196196

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:
199199

200200
```json
201201
{
@@ -209,30 +209,31 @@ A short note about the "icon" field of the topology control - the
209209
value for it can be taken from [Font Awesome
210210
Cheatsheet](http://fontawesome.io/cheatsheet/)
211211

212-
##### Node naming
212+
##### Naming Nodes
213213

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
216216
representing the running Docker container). To achieve that, it is
217217
important to make sure that the node ID in the plugin's report matches
218218
the ID of the node created by the probe. The ID is a
219219
semicolon-separated list of strings.
220220

221-
For containers, images, hosts and others the ID is usually formatted
221+
For containers, images, hosts and others, the ID is usually formatted
222222
as `${name};<${tag}>`. The `${name}` variable is usually a name of a
223223
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.
226225

227-
- host
228-
- container
229-
- container_image
230-
- pod
231-
- service
232-
- deployment
233-
- replica_set
226+
There is a fixed set of tags used by the probe:
234227

235-
The examples of "tagged" node names:
228+
- `host`
229+
- `container`
230+
- `container_image`
231+
- `pod`
232+
- `service`
233+
- `deployment`
234+
- `replica_set`
235+
236+
These are examples of "tagged" node names:
236237

237238
- The Docker container with full ID
238239
2299a2ca59dfd821f367e689d5869c4e568272c2305701761888e1d79d7a6f51:
@@ -243,17 +244,19 @@ The examples of "tagged" node names:
243244

244245
The fixed set of tags listed above is not a complete set of names a
245246
node can have though. For example, nodes representing processes are
246-
have ID formatted as `${host};${pid}`. Probably the easiest ways to
247+
have IDs formatted as `${host};${pid}`. The easiest way to
247248
discover how the nodes are named are:
248249

249-
- Read the code in
250+
1. Read the code in
250251
[report/id.go](https://github.com/weaveworks/scope/blob/master/report/id.go).
251-
- Browse the Weave Scope GUI, select some node and search for an `id`
252+
2. Browse the Weave Scope GUI, select some node and search for an `id`
252253
key in the `nodeDetails` array in the address bar.
253254
- For example in the
254255
`http://localhost:4040/#!/state/{"controlPipe":null,"nodeDetails":[{"id":"example.com;<host>","label":"example.com","topologyId":"hosts"}],…`
255256
URL, you can find the `example.com;<host>` which is an ID of the node
256257
representing the host.
257-
- Mentally substitute the `<SLASH>` with `/`. This can appear in
258+
3. Mentally substitute the `<SLASH>` with `/`. This can appear in
258259
Docker image names, so `docker.io/alpine` in the address bar will
259260
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

Comments
 (0)