Skip to content
This repository has been archived by the owner on Mar 14, 2022. It is now read-only.

Commit

Permalink
Merge pull request #6 from signalfx/mv_metric_namepart_to_dim
Browse files Browse the repository at this point in the history
Refactor cpucore and blkio metrics to define core and block devices as dimensions
  • Loading branch information
beccatortell authored Aug 8, 2016
2 parents 8a3f8e3 + 55bc78d commit acddf48
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 7 deletions.
55 changes: 55 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
### CHANGELOG

This file documents important changes to the Docker plugin for collectd.

- [2016-08-03: Dimensionalize block I/O and CPU per-core metrics](#2016-08-03-dimensionalize-block-i-o-and-cpu-per-core-metrics)

#### 2016-08-03: Dimensionalize block I/O and CPU per-core metrics

Prior to this update, the plugin transmitted block I/O and CPU per-core metrics
with the names of the block device and CPU core respectively included as part of
the metric name. In this update, this information has been removed from metric
names to dimensions.

SignalFx's built-in dashboards have been updated to accommodate metrics from
both before and after this change.

When you upgrade to this version, any custom SignalFx charts and detectors that
you have built that include block I/O or per-core CPU metrics may need to be
modified to include the new metric names. Modify charts as follows:

1. Whenever a chart uses an affected metric (see below), add a new plot to the
chart that uses the new metric name instead.
1. On the new plot, apply a filter by the new dimensions, with a value that
matches the contents of the previous metric name.
1. If your chart uses a timeseries expression that refers to the previous metric,
clone the expression, then modify any letter references in the clone to refer to
the new plot instead of the old one.

For detectors, follow the procedure above, then select the new plot or new
timeseries expression as the signal.

##### Block I/0: blkio.io_service_bytes_recursive.*

In this update, the block device identifier has been moved from metric names
to the dimensions called "device_major" and "device_minor".

For example:

| | Metric name | device_major | device_minor |
|--------|-------------|--------------|--------------|
| Before | `blkio.io_service_bytes_recursive-252-0.read` | _n/a_ | _n/a_ |
| After | `blkio.io_service_bytes_recursive.read` | `252` | `0` |


##### CPU statistics per core: cpu.percpu.usage

In this update, the CPU core identifier has been moved from metric names to
the dimension called "core".

For example:

| | Metric name | core |
|--------|-------------|--------------|
| Before | `cpu.percpu.usage.cpu0` | _n/a_ |
| After | `cpu.percpu.usage` | `cpu0` |
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ everything else from the plugin:
</Chain>
```

For convenience, you'll find those configuration blocks in the provided
sample configuration file [`dockerplugin.conf`](dockerplugin.conf).
For convenience, you'll find those configuration blocks in the example configuration file [`10-docker.conf`](https://github.com/signalfx/integrations/blob/master/collectd-docker/10-docker.conf).

## Requirements

Expand Down
24 changes: 19 additions & 5 deletions dockerplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,34 @@ def read_blkio_stats(container, dimensions, stats, t):
# numbers). We need to group and report the stats of each block
# device independently.
blkio_stats = {}
blkio_major_stats = {}
blkio_minor_stats = {}

for value in values:

k = '{key}-{major}-{minor}'.format(key=key,
major=value['major'],
minor=value['minor'])

if k not in blkio_stats:
blkio_stats[k] = []
blkio_stats[k].append(value['value'])
blkio_major_stats[k] = value['major']
blkio_minor_stats[k] = value['minor']

for type_instance, values in blkio_stats.items():
# add block device major and minor as dimensions
blkioDims = dimensions.copy()
blkioDims['device_major'] = str(blkio_major_stats[type_instance])
blkioDims['device_minor'] = str(blkio_minor_stats[type_instance])

if len(values) == 5:
emit(container, dimensions, 'blkio', values,
type_instance=type_instance, t=t)
emit(container, blkioDims, 'blkio', values,
type_instance=key, t=t)
elif len(values) == 1:
# For some reason, some fields contains only one value and
# the 'op' field is empty. Need to investigate this
emit(container, dimensions, 'blkio.single', values,
emit(container, blkioDims, 'blkio.single', values,
type_instance=key, t=t)
else:
log.warning(('Unexpected number of blkio stats for '
Expand All @@ -150,8 +162,10 @@ def read_cpu_stats(container, dimensions, stats, t):
cpu_usage = stats['cpu_usage']
percpu = cpu_usage['percpu_usage']
for cpu, value in enumerate(percpu):
emit(container, dimensions, 'cpu.percpu.usage', [value],
type_instance='cpu%d' % (cpu,), t=t)
percpuDims = dimensions.copy()
percpuDims['core'] = ('cpu%d' % (cpu))
emit(container, percpuDims, 'cpu.percpu.usage', [value],
type_instance='', t=t)

items = sorted(stats['throttling_data'].items())
emit(container, dimensions, 'cpu.throttling_data',
Expand Down

0 comments on commit acddf48

Please sign in to comment.