Git Product home page Git Product logo

snap-plugin-collector-docker's Introduction

DISCONTINUATION OF PROJECT.

This project will no longer be maintained by Intel.

This project has been identified as having known security escapes.

Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project.

Intel no longer accepts patches to this project.

DISCONTINUATION OF PROJECT

This project will no longer be maintained by Intel. Intel will not provide or guarantee development of or support for this project, including but not limited to, maintenance, bug fixes, new releases or updates. Patches to this project are no longer accepted by Intel. If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the community, please create your own fork of the project.

Build Status

Snap collector plugin - Docker

This plugin collects runtime metrics from Docker containers and its host machine. It gathers information about resource usage and performance characteristics.

It's used in the Snap framework.

  1. Getting Started
  1. Documentation
  1. Community Support
  2. Contributing
  3. License
  4. Acknowledgements

Getting Started

In order to use this plugin you need Docker Engine installed. Visit Install Docker Engine for detailed instructions how to do it. Plugin was tested against Docker version 1.12.3.

Operating systems

Installation

Download the plugin binary:

You can get the pre-built binaries for your OS and architecture from the plugin's GitHub Releases page. Download the plugin from the latest release and load it into snapteld (/opt/snap/plugins is the default location for Snap packages).

To build the plugin binary:

Fork https://github.com/intelsdi-x/snap-plugin-collector-docker Clone repo into $GOPATH/src/github.com/intelsdi-x/:

$ git clone https://github.com/<yourGithubID>/snap-plugin-collector-docker.git

Build the Snap docker plugin by running make within the cloned repo:

$ make

It may take a while to pull dependencies if you haven't had them already. This builds the plugin in ./build/

Configuration and Usage

Configuration parameters

It's possible to provide configuration to plugin via task manifest.

In order to setup Docker Remote API endpoint and procfs path in workflow section of a task configuration file it is necessary to include following:

workflow: 
  collect: 
    config: 
      /intel/docker: 
        endpoint: "<DOCKER_REMOTE_API_ENDPOINT>"
        procfs: "<PATH_TO_PROCFS>"

where DOCKER_REMOTE_API_ENDPOINT is an endpoint that is being used to communicate with Docker daemon via Docker Remote API, where PATH_TO_PROCFS is a path to proc filesystem on host.

For more information see Docker Remote API reference

Documentation

There are a number of other resources you can review to learn to use this plugin:

Notice, that this plugin using default docker server endpoint unix:///var/run/docker.sock to communicate with docker deamon. However, adding support for custom endpoints is on Roadmap.

Client instance ready for communication with the given // server endpoint. It will use the latest remote API version available in the // server.

Collected Metrics

The list of collected metrics is described in METRICS.md.

Examples

Similar to dream levels in the movie Inception, we have different levels of examples:

  • LEVEL 0: Snap running on your system (Linux only).
  • LEVEL 1: Snap runs in a container.
  • LEVEL 2: Snap runs in a docker-in-docker container.

For the sake of ease-of-use, these examples are presented in reverse order.

Run example in a docker-in-docker container

./examples/tasks/run-docker-file.sh

Run example in a docker container (Linux or Darwin only)

./examples/tasks/run-dockerception.sh

Run example on your Linux system

Check if there is some running docker container(s):

$ docker ps

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
7720efd76bb8        ubuntu              "/bin/bash"         35 minutes ago      Up 35 minutes                           prickly_spence
ad5221e8ae73        ubuntu              "/bin/bash"         36 minutes ago      Up 36 minutes                     		suspicious_mirzakhani

In one terminal window, start the Snap daemon (in this case with logging set to 1 and trust disabled):

$ snapteld -l 1 -t 0

In another terminal window download and load plugins:

$ wget http://snap.ci.snap-telemetry.io/plugins/snap-plugin-collector-docker/latest/linux/x86_64/snap-plugin-collector-docker
$ wget http://snap.ci.snap-telemetry.io/plugins/snap-plugin-publisher-file/latest/linux/x86_64/snap-plugin-publisher-file
$ chmod 755 snap-plugin-*
$ snaptel plugin load snap-plugin-collector-docker
$ snaptel plugin load snap-plugin-publisher-file

You can list all of available metrics:

$ snaptel metric list

Download an example task file and load it:

