Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report data structure documentation #2025

Merged

Conversation

alepuccetti
Copy link

This PR adds documentation for the primary data structures used to create a report. It will be of great help to developers that want to build their plugins.

I did this work on the website. Do you want me to add the same information on https://github.com/weaveworks/scope/blob/master/examples/plugins/README.md?

Relevant to #1963

/cc @2opremio @abuehrle

@alepuccetti alepuccetti force-pushed the alessandro/data-structures branch 4 times, most recently from 9b85635 to 278a356 Compare November 30, 2016 08:46
site/plugins.md Outdated
### Time Window
A report may have an attribute called `Window`.
This is the time window, expressed as duration, within which the data contained in the report are considered valid.
The default window is 15 seconds

This comment was marked as abuse.

@2opremio
Copy link
Contributor

@ekimekim Considering you would have appreciated this sort of documentation recently, would you mind reviewing it?

Copy link
Contributor

@ekimekim ekimekim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of open questions. A few formatting comments.

site/plugins.md Outdated
}
```

Nodes are stored in dictionary. The ID of nodes representing hosts or containers have the format `ID;<type>`, with type equal `host` or `container` accordingly.

This comment was marked as abuse.

site/plugins.md Outdated

- `latest` - the latest values to display.
- `latestControls` - the latest available controls.
- `metrics` - the collection of metrics to display in the UI.

This comment was marked as abuse.

This comment was marked as abuse.

site/plugins.md Outdated

- `timestamp` is the timestamp of when the control was exposed.
- `value` is an object containing the control value. At the moment, only the state is available.
- `Dead` is a boolean to know the state (active, dead) of a control. It is useful to show controls only when they are in a usable state.

This comment was marked as abuse.

site/plugins.md Outdated
- `Dead` is a boolean to know the state (active, dead) of a control. It is useful to show controls only when they are in a usable state.

### Metadata Templates
Metadata Templates describe of a particular metadata.

This comment was marked as abuse.

site/plugins.md Outdated
- `from` indicates where to look for the metadata. The possible values are:
- `latest`
- `sets`
- `counters`

This comment was marked as abuse.

site/plugins.md Outdated

- `metric-template-id` and `id` identify a particular metric template.
- `label` contains the label that will be used by Scope UI.
- `format` describes who the metrics is formatted.

This comment was marked as abuse.

site/plugins.md Outdated
- `label` contains the label that will be used by Scope UI.
- `format` describes who the metrics is formatted.
- `percent` the metric value is a percentage.
- `filesize` the metric value is a file size (e.g. memory usage).

This comment was marked as abuse.

site/plugins.md Outdated
}
```

### Metrics

This comment was marked as abuse.

site/plugins.md Outdated

- `metadata-template-identifier` and `id` identify a particular metadata template.
- `label` contains the label that will be used by Scope UI.
- `priority` is a floating point value used to decide the display ordering (lower values are displayed before higher ones).

This comment was marked as abuse.

