Snap open telemetry framework integration with Kubernetes.
10K+
Dockerfile links0.1, latest (snap4kube/Dockerfile)tribe(snap4kube/Dockerfile)Snap is an open source telemetry framework. It can be deployed to collect metrics in various environments including Docker containers and Kubernetes. It can be run in a Docker container to gather metrics i.e. from host and other containers. Deployment of Snap in Kubernetes cluster gives a possibility to monitor pods in the cluster. You can find more information on how to run Snap in those environments here. If you want to know how to use Snap in tribe mode you will find more information here.
In order to run Snap in a single docker container you simply run the command:
$ docker run -d --name snap -p 8181:8181 intelsdi/snap4kube:latest
To verify that Snap container has started correctly and perform some actions to start collection of metrics we need to log into the Snap container. Getting into the container is quite simple:
$ docker exec -ti snap bash
Now that you are inside the container with running Snap daemon, you may run command to list the plugins:
$ snaptel plugin list
The output should be No plugins found. Have you loaded a plugin? as there are no plugins loaded yet. Let's download some...
Inside a container you may use many different Snap plugins. Most of them require configuration. All of the plugins requirements can be found in their documentation.
In this section we show how to configure and load CPU plugin collector inside a container. The documentation of the Snap CPU plugin collector can be found here. As it is stated in the documentation, the CPU plugin collector gathers information from the file /proc/stat residing in the host machine. Running this plugin inside the container requires mapping of this file inside of the container. The original host file /proc/stat has to be available inside of the container. This means that we have to adjust Snap container in order to be able to use CPU plugin inside it.
In a Docker container mapping of the files is done with the addition of -v flag when running the container.
$ docker run -d --name snap -v <path-to-file-on-host>:<path-to-file-in-container> intelsdi/snap4kube:latest
So, to run Snap with CPU plugin reading resource usage from host you need to use command as below.
$ docker run -d --name snap -v /proc:/proc_host intelsdi/snap4kube:latest
If you get the error Conflict. The name "/snap" is already in use by container 0c8552a92025293b663ac458dd5f2133b5c825f1840fa4169f6957246c424503. You have to remove (or rename) that container to be able to reuse that name.. you have to remove running Snap container:
$ docker rm -f snap
and then create it one more time:
$ docker run -d --name snap -v /proc:/proc_host intelsdi/snap4kube:latest
Now that we have Snap container configured, we may download and load CPU collector plugin...
$ curl -fsL "https://github.com/intelsdi-x/snap-plugin-collector-cpu/releases/download/6/snap-plugin-collector-cpu_linux_x86_64" -o snap-plugin-collector-cpu
$ snaptel plugin load snap-plugin-collector-cpu
...and file publisher plugin:
$ curl -fsL "https://github.com/intelsdi-x/snap-plugin-publisher-file/releases/download/2/snap-plugin-publisher-file_linux_x86_64" -o snap-plugin-publisher-file
$ snaptel plugin load snap-plugin-publisher-file
Now, running the command:
$ snaptel plugin list
will print information about the two loaded plugins. To start the collection of metrics you can create task.
$ curl -sO "https://raw.githubusercontent.com/intelsdi-x/snap-integration-kubernetes/master/examples/tasks/cpu-file.json?token=AGOJ_5_Elzt_pLnxbbHgXvTDKQrt_uyeks5YdMSiwA%3D%3D"
$ snaptel task create -t snap-integration-kubernetes/examples/tasks/cpu-file.json
Command:
$ snaptel task list
will provide information whether the metrics collection was successful or not. Use task watch to verify that tasks have been created correctly.
$ snaptel task watch <task-id>
Inside Docker container it is possible to load most of the Snap plugins. The list of all Snap plugins is available in Plugin Catalog. After you choose plugin you click the plugin name. This redirects you to the plugin repository.
To use plugin inside the container you need to download its binary. In order to get plugin binary URL you go to the release section and copy the link for the latest plugin release.
Many of the plugins require prior configuration and adjustment of container. The example of such plugin is Snap Docker collector plugin. The Docker collector allows to collect runtime metrics from Docker containers and its host machine. It gathers information about resource usage and performance characteristics. More information about docker collector can be found here.
All of the plugins requirements can be found in their documentation. The documentation of the Snap Docker plugin collector can be found here. Docker plugin collector needs access to files residing in the host machine:
/var/run/docker.sock/proc/usr/bin/docker/var/lib/docker/sys/fs/cgroupThis means that the original host files have to be available inside of the container. Running this plugin inside the container requires mapping of those files inside of the container. What is more, Docker collector plugin requires enviroment variable PROCFS_MOUNT to be set. It should point to the directory inside the container where original host directorry /proc is mounted.
In a Docker container mapping of the files is done with the addition of -v flag when running the container.
$ docker run -d --name snap -v <path-to-file-on-host>:<path-to-file-in-container> intelsdi/snap4kube:latest
The enviroment variable PROCFS_MOUNT must also be set. In Docker this is done with the use of -e flag when running the container.
$ docker run -d --name snap -v <path-to-file-on-host>:<path-to-file-in-container> -e PROCFS_MOUNT=<path-to-file-in-container> intelsdi/snap4kube:latest
So, to run Snap with Docker collector plugin gathering metrics from host you need to use command as below.
$ docker run -d --name snap -v /proc/host:/proc_host -e PROCFS_MOUNT=/proc_host intelsdi/snap4kube:latest
To verify that Snap container has started correctly and load Docker collector plugin we need to log into the Snap container. Getting into the container is quite simple:
$ docker exec -ti snap bash
Now that you are inside the container with running Snap daemon, you may download and load Docker collector plugin using plugin binary URL from release section in plugin's repository.
$ curl -fsL "https://github.com/intelsdi-x/snap-plugin-collector-docker/releases/download/5/snap-plugin-collector-docker_linux_x86_64" -o snap-plugin-collector-docker
$ snaptel plugin load snap-plugin-collector-docker
Load file publisher:
$ curl -fsL "https://github.com/intelsdi-x/snap-plugin-publisher-file/releases/download/2/snap-plugin-publisher-file_linux_x86_64" -o snap-plugin-publisher-file
$ snaptel plugin load snap-plugin-publisher-file
Running command:
$ snaptel plugin list
will print information about the two loaded plugins. To start the collection of metrics you can create task.
$ curl -sO https://raw.githubusercontent.com/intelsdi-x/snap-plugin-collector-docker/master/examples/docker-file.json
$ snaptel task create -t ./docker-file.json
Command:
$ snaptel task list
will provide information whether the metrics collection was successful or not.
This way you may download and load almost any Snap plugin inside the Docker container.
Content type
Image
Digest
Size
122.7 MB
Last updated
over 9 years ago
docker pull intelsdi/snap4kube