$ curl -sfLO https://raw.githubusercontent.com/intelsdi-x/snap-plugin-collector-docker/master/examples/tasks/docker-file.json
$ snaptel task create -t docker-file.json
Using task manifest to create task
Task created
ID: 02dd7ff4-8106-47e9-8b86-70067cd0a850
Name: Task-02dd7ff4-8106-47e9-8b86-70067cd0a850
State: Running

See output from snaptel task watch <task_id>

(notice, that below only the fragment of task watcher output has been presented)

$ snaptel task watch 02dd7ff4-8106-47e9-8b86-70067cd0a850
Watching Task (02dd7ff4-8106-47e9-8b86-70067cd0a850):
NAMESPACE                                                                    DATA      		TIMESTAMP
/intel/docker/7720efd76bb8/cgroups/cpu_stats/cpu_usage/total           2.146646e+07       2016-06-21 12:44:09.551811277 +0200 CEST
/intel/docker/7720efd76bb8/cgroups/cpu_stats/cpu_usage/kernel_mode           1e+07              2016-06-21 12:44:09.552107446 +0200 CEST
/intel/docker/7720efd76bb8/cgroups/cpu_stats/cpu_usage/user_mode             0                  2016-06-21 12:44:09.552146203 +0200 CEST
/intel/docker/ad5221e8ae73/cgroups/cpu_stats/cpu_usage/total           2.146646e+07       2016-06-21 12:44:09.551811277 +0200 CEST
/intel/docker/ad5221e8ae73/cgroups/cpu_stats/cpu_usage/kernel_mode           1e+07              2016-06-21 12:44:09.552107446 +0200 CEST
/intel/docker/ad5221e8ae73/cgroups/cpu_stats/cpu_usage/user_mode             0                  2016-06-21 12:44:09.552146203 +0200 CEST
/intel/docker/root/cgroups/cpu_stats/cpu_usage/total                   2.88984998661e+12  2016-06-21 12:44:09.551811277 +0200 CEST
/intel/docker/root/cgroups/cpu_stats/cpu_usage/kernel_mode                   6.38e+11            2016-06-21 12:44:09.552107446 +0200 CEST
/intel/docker/root/cgroups/cpu_stats/cpu_usage/user_mode                     9.4397e+11          2016-06-21 12:44:09.552146203 +0200 CEST

(Keys ctrl+c terminate task watcher)

These data are published to file and stored there (in this example in /tmp/snap-docker-file.log).

Roadmap

There isn't a current roadmap for this plugin, but it is in active development. As we launch this plugin, we do not have any outstanding requirements for the next release.

If you have a feature request, please add it as an issue and/or submit a pull request.

Community Support

This repository is one of many plugins in snap, a powerful telemetry framework. See the full project at http://github.com/intelsdi-x/snap.

To reach out to other users, head to the main framework or visit Slack.

Contributing

We love contributions!

There's more than one way to give back, from examples to blogs to code updates. See our recommended process in CONTRIBUTING.md.

License

Snap, along with this plugin, is an Open Source software released under the Apache 2.0 License.

Acknowledgements

Thank you! Your contribution is incredibly important to us.

snap-plugin-collector-docker's People

Contributors

andrzej-k avatar brharrington avatar candysmurf avatar croseborough avatar denismakogon avatar geauxvirtual avatar izabellaraulin avatar janczer avatar jcooklin avatar katarzyna-z avatar kdembler avatar kindermoumoute avatar lmroz avatar marcin-krolik avatar marcin-ol avatar marcintao avatar mkleina avatar nanliu avatar nguyenddn avatar patrykmatyjasek avatar rdower avatar sandlbn avatar taotod avatar tiffanyfay avatar zhengqingyuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

snap-plugin-collector-docker's Issues

panic when getting disk usage

Snap version (use snapctl -v):
test-4ac7b4d (docker container built from intelsdi/snap:xenial)

Environment:

  • Cloud provider or hardware configuration: Running in Kubernetes on baremetal
  • OS (e.g. from /etc/os-release): Ubuntu xenial
  • Kernel (e.g. uname -a): 4.2.0-36-generic
  • Relevant tools (e.g. plugins used with Snap):
  • Others (e.g. deploying with Ansible): Docker version 1.12.1

What happened:
plugin panics and crashes.

Steps to reproduce it (as minimally and precisely as possible):

I am unsure of why the panic is being triggered. Perhaps a race condition where a path existed but removed before du -s is executed.

Anything else do we need to know (e.g. issue happens only occasionally):

time="2016-11-07T10:27:12Z" level=debug msg="panic: runtime error: index out of range" _module=plugin-exec io=stderr plugin=snap-plugin-collector-docker 
time="2016-11-07T10:27:12Z" level=debug _module=plugin-exec io=stderr plugin=snap-plugin-collector-docker 
time="2016-11-07T10:27:12Z" level=debug msg="goroutine 5 [running]:" _module=plugin-exec io=stderr plugin=snap-plugin-collector-docker 
time="2016-11-07T10:27:12Z" level=debug msg="panic(0x88dd40, 0xc420012090)" _module=plugin-exec io=stderr plugin=snap-plugin-collector-docker 
time="2016-11-07T10:27:12Z" level=debug msg="\t/home/travis/.gimme/versions/go1.7.1.linux.amd64/src/runtime/panic.go:500 +0x1a1" _module=plugin-exec io=stderr plugin=snap-plugin-collector-docker 
time="2016-11-07T10:27:12Z" level=debug msg="github.com/intelsdi-x/snap-plugin-collector-docker/fs.diskUsage(0x9254e1, 0xf, 0xc42003aee8, 0xc42003ae78, 0x0)" _module=plugin-exec io=stderr plugin=snap-plugin-collector-docker 
time="2016-11-07T10:27:12Z" level=debug msg="\t/home/travis/gopath/src/github.com/intelsdi-x/snap-plugin-collector-docker/fs/fs.go:371 +0x177" _module=plugin-exec io=stderr plugin=snap-plugin-collector-docker 
time="2016-11-07T10:27:12Z" level=debug msg="github.com/intelsdi-x/snap-plugin-collector-docker/fs.(*DiskUsageCollector).worker.func1(0xb742f0, 0xc4200ffd00, 0x91dcac, 0x4, 0xc420012fd0, 0x1, 0x1)" _module=plugin-exec io=stderr plugin=snap-plugin-collector-docker 
time="2016-11-07T10:27:12Z" level=debug msg="\t/home/travis/gopath/src/github.com/intelsdi-x/snap-plugin-collector-docker/fs/fs.go:105 +0x449" _module=plugin-exec io=stderr plugin=snap-plugin-collector-docker 
time="2016-11-07T10:27:12Z" level=debug msg="created by github.com/intelsdi-x/snap-plugin-collector-docker/fs.(*DiskUsageCollector).worker" _module=plugin-exec io=stderr plugin=snap-plugin-collector-docker 
time="2016-11-07T10:27:12Z" level=debug msg="\t/home/travis/gopath/src/github.com/intelsdi-x/snap-plugin-collector-docker/fs/fs.go:119 +0x80" _module=plugin-exec io=stderr plugin=snap-plugin-collector-docker 

loading the plugin error

The plugin cannot be loaded as its dynamic metric types don't have Name defined. Please see the error below:

NAP_PATH/bin/snapctl plugin load $SNAP_PATH/../../snap-plugin-collector-docker/build/rootfs/snap-plugin-collector-docker
Error loading plugin:
A dynamic element * requires a name for namespace /intel/linux/docker/*/cpu_stats/cpu_usage/total_usage.

If using auto-discovery flag to start Snap, listing loaded plugins, the snap-plugin-collector-docker was not shown but the metric list shown some metrics. For example:

intel/linux/docker/574c8997a830/memory_stats/stats/total_unevictable         3
/intel/linux/docker/574c8997a830/memory_stats/stats/total_writeback          3
/intel/linux/docker/574c8997a830/memory_stats/stats/unevictable          3
/intel/linux/docker/574c8997a830/memory_stats/stats/writeback            3
/intel/linux/docker/574c8997a830/memory_stats/swap_usage/failcnt         3
/intel/linux/docker/574c8997a830/memory_stats/swap_usage/max_usage       3
/intel/linux/docker/574c8997a830/memory_stats/swap_usage/usage           3
/intel/linux/docker/574c8997a830/memory_stats/usage/failcnt              3
/intel/linux/docker/574c8997a830/memory_stats/usage/max_usage            3
/intel/linux/docker/574c8997a830/memory_stats/usage/usage            3
/intel/mock/*/baz                                1,2
/intel/mock/bar                                  1,2
/intel/mock/foo                                  1,2

Task would be disabled if collecting any of metric containing "docker".

Expose cpu.shares specified per container

In our case there is a max number of shares overall that will be scheduled on a given machine. Shares per container would let us see the requested processing capacity per container and how the actual usage compares to that.

No test for client and fs package

Tests for client/client.go and fs/fs.go should be delivered. It seems that small code refactoring of these packages is needed to mock external lib methods.

CoreOS Support

I am trying to install snap and docker plugin in the CoreOS cluster but it is not working. Is Snap currently supported for CoreOS operating system?

Metrics total_usage has been renamed (backward compatibility broken)

The latest version of plugin exposes metric total instead of total_usage. Readme.md and Metrics.md is out-of-date. "Total_usage" is also used in tests what is misleading.

There should be a consequence in keeping metric namespace across plugin code, documentation, and tests. Also, unnecessary renaming should be avoided in the future.

cc: @intelsdi-x/snap-maintainers

Cgroups driver incorrectly handled on RHEL

Plugin is not working properly on RHEL with Docker running cgroupfs as CGroup driver. In general handling of CGroup driver is incorrectly implemented. Additionally openlibcontainers/runc lib is quite limiting enhancements to collected metrics.

document the docker endpoint config

#59 and #62 is introducing a new endpoint config. We should remove this from the wishlist, document the default value, and provide example configs on how to use the tcp endpoint.

Support for docker on Windows

Our docker collector should also support getting metrics from docker container running in Windows environment. Ideally with the same set of metrics as for Linux version.

Add Kubernetes labels as tags to docker metrics

It would be good to tag docker metrics collected in Kubernetes environment with Kubernetes labels. Those labels are currently available as a separate metric /intel/docker/<docker_id>/spec/labels/<label_key>/value. This metric shouldn't be removed thou from the list of metrics collected by this plugin.

docker-collector hang up few second after startup

Dears!
Something is wrong when I try to create task however I am not able to solve it.
No idea if configuration error or bug.
It would be great if you may offer any solution of this issue
or in better way some manifest and all other settings for correct run on Ubuntu 16.04 server.

Thanks for your reaction,
Best Regards,
Richard

P.S.: Docker CE is the latest same as on monitored system.

Snap daemon version (use snapteld -v):
snaptel version 1.3.0

Environment:

  • Cloud provider or hardware configuration:
    Intel i7/32GBy RAM/SSD 240GBy Intel
  • OS (e.g. from /etc/os-release):
    Ubuntu 16.04 Server
  • Kernel (e.g. uname -a):
    Linux ubuntu 4.4.0-62-generic #83-Ubuntu SMP Wed Jan 18 14:10:15 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  • Relevant tools (e.g. plugins used with Snap):
    snaptel plugin load snap-plugin-collector-docker
    snaptel plugin load snap-plugin-publisher-file

What happened:
snaptel task hang in any case after few seconds.
No way to run it successfuly.

What you expected to happen:
snaptel task runs successfuly and send values to file-publisher.

Steps to reproduce it (as minimally and precisely as possible):
clear
echo "Intel Snap restarting..."
service snap-telemetry start
sleep 10s
sudo docker -v
rm -f snap-plugin-collector-docker
rm -f snap-plugin-publisher-file
wget http://snap.ci.snap-telemetry.io/plugins/snap-plugin-collector-docker/latest/linux/x86_64/snap-plugin-collector-docker
wget http://snap.ci.snap-telemetry.io/plugins/snap-plugin-publisher-file/latest/linux/x86_64/snap-plugin-publisher-file
chmod 755 snap-plugin-*
snaptel plugin load snap-plugin-collector-docker
snaptel plugin load snap-plugin-publisher-file
snaptel plugin list
snaptel metric list
//// curl -sfLO https://raw.githubusercontent.com/intelsdi-x/snap-plugin-collector-docker/master/examples/tasks/docker-file.json
snaptel task create -t docker-file.json
//// HANG ALLWAYS after few seconds
snaptel task list

Anything else do we need to know (e.g. issue happens only occasionally):
DOCKER:
Docker version 17.06.0-ce, build 02c1d87