site/plugins.md Outdated
"another-metadata-template-id": {...}
}
```

This comment was marked as abuse.

This comment was marked as abuse.

@2opremio
Copy link
Contributor

@alepuccetti Ping

@alepuccetti
Copy link
Author

@2opremio I will get back to this soon. Lately, I was busy debugging and testing the ebpf program distro agnostic.

@alepuccetti alepuccetti force-pushed the alessandro/data-structures branch from 278a356 to 0776d9d Compare January 17, 2017 11:10
@alepuccetti
Copy link
Author

I added a new commit for an easier review, I will squash it before merge.

@alepuccetti alepuccetti force-pushed the alessandro/data-structures branch 4 times, most recently from 2918e8b to f6e4b16 Compare January 17, 2017 15:04
@alepuccetti alepuccetti force-pushed the alessandro/data-structures branch 3 times, most recently from c6f0244 to 720365e Compare February 20, 2017 13:58
@2opremio
Copy link
Contributor

@alepuccetti ping

@alepuccetti
Copy link
Author

alepuccetti commented Mar 11, 2017 via email

site/plugins.md Outdated
To pair metadata with its template, it is necessary to use the `metadata-template-id` as a key to identify that particular piece of data. Example:

```json
"metadata-templates": {

This comment was marked as abuse.

site/plugins.md Outdated
A report can contain many types of information.
If you go back to the [Reporter Interface](#reporter-interface) section, you see the top-level `Plugins` attribute.
Along with that, a report may contain multiple topologies.
An example of a report containing few topologies is the following:

This comment was marked as abuse.

site/plugins.md Outdated

### Topologies
Topologies can be of various types.
Each topology consists of a list of nodes and other information about the topology.

This comment was marked as abuse.

site/plugins.md Outdated
- `table_templates` - contains the templates used to render tables into the Scope UI.
- `metric_templates` - contains the templates used to render metrics into the Scope UI.

**Note**: These attribute are not required. But a topology with no `nodes` does not have any information to render, `metadata_templates`, as well as `table_templates`, are needed to know how to render the information carried by `nodes` in the Scope UI.

This comment was marked as abuse.

site/plugins.md Outdated

### Nodes
A Node contains information about a specific element of a topology.
For example the Host topology will contain nodes describing all the hosts in it.

This comment was marked as abuse.

site/plugins.md Outdated
### Nodes
A Node contains information about a specific element of a topology.
For example the Host topology will contain nodes describing all the hosts in it.
The same is for containers and Container topology, pods and Pod topology and so on.

This comment was marked as abuse.

site/plugins.md Outdated
}
```

- `timestamp` is the timestamp of when the control was exposed.

This comment was marked as abuse.

site/plugins.md Outdated
- `metadata-template-identifier` and `id` identify a particular metadata template.
- `label` contains the label that will be used by Scope UI.
- `dataType` specifies the type of data, this will determine how the value is displayed. Possible values for this attribute are: number, ip, and datetime.
- `priority` is a floating point value used to decide the display ordering (lower values are displayed before higher ones). If it is omitted the UI display the value as last.

This comment was marked as abuse.

site/plugins.md Outdated
- `label` contains the label that will be used by Scope UI.
- `prefix` is used to identify which metadata templates belong to the table.

If you want to display data in a table, you have to define a table template and prepend the table prefix to all the metadata templates that identifies the data you want to put in such table.

This comment was marked as abuse.

site/plugins.md Outdated
The following is an example of a report with a metric and a its metric template:

```json
"metric_templates": {

This comment was marked as abuse.

This comment was marked as abuse.

site/plugins.md Outdated
This is the time window, expressed as duration, within which the data contained in the report are considered valid.
The default window is 15 seconds.
You may change the window value using the option `-app.window <SECONDS>` when launching scope.
However, using values less than 15 seconds increases the change of information not be correctly displayed.

This comment was marked as abuse.

@alban alban force-pushed the alessandro/data-structures branch from 720365e to 68d9dcb Compare April 4, 2017 13:58
@alban
Copy link
Contributor

alban commented Apr 4, 2017

I rebased the branch, squashed the commits & added a couple of new fixes from the review above.

site/plugins.md Outdated
This is the time window, expressed as duration, within which the data contained in the report are considered valid.
The default window is 15 seconds.
You may change the window value using the option `-app.window <SECONDS>` when launching scope.
However, using values less than 15 seconds increases the chance of information not being correctly displayed.

This comment was marked as abuse.

site/plugins.md Outdated
**See Also**
### <a id="report-data-structures"></a>Report Data structures
A report can contain many types of information.
If you go back to the [Reporter Interface](#reporter-interface) section, you see the top-level `Plugins` attribute.

This comment was marked as abuse.

site/plugins.md Outdated
### Topologies
Topologies can be of various types.
Each topology consists of some general information and a list of nodes.
The available topologies are:

This comment was marked as abuse.

site/plugins.md Outdated
Each topology consists of some general information and a list of nodes.
The available topologies are:

- `Endpoint` nodes are (address, port) tuples on each host.

This comment was marked as abuse.

site/plugins.md Outdated
### Controls
Controls describe interfaces that expose actions that the user can perform on different objects (e.g. host, container, etc.).
Controls are an element of nodes. In this way, each control in a node is attached to it and performs an action on the object described by the node itself. Below is an example of how controls are represented in the JSON report.
In the report the attribute `latest_controls` contains all the controls exposed by scope and/or plugins, but only those alive will be listed in the attribute `controls`.

This comment was marked as abuse.

site/plugins.md Outdated
### Metadata
All metadata entries are placed within nodes in the section named `latest`.
This section contains the latest values to display and consists of `timestamp` and `value`.
Both should be written as strings in the json (with the double quotes).

This comment was marked as abuse.

site/plugins.md Outdated
- `dataType` specifies the type of data, this will determine how the value is displayed. Possible values for this attribute are: "number", "ip", "datetime" and "" for strings.
- `priority` is a floating point value used to decide the display ordering (lower values are displayed before higher ones). If omitted, the UI will display it last.
- `from` indicates where to look for the metadata. The possible values are:
- `latest`

This comment was marked as abuse.

site/plugins.md Outdated
- `metric-template-id` and `id` identify a particular metric template.
- `label` contains the label that will be used by Scope UI.
- `format` describes how the metrics is formatted.
- `percent` the metric value is a percentage.

This comment was marked as abuse.

@alban
Copy link
Contributor

alban commented Apr 13, 2017

@ekimekim: please take a second look

Copy link
Contributor

@ekimekim ekimekim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot better but still missing some important information.

- `Pods` nodes represent all Kubernetes pods running on hosts running probes.
- `Service` nodes represent all Kubernetes services running on hosts running probes.
- `Deployment` nodes represent all Kubernetes deployments running on hosts running probes.
- `ReplicaSet` nodes represent all Kubernetes ReplicaSets running on hosts running probes.

This comment was marked as abuse.

This comment was marked as abuse.

site/plugins.md Outdated
```

Nodes are stored in a dictionary.
The ID of nodes representing hosts or containers has the format `ID;<type>`, with type equal to the literal string `host` or `container` respectively.

This comment was marked as abuse.

This comment was marked as abuse.

site/plugins.md Outdated
}
```

- `metadata-template-identifier` and `id` identify a particular metadata template.

This comment was marked as abuse.

This comment was marked as abuse.

site/plugins.md Outdated
- `from` indicates where to look for the metadata. The possible values are:
- `latest`
- `sets`
- `counters`

This comment was marked as abuse.

This comment was marked as abuse.

@schu
Copy link
Contributor

schu commented Apr 18, 2017

@ekimekim please take a look again.

Copy link
Contributor

@ekimekim ekimekim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last thing worth mentioning I just thought of. But everything currently here looks good. I'm happy to merge as is.

site/plugins.md Outdated
@@ -467,6 +467,8 @@ In particular, a node may contain:
- `latest` - an id-value map containing the latest values. Each id has only one value.
- `latestControls` - the latest available controls.
- `metrics` - the collection of metrics to display in the UI. Each metric has multiple timestamped values.
- `sets` - a string->set-of-strings map, for example a list of local networks.
- `counters` - a string->int map.

This comment was marked as abuse.

This comment was marked as abuse.

Copy link
Contributor

@abuehrle abuehrle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small tweaks to the text

site/plugins.md Outdated
@@ -16,7 +16,8 @@ The following topics are discussed:
* [Naming Nodes](#naming-nodes)
* [A Guide to Developing Plugins](#plugins-developing-guide)
* [Setting up the Structure](#structure)
* [Defining the Reporter Interface](#reporter-interface)
* [Defining the Reporter Interface](#defining-reporter-interface)
* [Report Data Structures](#report-data-structures)

Any kind of metrics can be generated and inserted into Scope using custom plugins. Metrics generated through your plugin are displayed in the user interface alongside the standard set of metrics that are found in Weave Scope.

This comment was marked as abuse.

site/plugins.md Outdated
Topologies can be of various types.
Each topology consists of some general information and a list of nodes.
These are the available topologies:

This comment was marked as abuse.

This comment was marked as abuse.

site/plugins.md Outdated
All metadata entries are placed within nodes in the section named `latest`.
This section contains the latest values to display and consists of `timestamp` and `value`.
Both should be written as json strings (with double quotes).
Scope uses `metadata_templates` to know how to display such data.

This comment was marked as abuse.

site/plugins.md Outdated

### Metadata Templates
Metadata Templates describe a particular metadata item.
This description is used to extract metadata from a node and display it on Scope UI.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

This comment was marked as abuse.

site/plugins.md Outdated
- `id` is a string identifying the particular metadata template (here `traffic-control-pktloss`) and is also used as a key to the template value.
- `label` contains the label that will be used by Scope UI.
- `dataType` specifies the type of data, this will determine how the value is displayed. Possible values for this attribute are: "number", "ip", "datetime" and "" for strings.
- `priority` is a floating point value used to decide the display ordering (lower values are displayed before higher ones). If omitted, the UI will display it last.

This comment was marked as abuse.

site/plugins.md Outdated

### Table Templates
Table Templates describe a table and how to identify which metadata templates belong to the table.

This comment was marked as abuse.

site/plugins.md Outdated
- `prefix` is used to identify which metadata templates belong to the table.

If you want to display data in a table, you have to define a table template and prepend the table prefix to all the metadata templates that identify the data you want to put in such table.

This comment was marked as abuse.

site/plugins.md Outdated
Scope uses the `metric_templates` to know how to display such data. To pair a metric with its template, it is necessary to use the `metric-template-id` as key to identify that particular metric.
Metrics are suitable for information such as CPU and memory usage, HTTP requests rate, I/O operations, etc.
The following is an example of a report with a metric preceded by its metric template:

This comment was marked as abuse.

site/plugins.md Outdated
- `metric-template-id` and `id` identify a particular metric template.
- `label` contains the label that will be used by Scope UI.
- `format` describes how the metrics is formatted.
- `percent` the metric value is a percentage.

This comment was marked as abuse.

site/plugins.md Outdated
The default window is 15 seconds.
You may change the window value using the option `-app.window <SECONDS>` when launching scope.
However, using values smaller than 15 seconds increases the chance of information not being correctly displayed.

This comment was marked as abuse.

@alban alban force-pushed the alessandro/data-structures branch from 4a4a248 to 1bc0bca Compare April 26, 2017 12:36
@alban
Copy link
Contributor

alban commented Apr 26, 2017

Thanks for the review, I rebased & pushed a new commit with changes from @abuehrle's review.

@alban
Copy link
Contributor

alban commented Apr 26, 2017

lint complains in CircleCI after the rebase, even after a CircleCI build without cache:

cd $SRCDIR; make RM= lint
docker run  -ti \
		-v /home/ubuntu/src/github.com/weaveworks/scope:/go/src/github.com/weaveworks/scope \
		-v /home/ubuntu/src/github.com/weaveworks/scope/.pkg:/go/pkg \
		--net=host \
		-e GOARCH -e GOOS -e CIRCLECI -e CIRCLE_BUILD_NUM -e CIRCLE_NODE_TOTAL \
		-e CIRCLE_NODE_INDEX -e COVERDIR -e SLOW -e TESTDIRS \
		weaveworks/scope-backend-build SCOPE_VERSION=1bc0bca2 GO_BUILD_INSTALL_DEPS=-i CODECGEN_UID=0 lint
make: Entering directory '/go/src/github.com/weaveworks/scope'

./tools/lint -ignorespelling "agre " -ignorespelling "AGRE " .

./extras/dialer/dialer:24:27: reached } without matching [ with ]

./extras/dialer/dialer: run shfmt -i 4 -w ./extras/dialer/dialer

./extras/dialer/time-scope-probe-cgroup:31:18: arithmetic expressions must consist of names and numbers

...

I don't understand why: this PR only changes the documentation, not the code.

@ekimekim
Copy link
Contributor

At a guess: this may be another case of a bug I feel I've seen before (maybe only locally? i don't recall) where "no code files changed" somehow becomes "check all files". I'll check it out. In the meantime, feel free to ignore the failing lint check and we can merge once @abuehrle is happy.

@abuehrle
Copy link
Contributor

LGTM

@ekimekim ekimekim merged commit e127392 into weaveworks:master Apr 26, 2017
@alban
Copy link
Contributor

alban commented Apr 27, 2017

For the record, CircleCI was happy with this PR once it got merged into master: https://circleci.com/gh/weaveworks/scope/7076

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants