feature(kubernetes plugin): Adds support for a kuberentes plugin

fixes #569
This commit also refactors the existing docker plugin so that the
kubernetes plugin can gather metrics from the docker system.
This commit is contained in:
Jonathan Chauncey 2016-01-26 15:16:46 -07:00
parent a11e07e250
commit f13889d1c9
11 changed files with 906 additions and 300 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ tivan
.idea
*~
*#
vendor/

38
Godeps
View File

@ -3,30 +3,28 @@ github.com/Shopify/sarama d37c73f2b2bce85f7fa16b6a550d26c5372892ef
github.com/Sirupsen/logrus f7f79f729e0fbe2fcc061db48a9ba0263f588252
github.com/amir/raidman 6a8e089bbe32e6b907feae5ba688841974b3c339
github.com/armon/go-metrics 345426c77237ece5dab0e1605c3e4b35c3f54757
github.com/aws/aws-sdk-go 87b1e60a50b09e4812dee560b33a238f67305804
github.com/aws/aws-sdk-go 3ad0b07b44c22c21c734d1094981540b7a11e942
github.com/beorn7/perks b965b613227fddccbfffe13eae360ed3fa822f8d
github.com/boltdb/bolt ee4a0888a9abe7eefe5a0992ca4cb06864839873
github.com/boltdb/bolt 6465994716bf6400605746e79224cf1e7ed68725
github.com/cenkalti/backoff 4dc77674aceaabba2c7e3da25d4c823edfb73f99
github.com/dancannon/gorethink 6f088135ff288deb9d5546f4c71919207f891a70
github.com/dancannon/gorethink ff457cac6a529d9749d841a733d76e8305cba3c8
github.com/davecgh/go-spew 5215b55f46b2b919f50a1df0eaa5886afe4e3b3d
github.com/eapache/go-resiliency b86b1ec0dd4209a588dc1285cdd471e73525c0b3
github.com/eapache/queue ded5959c0d4e360646dc9e9908cff48666781367
github.com/fsouza/go-dockerclient 7b651349f9479f5114913eefbfd3c4eeddd79ab4
github.com/fsouza/go-dockerclient 6fb38e6bb3d544d7eb5b55fd396cd4e6850802d8
github.com/go-ini/ini afbd495e5aaea13597b5e14fe514ddeaa4d76fc3
github.com/go-sql-driver/mysql 7c7f556282622f94213bc028b4d0a7b6151ba239
github.com/gogo/protobuf e8904f58e872a473a5b91bc9bf3377d223555263
github.com/golang/protobuf 6aaa8d47701fa6cf07e914ec01fde3d4a1fe79c3
github.com/go-sql-driver/mysql 72ea5d0b32a04c67710bf63e97095d82aea5f352
github.com/gogo/protobuf c57e439bad574c2e0877ff18d514badcfced004d
github.com/golang/protobuf 2402d76f3d41f928c7902a765dfc872356dd3aad
github.com/golang/snappy 723cc1e459b8eea2dea4583200fd60757d40097a
github.com/gonuts/go-shellquote e842a11b24c6abfb3dd27af69a17f482e4b483c2
github.com/gorilla/context 1c83b3eabd45b6d76072b66b746c20815fb2872d
github.com/gorilla/mux 26a6070f849969ba72b72256e9f14cf519751690
github.com/hailocab/go-hostpool e80d13ce29ede4452c43dea11e79b9bc8a15b478
github.com/hailocab/go-hostpool 50839ee41f32bfca8d03a183031aa634b2dc1c64
github.com/hashicorp/go-msgpack fa3f63826f7c23912c15263591e65d54d080b458
github.com/hashicorp/raft 057b893fd996696719e98b6c44649ea14968c811
github.com/hashicorp/raft b95f335efee1992886864389183ebda0c0a5d0f6
github.com/hashicorp/raft-boltdb d1e82c1ec3f15ee991f7cc7ffd5b67ff6f5bbaee
github.com/influxdata/config bae7cb98197d842374d3b8403905924094930f24
github.com/influxdata/influxdb 697f48b4e62e514e701ffec39978b864a3c666e6
github.com/influxdb/influxdb 697f48b4e62e514e701ffec39978b864a3c666e6
github.com/influxdata/influxdb 0e0f85a0c1fd1788ae4f9145531b02c539cfa5b5
github.com/influxdb/influxdb 0e0f85a0c1fd1788ae4f9145531b02c539cfa5b5
github.com/jmespath/go-jmespath c01cf91b011868172fdcd9f41838e80c9d716264
github.com/klauspost/crc32 999f3125931f6557b991b2f8472172bdfa578d38
github.com/lib/pq 8ad2b298cadd691a77015666a5372eae5dbfac8f
@ -39,21 +37,21 @@ github.com/pborman/uuid dee7705ef7b324f27ceb85a121c61f2c2e8ce988
github.com/pmezard/go-difflib 792786c7400a136282c1664665ae0a8db921c6c2
github.com/prometheus/client_golang 67994f177195311c3ea3d4407ed0175e34a4256f
github.com/prometheus/client_model fa8ad6fec33561be4280a8f0514318c79d7f6cb6
github.com/prometheus/common 14ca1097bbe21584194c15e391a9dab95ad42a59
github.com/prometheus/common 0a3005bb37bc411040083a55372e77c405f6464c
github.com/prometheus/procfs 406e5b7bfd8201a36e2bb5f7bdae0b03380c2ce8
github.com/samuel/go-zookeeper 218e9c81c0dd8b3b18172b2bbfad92cc7d6db55f
github.com/shirou/gopsutil 85bf0974ed06e4e668595ae2b4de02e772a2819b
github.com/shirou/gopsutil 8850f58d7035653e1ab90711481954c8ca1b9813
github.com/soniah/gosnmp b1b4f885b12c5dcbd021c5cee1c904110de6db7d
github.com/streadway/amqp b4f3ceab0337f013208d31348b578d83c0064744
github.com/stretchr/objx 1a9d0bb9f541897e62256577b352fdbc1fb4fd94
github.com/stretchr/testify f390dcf405f7b83c997eac1b06768bb9f44dec18
github.com/wvanbergen/kafka 1a8639a45164fcc245d5c7b4bd3ccfbd1a0ffbf3
github.com/wvanbergen/kazoo-go 0f768712ae6f76454f987c3356177e138df258f8
github.com/zensqlmonitor/go-mssqldb ffe5510c6fa5e15e6d983210ab501c815b56b363
golang.org/x/crypto 1f22c0103821b9390939b6776727195525381532
golang.org/x/net 04b9de9b512f58addf28c9853d50ebef61c3953e
golang.org/x/text 6d3c22c4525a4da167968fa2479be5524d2e8bd0
gopkg.in/dancannon/gorethink.v1 6f088135ff288deb9d5546f4c71919207f891a70
golang.org/x/crypto 3760e016850398b85094c4c99e955b8c3dea5711
golang.org/x/net 72aa00c6241a8013dc9b040abb45f57edbe73945
golang.org/x/text cf4986612c83df6c55578ba198316d1684a9a287
gopkg.in/dancannon/gorethink.v1 e2cef022d0495329dfb0635991de76efcab5cf50
gopkg.in/fatih/pool.v2 cba550ebf9bce999a02e963296d4bc7a486cb715
gopkg.in/mgo.v2 03c9f3ee4c14c8e51ee521a6a7d0425658dd6f64
gopkg.in/yaml.v2 f7716cbe52baa25d2e9b0d0da546fcf909fc16b4
github.com/jchauncey/kubeclient 52ad51a76eed34f58589952b20b4a1d5928cdcd2

327
glide.lock generated Normal file
View File

@ -0,0 +1,327 @@
hash: 72cce248c61fcd2aeb705fdfc7651d6209652785233c51db759c026cb056c746
updated: 2016-02-04T15:41:25.032836149-07:00
imports:
- name: git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.golang.git
version: dbd8d5c40a582eb9adacde36b47932b3a3ad0034
subpackages:
- packets
- name: github.com/amir/raidman
version: 6a8e089bbe32e6b907feae5ba688841974b3c339
subpackages:
- proto
- name: github.com/armon/go-metrics
version: 345426c77237ece5dab0e1605c3e4b35c3f54757
- name: github.com/aws/aws-sdk-go
version: 3ad0b07b44c22c21c734d1094981540b7a11e942
subpackages:
- aws
- aws/credentials
- aws/credentials/ec2rolecreds
- aws/ec2metadata
- aws/session
- service/cloudwatch
- service/kinesis
- aws/awserr
- aws/client
- aws/client/metadata
- aws/request
- aws/corehandlers
- aws/defaults
- private/endpoints
- aws/awsutil
- private/protocol/query
- private/signer/v4
- private/protocol/jsonrpc
- private/waiter
- private/protocol/query/queryutil
- private/protocol/xml/xmlutil
- private/protocol/rest
- private/protocol/json/jsonutil
- name: github.com/beorn7/perks
version: b965b613227fddccbfffe13eae360ed3fa822f8d
subpackages:
- quantile
- name: github.com/boltdb/bolt
version: 6465994716bf6400605746e79224cf1e7ed68725
- name: github.com/cenkalti/backoff
version: 4dc77674aceaabba2c7e3da25d4c823edfb73f99
- name: github.com/dancannon/gorethink
version: ff457cac6a529d9749d841a733d76e8305cba3c8
subpackages:
- encoding
- ql2
- types
- name: github.com/davecgh/go-spew
version: 5215b55f46b2b919f50a1df0eaa5886afe4e3b3d
subpackages:
- spew
- name: github.com/eapache/go-resiliency
version: b86b1ec0dd4209a588dc1285cdd471e73525c0b3
subpackages:
- breaker
- name: github.com/eapache/queue
version: ded5959c0d4e360646dc9e9908cff48666781367
- name: github.com/emicklei/go-restful
version: abf32aacea4194d93badf851494b54a159daddd2
subpackages:
- swagger
- log
- name: github.com/fsouza/go-dockerclient
version: 6fb38e6bb3d544d7eb5b55fd396cd4e6850802d8
subpackages:
- external/github.com/docker/docker/opts
- external/github.com/docker/docker/pkg/archive
- external/github.com/docker/docker/pkg/fileutils
- external/github.com/docker/docker/pkg/homedir
- external/github.com/docker/docker/pkg/stdcopy
- external/github.com/hashicorp/go-cleanhttp
- external/github.com/Sirupsen/logrus
- external/github.com/docker/docker/pkg/idtools
- external/github.com/docker/docker/pkg/ioutils
- external/github.com/docker/docker/pkg/pools
- external/github.com/docker/docker/pkg/promise
- external/github.com/docker/docker/pkg/system
- external/github.com/opencontainers/runc/libcontainer/user
- external/golang.org/x/net/context
- name: github.com/ghodss/yaml
version: 73d445a93680fa1a78ae23a5839bad48f32ba1ee
- name: github.com/go-ini/ini
version: afbd495e5aaea13597b5e14fe514ddeaa4d76fc3
- name: github.com/go-sql-driver/mysql
version: 72ea5d0b32a04c67710bf63e97095d82aea5f352
- name: github.com/gogo/protobuf
version: c57e439bad574c2e0877ff18d514badcfced004d
subpackages:
- proto
- name: github.com/golang/glog
version: 23def4e6c14b4da8ac2ed8007337bc5eb5007998
- name: github.com/golang/protobuf
version: 2402d76f3d41f928c7902a765dfc872356dd3aad
subpackages:
- proto
- name: github.com/golang/snappy
version: 723cc1e459b8eea2dea4583200fd60757d40097a
- name: github.com/gonuts/go-shellquote
version: e842a11b24c6abfb3dd27af69a17f482e4b483c2
- name: github.com/google/gofuzz
version: fd52762d25a41827db7ef64c43756fd4b9f7e382
- name: github.com/gorilla/context
version: 1c83b3eabd45b6d76072b66b746c20815fb2872d
- name: github.com/gorilla/mux
version: 26a6070f849969ba72b72256e9f14cf519751690
- name: github.com/hailocab/go-hostpool
version: 50839ee41f32bfca8d03a183031aa634b2dc1c64
- name: github.com/hashicorp/go-msgpack
version: fa3f63826f7c23912c15263591e65d54d080b458
subpackages:
- codec
- name: github.com/hashicorp/raft
version: b95f335efee1992886864389183ebda0c0a5d0f6
- name: github.com/hashicorp/raft-boltdb
version: d1e82c1ec3f15ee991f7cc7ffd5b67ff6f5bbaee
- name: github.com/influxdata/config
version: bae7cb98197d842374d3b8403905924094930f24
- name: github.com/influxdata/influxdb
version: 0e0f85a0c1fd1788ae4f9145531b02c539cfa5b5
subpackages:
- client/v2
- models
- services/graphite
- name: github.com/influxdb/influxdb
version: 0e0f85a0c1fd1788ae4f9145531b02c539cfa5b5
subpackages:
- models
- pkg/escape
- cluster
- meta
- monitor
- toml
- tsdb
- cluster/internal
- influxql
- meta/internal
- pkg/slices
- tsdb/internal
- name: github.com/jchauncey/kubeclient
version: 52ad51a76eed34f58589952b20b4a1d5928cdcd2
subpackages:
- api
- client/unversioned
- api/meta
- api/resource
- api/unversioned
- auth/user
- conversion
- fields
- labels
- runtime
- runtime/serializer
- types
- util
- util/intstr
- util/rand
- util/sets
- api/errors
- api/v1
- api/validation
- apimachinery/registered
- apis/extensions
- client/transport
- util/net
- util/wait
- version
- watch
- watch/json
- third_party/forked/reflect
- util/validation
- conversion/queryparams
- util/errors
- runtime/serializer/json
- runtime/serializer/recognizer
- runtime/serializer/versioning
- util/runtime
- util/validation/field
- util/parsers
- api/util
- capabilities
- util/yaml
- apimachinery
- name: github.com/jmespath/go-jmespath
version: c01cf91b011868172fdcd9f41838e80c9d716264
- name: github.com/juju/ratelimit
version: 77ed1c8a01217656d2080ad51981f6e99adaa177
- name: github.com/klauspost/crc32
version: 999f3125931f6557b991b2f8472172bdfa578d38
- name: github.com/lib/pq
version: 8ad2b298cadd691a77015666a5372eae5dbfac8f
subpackages:
- oid
- name: github.com/matttproud/golang_protobuf_extensions
version: d0c3fe89de86839aecf2e0579c40ba3bb336a453
subpackages:
- pbutil
- name: github.com/mreiferson/go-snappystream
version: 028eae7ab5c4c9e2d1cb4c4ca1e53259bbe7e504
subpackages:
- snappy-go
- name: github.com/naoina/go-stringutil
version: 6b638e95a32d0c1131db0e7fe83775cbea4a0d0b
- name: github.com/naoina/toml
version: 751171607256bb66e64c9f0220c00662420c38e9
subpackages:
- ast
- name: github.com/nsqio/go-nsq
version: 2118015c120962edc5d03325c680daf3163a8b5f
- name: github.com/pborman/uuid
version: dee7705ef7b324f27ceb85a121c61f2c2e8ce988
- name: github.com/pmezard/go-difflib
version: 792786c7400a136282c1664665ae0a8db921c6c2
subpackages:
- difflib
- name: github.com/prometheus/client_golang
version: 67994f177195311c3ea3d4407ed0175e34a4256f
subpackages:
- prometheus
- name: github.com/prometheus/client_model
version: fa8ad6fec33561be4280a8f0514318c79d7f6cb6
subpackages:
- go
- name: github.com/prometheus/common
version: 0a3005bb37bc411040083a55372e77c405f6464c
subpackages:
- expfmt
- model
- internal/bitbucket.org/ww/goautoneg
- name: github.com/prometheus/procfs
version: 406e5b7bfd8201a36e2bb5f7bdae0b03380c2ce8
- name: github.com/samuel/go-zookeeper
version: 218e9c81c0dd8b3b18172b2bbfad92cc7d6db55f
subpackages:
- zk
- name: github.com/shirou/gopsutil
version: 8850f58d7035653e1ab90711481954c8ca1b9813
subpackages:
- cpu
- disk
- host
- load
- mem
- net
- process
- internal/common
- name: github.com/Shopify/sarama
version: d37c73f2b2bce85f7fa16b6a550d26c5372892ef
- name: github.com/Sirupsen/logrus
version: f7f79f729e0fbe2fcc061db48a9ba0263f588252
- name: github.com/soniah/gosnmp
version: b1b4f885b12c5dcbd021c5cee1c904110de6db7d
- name: github.com/spf13/pflag
version: 7f60f83a2c81bc3c3c0d5297f61ddfa68da9d3b7
- name: github.com/streadway/amqp
version: b4f3ceab0337f013208d31348b578d83c0064744
- name: github.com/stretchr/objx
version: 1a9d0bb9f541897e62256577b352fdbc1fb4fd94
- name: github.com/stretchr/testify
version: f390dcf405f7b83c997eac1b06768bb9f44dec18
subpackages:
- assert
- mock
- http
- name: github.com/ugorji/go
version: 646ae4a518c1c3be0739df898118d9bccf993858
subpackages:
- codec
- name: github.com/wvanbergen/kafka
version: 1a8639a45164fcc245d5c7b4bd3ccfbd1a0ffbf3
subpackages:
- consumergroup
- name: github.com/wvanbergen/kazoo-go
version: 0f768712ae6f76454f987c3356177e138df258f8
- name: github.com/zensqlmonitor/go-mssqldb
version: ffe5510c6fa5e15e6d983210ab501c815b56b363
- name: golang.org/x/crypto
version: 3760e016850398b85094c4c99e955b8c3dea5711
subpackages:
- md4
- bcrypt
- blowfish
- name: golang.org/x/net
version: 72aa00c6241a8013dc9b040abb45f57edbe73945
subpackages:
- html/charset
- websocket
- context
- html
- html/atom
- name: golang.org/x/text
version: cf4986612c83df6c55578ba198316d1684a9a287
subpackages:
- encoding
- encoding/charmap
- encoding/htmlindex
- transform
- encoding/internal/identifier
- encoding/internal
- encoding/japanese
- encoding/korean
- encoding/simplifiedchinese
- encoding/traditionalchinese
- encoding/unicode
- language
- internal/utf8internal
- runes
- internal/tag
- name: gopkg.in/dancannon/gorethink.v1
version: e2cef022d0495329dfb0635991de76efcab5cf50
- name: gopkg.in/fatih/pool.v2
version: cba550ebf9bce999a02e963296d4bc7a486cb715
- name: gopkg.in/mgo.v2
version: 03c9f3ee4c14c8e51ee521a6a7d0425658dd6f64
subpackages:
- bson
- internal/scram
- name: gopkg.in/yaml.v2
version: f7716cbe52baa25d2e9b0d0da546fcf909fc16b4
- name: speter.net/go/exp/math/dec/inf
version: 42ca6cd68aa922bc3f32f1e056e61b65945d9ad7
devImports: []

157
glide.yaml Normal file
View File

@ -0,0 +1,157 @@
package: github.com/influxdata/telegraf
import:
- package: git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.golang.git
version: dbd8d5c40a582eb9adacde36b47932b3a3ad0034
- package: github.com/Shopify/sarama
version: d37c73f2b2bce85f7fa16b6a550d26c5372892ef
- package: github.com/Sirupsen/logrus
version: f7f79f729e0fbe2fcc061db48a9ba0263f588252
- package: github.com/amir/raidman
version: 6a8e089bbe32e6b907feae5ba688841974b3c339
- package: github.com/armon/go-metrics
version: 345426c77237ece5dab0e1605c3e4b35c3f54757
- package: github.com/aws/aws-sdk-go
version: 3ad0b07b44c22c21c734d1094981540b7a11e942
subpackages:
- aws
- aws/credentials
- aws/credentials/ec2rolecreds
- aws/ec2metadata
- aws/session
- service/cloudwatch
- service/kinesis
- package: github.com/beorn7/perks
version: b965b613227fddccbfffe13eae360ed3fa822f8d
- package: github.com/boltdb/bolt
version: 6465994716bf6400605746e79224cf1e7ed68725
- package: github.com/cenkalti/backoff
version: 4dc77674aceaabba2c7e3da25d4c823edfb73f99
- package: github.com/dancannon/gorethink
version: ff457cac6a529d9749d841a733d76e8305cba3c8
- package: github.com/davecgh/go-spew
version: 5215b55f46b2b919f50a1df0eaa5886afe4e3b3d
- package: github.com/eapache/go-resiliency
version: b86b1ec0dd4209a588dc1285cdd471e73525c0b3
- package: github.com/eapache/queue
version: ded5959c0d4e360646dc9e9908cff48666781367
- package: github.com/fsouza/go-dockerclient
version: 6fb38e6bb3d544d7eb5b55fd396cd4e6850802d8
- package: github.com/go-ini/ini
version: afbd495e5aaea13597b5e14fe514ddeaa4d76fc3
- package: github.com/go-sql-driver/mysql
version: 72ea5d0b32a04c67710bf63e97095d82aea5f352
- package: github.com/gogo/protobuf
version: c57e439bad574c2e0877ff18d514badcfced004d
- package: github.com/golang/protobuf
version: 2402d76f3d41f928c7902a765dfc872356dd3aad
- package: github.com/golang/snappy
version: 723cc1e459b8eea2dea4583200fd60757d40097a
- package: github.com/gonuts/go-shellquote
version: e842a11b24c6abfb3dd27af69a17f482e4b483c2
- package: github.com/hailocab/go-hostpool
version: 50839ee41f32bfca8d03a183031aa634b2dc1c64
- package: github.com/hashicorp/go-msgpack
version: fa3f63826f7c23912c15263591e65d54d080b458
- package: github.com/hashicorp/raft
version: b95f335efee1992886864389183ebda0c0a5d0f6
- package: github.com/hashicorp/raft-boltdb
version: d1e82c1ec3f15ee991f7cc7ffd5b67ff6f5bbaee
- package: github.com/influxdata/config
version: bae7cb98197d842374d3b8403905924094930f24
- package: github.com/influxdata/influxdb
version: 0e0f85a0c1fd1788ae4f9145531b02c539cfa5b5
subpackages:
- client/v2
- models
- services/graphite
- package: github.com/influxdb/influxdb
version: 0e0f85a0c1fd1788ae4f9145531b02c539cfa5b5
- package: github.com/jmespath/go-jmespath
version: c01cf91b011868172fdcd9f41838e80c9d716264
- package: github.com/klauspost/crc32
version: 999f3125931f6557b991b2f8472172bdfa578d38
- package: github.com/lib/pq
version: 8ad2b298cadd691a77015666a5372eae5dbfac8f
- package: github.com/matttproud/golang_protobuf_extensions
version: d0c3fe89de86839aecf2e0579c40ba3bb336a453
- package: github.com/mreiferson/go-snappystream
version: 028eae7ab5c4c9e2d1cb4c4ca1e53259bbe7e504
- package: github.com/naoina/go-stringutil
version: 6b638e95a32d0c1131db0e7fe83775cbea4a0d0b
- package: github.com/naoina/toml
version: 751171607256bb66e64c9f0220c00662420c38e9
subpackages:
- ast
- package: github.com/nsqio/go-nsq
version: 2118015c120962edc5d03325c680daf3163a8b5f
- package: github.com/pborman/uuid
version: dee7705ef7b324f27ceb85a121c61f2c2e8ce988
- package: github.com/pmezard/go-difflib
version: 792786c7400a136282c1664665ae0a8db921c6c2
- package: github.com/prometheus/client_golang
version: 67994f177195311c3ea3d4407ed0175e34a4256f
subpackages:
- prometheus
- package: github.com/prometheus/client_model
version: fa8ad6fec33561be4280a8f0514318c79d7f6cb6
- package: github.com/prometheus/common
version: 0a3005bb37bc411040083a55372e77c405f6464c
subpackages:
- expfmt
- model
- package: github.com/prometheus/procfs
version: 406e5b7bfd8201a36e2bb5f7bdae0b03380c2ce8
- package: github.com/samuel/go-zookeeper
version: 218e9c81c0dd8b3b18172b2bbfad92cc7d6db55f
- package: github.com/shirou/gopsutil
version: 8850f58d7035653e1ab90711481954c8ca1b9813
subpackages:
- cpu
- disk
- host
- load
- mem
- net
- process
- package: github.com/soniah/gosnmp
version: b1b4f885b12c5dcbd021c5cee1c904110de6db7d
- package: github.com/streadway/amqp
version: b4f3ceab0337f013208d31348b578d83c0064744
- package: github.com/stretchr/objx
version: 1a9d0bb9f541897e62256577b352fdbc1fb4fd94
- package: github.com/stretchr/testify
version: f390dcf405f7b83c997eac1b06768bb9f44dec18
subpackages:
- assert
- mock
- package: github.com/wvanbergen/kafka
version: 1a8639a45164fcc245d5c7b4bd3ccfbd1a0ffbf3
subpackages:
- consumergroup
- package: github.com/wvanbergen/kazoo-go
version: 0f768712ae6f76454f987c3356177e138df258f8
- package: golang.org/x/crypto
version: 3760e016850398b85094c4c99e955b8c3dea5711
- package: golang.org/x/net
version: 72aa00c6241a8013dc9b040abb45f57edbe73945
subpackages:
- html/charset
- package: golang.org/x/text
version: cf4986612c83df6c55578ba198316d1684a9a287
- package: gopkg.in/dancannon/gorethink.v1
version: e2cef022d0495329dfb0635991de76efcab5cf50
- package: gopkg.in/fatih/pool.v2
version: cba550ebf9bce999a02e963296d4bc7a486cb715
- package: gopkg.in/mgo.v2
version: 03c9f3ee4c14c8e51ee521a6a7d0425658dd6f64
subpackages:
- bson
- package: gopkg.in/yaml.v2
version: f7716cbe52baa25d2e9b0d0da546fcf909fc16b4
- package: github.com/jchauncey/kubeclient
version: 52ad51a76eed34f58589952b20b4a1d5928cdcd2
subpackages:
- api
- client/unversioned
- package: github.com/gorilla/mux
- package: github.com/zensqlmonitor/go-mssqldb

301
internal/docker/docker.go Normal file
View File

@ -0,0 +1,301 @@
package docker
import (
"fmt"
"strings"
"sync"
"time"
"github.com/influxdata/telegraf"
api "k8s.io/kubernetes/pkg/api"
kube "k8s.io/kubernetes/pkg/client/unversioned"
godocker "github.com/fsouza/go-dockerclient"
)
// CreateClient sets the client value in the Docker struct
func CreateClient(endpoint string) (*godocker.Client, error) {
var c *godocker.Client
var err error
if endpoint == "ENV" {
c, err = godocker.NewClientFromEnv()
} else if endpoint == "" {
c, err = godocker.NewClient("unix:///var/run/docker.sock")
} else {
c, err = godocker.NewClient(endpoint)
}
return c, err
}
func GatherContainerMetrics(client *godocker.Client, kubeClient *kube.Client, containerNames []string, acc telegraf.Accumulator) error {
opts := godocker.ListContainersOptions{}
containers, err := client.ListContainers(opts)
if err != nil {
return err
}
var wg sync.WaitGroup
wg.Add(len(containers))
for _, container := range containers {
go func(c godocker.APIContainers) {
defer wg.Done()
err := gatherContainer(client, kubeClient, c, containerNames, acc)
if err != nil {
fmt.Println(err.Error())
}
}(container)
}
wg.Wait()
return nil
}
func gatherContainer(
client *godocker.Client,
kubeClient *kube.Client,
container godocker.APIContainers,
containerNames []string,
acc telegraf.Accumulator,
) error {
// Parse container name
cname := "unknown"
if len(container.Names) > 0 {
// Not sure what to do with other names, just take the first.
cname = strings.TrimPrefix(container.Names[0], "/")
}
tags := map[string]string{
"container_id": container.ID,
"container_name": cname,
"container_image": container.Image,
}
if kubeClient != nil {
tags = gatherKubernetesLabels(kubeClient, container.ID, tags)
}
if len(containerNames) > 0 {
if !sliceContains(cname, containerNames) {
return nil
}
}
statChan := make(chan *godocker.Stats)
done := make(chan bool)
statOpts := godocker.StatsOptions{
Stream: false,
ID: container.ID,
Stats: statChan,
Done: done,
Timeout: time.Duration(time.Second * 5),
}
go func() {
client.Stats(statOpts)
}()
stat := <-statChan
close(done)
// Add labels to tags
for k, v := range container.Labels {
tags[k] = v
}
gatherContainerStats(stat, acc, tags)
return nil
}
func gatherContainerStats(
stat *godocker.Stats,
acc telegraf.Accumulator,
tags map[string]string,
) {
now := stat.Read
memfields := map[string]interface{}{
"max_usage": stat.MemoryStats.MaxUsage,
"usage": stat.MemoryStats.Usage,
"fail_count": stat.MemoryStats.Failcnt,
"limit": stat.MemoryStats.Limit,
"total_pgmafault": stat.MemoryStats.Stats.TotalPgmafault,
"cache": stat.MemoryStats.Stats.Cache,
"mapped_file": stat.MemoryStats.Stats.MappedFile,
"total_inactive_file": stat.MemoryStats.Stats.TotalInactiveFile,
"pgpgout": stat.MemoryStats.Stats.Pgpgout,
"rss": stat.MemoryStats.Stats.Rss,
"total_mapped_file": stat.MemoryStats.Stats.TotalMappedFile,
"writeback": stat.MemoryStats.Stats.Writeback,
"unevictable": stat.MemoryStats.Stats.Unevictable,
"pgpgin": stat.MemoryStats.Stats.Pgpgin,
"total_unevictable": stat.MemoryStats.Stats.TotalUnevictable,
"pgmajfault": stat.MemoryStats.Stats.Pgmajfault,
"total_rss": stat.MemoryStats.Stats.TotalRss,
"total_rss_huge": stat.MemoryStats.Stats.TotalRssHuge,
"total_writeback": stat.MemoryStats.Stats.TotalWriteback,
"total_inactive_anon": stat.MemoryStats.Stats.TotalInactiveAnon,
"rss_huge": stat.MemoryStats.Stats.RssHuge,
"hierarchical_memory_limit": stat.MemoryStats.Stats.HierarchicalMemoryLimit,
"total_pgfault": stat.MemoryStats.Stats.TotalPgfault,
"total_active_file": stat.MemoryStats.Stats.TotalActiveFile,
"active_anon": stat.MemoryStats.Stats.ActiveAnon,
"total_active_anon": stat.MemoryStats.Stats.TotalActiveAnon,
"total_pgpgout": stat.MemoryStats.Stats.TotalPgpgout,
"total_cache": stat.MemoryStats.Stats.TotalCache,
"inactive_anon": stat.MemoryStats.Stats.InactiveAnon,
"active_file": stat.MemoryStats.Stats.ActiveFile,
"pgfault": stat.MemoryStats.Stats.Pgfault,
"inactive_file": stat.MemoryStats.Stats.InactiveFile,
"total_pgpgin": stat.MemoryStats.Stats.TotalPgpgin,
}
acc.AddFields("docker_mem", memfields, tags, now)
cpufields := map[string]interface{}{
"usage_total": stat.CPUStats.CPUUsage.TotalUsage,
"usage_in_usermode": stat.CPUStats.CPUUsage.UsageInUsermode,
"usage_in_kernelmode": stat.CPUStats.CPUUsage.UsageInKernelmode,
"usage_system": stat.CPUStats.SystemCPUUsage,
"throttling_periods": stat.CPUStats.ThrottlingData.Periods,
"throttling_throttled_periods": stat.CPUStats.ThrottlingData.ThrottledPeriods,
"throttling_throttled_time": stat.CPUStats.ThrottlingData.ThrottledTime,
}
cputags := copyTags(tags)
cputags["cpu"] = "cpu-total"
acc.AddFields("docker_cpu", cpufields, cputags, now)
for i, percpu := range stat.CPUStats.CPUUsage.PercpuUsage {
percputags := copyTags(tags)
percputags["cpu"] = fmt.Sprintf("cpu%d", i)
acc.AddFields("docker_cpu", map[string]interface{}{"usage_total": percpu}, percputags, now)
}
for network, netstats := range stat.Networks {
netfields := map[string]interface{}{
"rx_dropped": netstats.RxDropped,
"rx_bytes": netstats.RxBytes,
"rx_errors": netstats.RxErrors,
"tx_packets": netstats.TxPackets,
"tx_dropped": netstats.TxDropped,
"rx_packets": netstats.RxPackets,
"tx_errors": netstats.TxErrors,
"tx_bytes": netstats.TxBytes,
}
// Create a new network tag dictionary for the "network" tag
nettags := copyTags(tags)
nettags["network"] = network
acc.AddFields("docker_net", netfields, nettags, now)
}
gatherBlockIOMetrics(stat, acc, tags, now)
}
func gatherBlockIOMetrics(
stat *godocker.Stats,
acc telegraf.Accumulator,
tags map[string]string,
now time.Time,
) {
blkioStats := stat.BlkioStats
// Make a map of devices to their block io stats
deviceStatMap := make(map[string]map[string]interface{})
for _, metric := range blkioStats.IOServiceBytesRecursive {
device := fmt.Sprintf("%d:%d", metric.Major, metric.Minor)
_, ok := deviceStatMap[device]
if !ok {
deviceStatMap[device] = make(map[string]interface{})
}
field := fmt.Sprintf("io_service_bytes_recursive_%s", strings.ToLower(metric.Op))
deviceStatMap[device][field] = metric.Value
}
for _, metric := range blkioStats.IOServicedRecursive {
device := fmt.Sprintf("%d:%d", metric.Major, metric.Minor)
_, ok := deviceStatMap[device]
if !ok {
deviceStatMap[device] = make(map[string]interface{})
}
field := fmt.Sprintf("io_serviced_recursive_%s", strings.ToLower(metric.Op))
deviceStatMap[device][field] = metric.Value
}
for _, metric := range blkioStats.IOQueueRecursive {
device := fmt.Sprintf("%d:%d", metric.Major, metric.Minor)
field := fmt.Sprintf("io_queue_recursive_%s", strings.ToLower(metric.Op))
deviceStatMap[device][field] = metric.Value
}
for _, metric := range blkioStats.IOServiceTimeRecursive {
device := fmt.Sprintf("%d:%d", metric.Major, metric.Minor)
field := fmt.Sprintf("io_service_time_recursive_%s", strings.ToLower(metric.Op))
deviceStatMap[device][field] = metric.Value
}
for _, metric := range blkioStats.IOWaitTimeRecursive {
device := fmt.Sprintf("%d:%d", metric.Major, metric.Minor)
field := fmt.Sprintf("io_wait_time_%s", strings.ToLower(metric.Op))
deviceStatMap[device][field] = metric.Value
}
for _, metric := range blkioStats.IOMergedRecursive {
device := fmt.Sprintf("%d:%d", metric.Major, metric.Minor)
field := fmt.Sprintf("io_merged_recursive_%s", strings.ToLower(metric.Op))
deviceStatMap[device][field] = metric.Value
}
for _, metric := range blkioStats.IOTimeRecursive {
device := fmt.Sprintf("%d:%d", metric.Major, metric.Minor)
field := fmt.Sprintf("io_time_recursive_%s", strings.ToLower(metric.Op))
deviceStatMap[device][field] = metric.Value
}
for _, metric := range blkioStats.SectorsRecursive {
device := fmt.Sprintf("%d:%d", metric.Major, metric.Minor)
field := fmt.Sprintf("sectors_recursive_%s", strings.ToLower(metric.Op))
deviceStatMap[device][field] = metric.Value
}
for device, fields := range deviceStatMap {
iotags := copyTags(tags)
iotags["device"] = device
acc.AddFields("docker_blkio", fields, iotags, now)
}
}
func copyTags(in map[string]string) map[string]string {
out := make(map[string]string)
for k, v := range in {
out[k] = v
}
return out
}
func gatherKubernetesLabels(kubeClient *kube.Client, containerID string, tags map[string]string) map[string]string {
podClient := kubeClient.Pods(api.NamespaceAll)
pods, _ := podClient.List(api.ListOptions{})
for _, pod := range pods.Items {
for _, containerStatus := range pod.Status.ContainerStatuses {
podContainerID := strings.TrimPrefix(containerStatus.ContainerID, "docker://")
if podContainerID == containerID {
for k, v := range pod.ObjectMeta.Labels {
tags[k] = v
}
return tags
}
}
}
return tags
}
func sliceContains(in string, sl []string) bool {
for _, str := range sl {
if str == in {
return true
}
}
return false
}

View File

@ -1,4 +1,4 @@
package system
package docker
import (
"testing"

View File

@ -14,6 +14,7 @@ import (
_ "github.com/influxdata/telegraf/plugins/inputs/influxdb"
_ "github.com/influxdata/telegraf/plugins/inputs/jolokia"
_ "github.com/influxdata/telegraf/plugins/inputs/kafka_consumer"
_ "github.com/influxdata/telegraf/plugins/inputs/kubernetes"
_ "github.com/influxdata/telegraf/plugins/inputs/leofs"
_ "github.com/influxdata/telegraf/plugins/inputs/lustre2"
_ "github.com/influxdata/telegraf/plugins/inputs/mailchimp"

View File

@ -98,9 +98,9 @@ on the availability of per-cpu stats on your system.
### Tags:
- All stats have the following tags:
- cont_id (container ID)
- cont_image (container image)
- cont_name (container name)
- container_id (container ID)
- container_image (container image)
- container_name (container name)
- docker_cpu specific:
- cpu
- docker_net specific:

View File

@ -1,23 +1,17 @@
package system
import (
"fmt"
"log"
"strings"
"sync"
"time"
"github.com/influxdata/telegraf"
docker "github.com/influxdata/telegraf/internal/docker"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/fsouza/go-dockerclient"
godocker "github.com/fsouza/go-dockerclient"
)
type Docker struct {
Endpoint string
ContainerNames []string
client *docker.Client
client *godocker.Client
}
var sampleConfig = `
@ -36,279 +30,17 @@ func (d *Docker) Description() string {
func (d *Docker) SampleConfig() string { return sampleConfig }
func (d *Docker) Gather(acc telegraf.Accumulator) error {
if d.client == nil {
var c *docker.Client
var err error
if d.Endpoint == "ENV" {
c, err = docker.NewClientFromEnv()
if err != nil {
return err
}
} else if d.Endpoint == "" {
c, err = docker.NewClient("unix:///var/run/docker.sock")
if err != nil {
return err
}
} else {
c, err = docker.NewClient(d.Endpoint)
if err != nil {
return err
}
}
d.client = c
}
var err error
opts := docker.ListContainersOptions{}
containers, err := d.client.ListContainers(opts)
d.client, err = docker.CreateClient(d.Endpoint)
if err != nil {
return err
}
var wg sync.WaitGroup
wg.Add(len(containers))
for _, container := range containers {
go func(c docker.APIContainers) {
defer wg.Done()
err := d.gatherContainer(c, acc)
if err != nil {
fmt.Println(err.Error())
}
}(container)
if d.client != nil {
err = docker.GatherContainerMetrics(d.client, nil, d.ContainerNames, acc)
}
wg.Wait()
return nil
}
func (d *Docker) gatherContainer(
container docker.APIContainers,
acc telegraf.Accumulator,
) error {
// Parse container name
cname := "unknown"
if len(container.Names) > 0 {
// Not sure what to do with other names, just take the first.
cname = strings.TrimPrefix(container.Names[0], "/")
}
tags := map[string]string{
"cont_id": container.ID,
"cont_name": cname,
"cont_image": container.Image,
}
if len(d.ContainerNames) > 0 {
if !sliceContains(cname, d.ContainerNames) {
return nil
}
}
statChan := make(chan *docker.Stats)
done := make(chan bool)
statOpts := docker.StatsOptions{
Stream: false,
ID: container.ID,
Stats: statChan,
Done: done,
Timeout: time.Duration(time.Second * 5),
}
go func() {
err := d.client.Stats(statOpts)
if err != nil {
log.Printf("Error getting docker stats: %s\n", err.Error())
}
}()
stat := <-statChan
close(done)
if stat == nil {
return nil
}
// Add labels to tags
for k, v := range container.Labels {
tags[k] = v
}
gatherContainerStats(stat, acc, tags)
return nil
}
func gatherContainerStats(
stat *docker.Stats,
acc telegraf.Accumulator,
tags map[string]string,
) {
now := stat.Read
memfields := map[string]interface{}{
"max_usage": stat.MemoryStats.MaxUsage,
"usage": stat.MemoryStats.Usage,
"fail_count": stat.MemoryStats.Failcnt,
"limit": stat.MemoryStats.Limit,
"total_pgmafault": stat.MemoryStats.Stats.TotalPgmafault,
"cache": stat.MemoryStats.Stats.Cache,
"mapped_file": stat.MemoryStats.Stats.MappedFile,
"total_inactive_file": stat.MemoryStats.Stats.TotalInactiveFile,
"pgpgout": stat.MemoryStats.Stats.Pgpgout,
"rss": stat.MemoryStats.Stats.Rss,
"total_mapped_file": stat.MemoryStats.Stats.TotalMappedFile,
"writeback": stat.MemoryStats.Stats.Writeback,
"unevictable": stat.MemoryStats.Stats.Unevictable,
"pgpgin": stat.MemoryStats.Stats.Pgpgin,
"total_unevictable": stat.MemoryStats.Stats.TotalUnevictable,
"pgmajfault": stat.MemoryStats.Stats.Pgmajfault,
"total_rss": stat.MemoryStats.Stats.TotalRss,
"total_rss_huge": stat.MemoryStats.Stats.TotalRssHuge,
"total_writeback": stat.MemoryStats.Stats.TotalWriteback,
"total_inactive_anon": stat.MemoryStats.Stats.TotalInactiveAnon,
"rss_huge": stat.MemoryStats.Stats.RssHuge,
"hierarchical_memory_limit": stat.MemoryStats.Stats.HierarchicalMemoryLimit,
"total_pgfault": stat.MemoryStats.Stats.TotalPgfault,
"total_active_file": stat.MemoryStats.Stats.TotalActiveFile,
"active_anon": stat.MemoryStats.Stats.ActiveAnon,
"total_active_anon": stat.MemoryStats.Stats.TotalActiveAnon,
"total_pgpgout": stat.MemoryStats.Stats.TotalPgpgout,
"total_cache": stat.MemoryStats.Stats.TotalCache,
"inactive_anon": stat.MemoryStats.Stats.InactiveAnon,
"active_file": stat.MemoryStats.Stats.ActiveFile,
"pgfault": stat.MemoryStats.Stats.Pgfault,
"inactive_file": stat.MemoryStats.Stats.InactiveFile,
"total_pgpgin": stat.MemoryStats.Stats.TotalPgpgin,
}
acc.AddFields("docker_mem", memfields, tags, now)
cpufields := map[string]interface{}{
"usage_total": stat.CPUStats.CPUUsage.TotalUsage,
"usage_in_usermode": stat.CPUStats.CPUUsage.UsageInUsermode,
"usage_in_kernelmode": stat.CPUStats.CPUUsage.UsageInKernelmode,
"usage_system": stat.CPUStats.SystemCPUUsage,
"throttling_periods": stat.CPUStats.ThrottlingData.Periods,
"throttling_throttled_periods": stat.CPUStats.ThrottlingData.ThrottledPeriods,
"throttling_throttled_time": stat.CPUStats.ThrottlingData.ThrottledTime,
}
cputags := copyTags(tags)
cputags["cpu"] = "cpu-total"
acc.AddFields("docker_cpu", cpufields, cputags, now)
for i, percpu := range stat.CPUStats.CPUUsage.PercpuUsage {
percputags := copyTags(tags)
percputags["cpu"] = fmt.Sprintf("cpu%d", i)
acc.AddFields("docker_cpu", map[string]interface{}{"usage_total": percpu}, percputags, now)
}
for network, netstats := range stat.Networks {
netfields := map[string]interface{}{
"rx_dropped": netstats.RxDropped,
"rx_bytes": netstats.RxBytes,
"rx_errors": netstats.RxErrors,
"tx_packets": netstats.TxPackets,
"tx_dropped": netstats.TxDropped,
"rx_packets": netstats.RxPackets,
"tx_errors": netstats.TxErrors,
"tx_bytes": netstats.TxBytes,
}
// Create a new network tag dictionary for the "network" tag
nettags := copyTags(tags)
nettags["network"] = network
acc.AddFields("docker_net", netfields, nettags, now)
}
gatherBlockIOMetrics(stat, acc, tags, now)
}
func gatherBlockIOMetrics(
stat *docker.Stats,
acc telegraf.Accumulator,
tags map[string]string,
now time.Time,
) {
blkioStats := stat.BlkioStats
// Make a map of devices to their block io stats
deviceStatMap := make(map[string]map[string]interface{})
for _, metric := range blkioStats.IOServiceBytesRecursive {
device := fmt.Sprintf("%d:%d", metric.Major, metric.Minor)
_, ok := deviceStatMap[device]
if !ok {
deviceStatMap[device] = make(map[string]interface{})
}
field := fmt.Sprintf("io_service_bytes_recursive_%s", strings.ToLower(metric.Op))
deviceStatMap[device][field] = metric.Value
}
for _, metric := range blkioStats.IOServicedRecursive {
device := fmt.Sprintf("%d:%d", metric.Major, metric.Minor)
_, ok := deviceStatMap[device]
if !ok {
deviceStatMap[device] = make(map[string]interface{})
}
field := fmt.Sprintf("io_serviced_recursive_%s", strings.ToLower(metric.Op))
deviceStatMap[device][field] = metric.Value
}
for _, metric := range blkioStats.IOQueueRecursive {
device := fmt.Sprintf("%d:%d", metric.Major, metric.Minor)
field := fmt.Sprintf("io_queue_recursive_%s", strings.ToLower(metric.Op))
deviceStatMap[device][field] = metric.Value
}
for _, metric := range blkioStats.IOServiceTimeRecursive {
device := fmt.Sprintf("%d:%d", metric.Major, metric.Minor)
field := fmt.Sprintf("io_service_time_recursive_%s", strings.ToLower(metric.Op))
deviceStatMap[device][field] = metric.Value
}
for _, metric := range blkioStats.IOWaitTimeRecursive {
device := fmt.Sprintf("%d:%d", metric.Major, metric.Minor)
field := fmt.Sprintf("io_wait_time_%s", strings.ToLower(metric.Op))
deviceStatMap[device][field] = metric.Value
}
for _, metric := range blkioStats.IOMergedRecursive {
device := fmt.Sprintf("%d:%d", metric.Major, metric.Minor)
field := fmt.Sprintf("io_merged_recursive_%s", strings.ToLower(metric.Op))
deviceStatMap[device][field] = metric.Value
}
for _, metric := range blkioStats.IOTimeRecursive {
device := fmt.Sprintf("%d:%d", metric.Major, metric.Minor)
field := fmt.Sprintf("io_time_recursive_%s", strings.ToLower(metric.Op))
deviceStatMap[device][field] = metric.Value
}
for _, metric := range blkioStats.SectorsRecursive {
device := fmt.Sprintf("%d:%d", metric.Major, metric.Minor)
field := fmt.Sprintf("sectors_recursive_%s", strings.ToLower(metric.Op))
deviceStatMap[device][field] = metric.Value
}
for device, fields := range deviceStatMap {
iotags := copyTags(tags)
iotags["device"] = device
acc.AddFields("docker_blkio", fields, iotags, now)
}
}
func copyTags(in map[string]string) map[string]string {
out := make(map[string]string)
for k, v := range in {
out[k] = v
}
return out
}
func sliceContains(in string, sl []string) bool {
for _, str := range sl {
if str == in {
return true
}
}
return false
return err
}
func init() {

View File

@ -0,0 +1,30 @@
# Kubernetes Input Plugin
The kubernetes plugin uses the docker remote API to gather metrics on running
docker containers. You can read Docker's documentation for their remote API
[here](https://docs.docker.com/engine/reference/api/docker_remote_api_v1.20/#get-container-stats-based-on-resource-usage)
It then decorates those metrics with the kubernetes labels (and docker labels).
The kubernetes plugin uses the excellent
[fsouza go-dockerclient](https://github.com/fsouza/go-dockerclient) library to
gather stats. Documentation for the library can be found
[here](https://godoc.org/github.com/fsouza/go-dockerclient) and documentation
for the stat structure can be found
[here](https://godoc.org/github.com/fsouza/go-dockerclient#Stats)
### Configuration:
```
# Read metrics about docker containers
[[inputs.kubernetes]]
# Docker Endpoint
# To use TCP, set endpoint = "tcp://[ip]:[port]"
# To use environment variables (ie, docker-machine), set endpoint = "ENV"
endpoint = "unix:///var/run/docker.sock"
# Only collect metrics for these containers, collect all if empty
container_names = []
```
### Measurements & Fields:
Please see the [docker input plugin](../docker/README.md) for detailed list of measurements.

View File

@ -0,0 +1,59 @@
package system
import (
kube "k8s.io/kubernetes/pkg/client/unversioned"
godocker "github.com/fsouza/go-dockerclient"
"github.com/influxdata/telegraf"
docker "github.com/influxdata/telegraf/internal/docker"
"github.com/influxdata/telegraf/plugins/inputs"
)
type Kubernetes struct {
DockerEndpoint string
ContainerNames []string
DockerClient *godocker.Client
KubernetesClient *kube.Client
}
var sampleConfig = `
# Docker Endpoint
# To use TCP, set docker_endpoint = "tcp://[ip]:[port]"
# To use environment variables (ie, docker-machine), set docker_endpoint = "ENV"
docker_endpoint = "unix:///var/run/docker.sock"
# Only collect metrics for these containers, collect all if empty
container_names = []
`
func (k *Kubernetes) Description() string {
return "Read metrics about docker containers running on a kubernetes cluster"
}
func (k *Kubernetes) SampleConfig() string { return sampleConfig }
func (k *Kubernetes) Gather(acc telegraf.Accumulator) error {
var err error
k.KubernetesClient, err = kube.NewInCluster()
if err != nil {
return err
}
k.DockerClient, err = docker.CreateClient(k.DockerEndpoint)
if err != nil {
return err
}
if k.DockerClient != nil {
err = docker.GatherContainerMetrics(k.DockerClient, k.KubernetesClient, k.ContainerNames, acc)
}
return err
}
func init() {
inputs.Add("kubernetes", func() telegraf.Input {
return &Kubernetes{}
})
}