FILE:
docker-file.json
{
"version": 1,
"schedule": {
"type": "simple",
"interval": "5s"
},
"workflow": {
"collect": {
"metrics": {
"/intel/docker//spec/": {},
"/intel/docker//stats/cgroups/cpu_stats/": {},
"/intel/docker//stats/cgroups/memory_stats/": {}
},
"config": {
"/intel/docker": {
"endpoint": "http://localhost:2375",
"procfs": "/proc"
}
},
"publish": [
{
"plugin_name": "file",
"config": {
"file": "/tmp/snap-docker-file.log"
}
}
]
}
}
}

FILE:
"/lib/systemd/system/docker.service"
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service
Wants=network-online.target
Requires=docker.socket

[Service]
Type=notify

ExecStart=/usr/bin/dockerd -H fd:// -H=tcp://0.0.0.0:2375

ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target

OUTPUT:
...
/intel/docker//stats/network//tx_dropped 8
/intel/docker//stats/network//tx_errors 8
/intel/docker//stats/network//tx_packets 8
Using task manifest to create task
Task created
ID: 663138f6-6b4b-423c-b9b3-e04f58e98390
Name: Task-663138f6-6b4b-423c-b9b3-e04f58e98390
State: Running
//// ID NAME STATE HIT MISS FAIL CREATED LAST FAILURE
//// 663138f6-6b4b-423c-b9b3-e04f58e98390 Task-663138f6-6b4b-423c-b9b3-e04f58e98390 //// Running 0 0 0 5:01AM 8-07-2017
grafana@ubuntu:/intelSnap$ snaptel task list
//// ID NAME STATE HIT MISS FAIL CREATED LAST FAILURE
//// 663138f6-6b4b-423c-b9b3-e04f58e98390 Task-663138f6-6b4b-423c-b9b3-e04f58e98390 Running 2 0 2 5:01AM 8-07-2017 rpc error: code = 5 desc = open /proc/0/mountinfo: no such file or directory
grafana@ubuntu:
/intelSnap$

Cannot build docker images

As this plugin references an old Snap build, the following error occurred when run:

snap-plugin-collector-docker/scripts/run_test_snap_plugin_collector_docker_darwin.sh 

The error was:

20:38:25 # cd .; git clone https://code.google.com/p/go-decimal-inf.exp /tmp/gopath.IfIt0s/src/speter.net/go/exp/math/dec/inf
20:38:25 Cloning into '/tmp/gopath.IfIt0s/src/speter.net/go/exp/math/dec/inf'...
20:38:25 fatal: repository 'https://code.google.com/p/go-decimal-inf.exp/' not found
20:38:25 godep: error downloading dep (speter.net/go/exp/math/dec/inf): exit status 128
20:38:25 godep: Error downloading some deps. Aborting restore and check.

Filesystem metrics not available

Environment:

  • Cloud provider or hardware configuration: bare metal with docker and kubernetes
  • Docker in version 1.12, unsure what was configuration of kubernetes cluster, maybe @mkuculyma can provide details if required

What happened:
Filesystem metrics are not collected for containers, ex. requesting /intel/docker/*/stats/filesystem/*/base_usage returns 0 metrics

What you expected to happen:
Make it work :)

Anything else do we need to know (e.g. issue happens only occasionally):
I tried to debug this issue yesterday, worker thread is collecting stats for directory of interest (however, result might be incorrect because du -sx [dir] is not traversing subdirectories nor its done manually in code). This code is riddle for me, some functions are left unused (i.e. updateContainerImagesPath). Perhaps this functionality have been broken during one of refactors and this is rather platform independent.

Use logrus to logging in docker plugin

More logs to trace collection process are needed but they should be depended on the set log level. Such logs should have fields with full information what happens, for example:

logrus.WithFields(logrus.Fields{
    "_block": "GetStatsFromContainer",
    "_id": container_id,
}).Info("Getting stats from docker container")

It will be helpful for debug purpose.

Make use of wildcards for metrics

Snap's metric types can use * for wildcards in a namespace, which allows a one-to-many collection.

For example, the metric /intel/linux/docker/<container id>/cpu_stats/cpu_usage/percpu_usage/0 could be represented as/intel/linux/docker/*/cpu_stats/cpu_usage/percpu_usage/0 which would result in collecting percpu_usage/0 for all containers on a given host.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.