Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.gem
vendor
pkg
coverage/
.idea/
27 changes: 22 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
fluent-plugin-kubernetes-metrics (1.0.0)
fluent-plugin-kubernetes-metrics (1.1.0.Alpha)
fluentd (>= 0.14.10, < 2)
kubeclient (~> 4.0)
multi_json (~> 1.13)
Expand All @@ -13,10 +13,13 @@ GEM
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
cool.io (1.5.3)
crack (0.4.3)
safe_yaml (~> 1.0.0)
dig_rb (1.0.1)
docile (1.3.1)
domain_name (0.5.20180417)
unf (>= 0.0.5, < 1.0.0)
fluentd (1.2.5)
fluentd (1.3.0)
cool.io (>= 1.4.5, < 2.0.0)
dig_rb (~> 1.0.0)
http_parser.rb (>= 0.5.1, < 0.7.0)
Expand All @@ -27,6 +30,7 @@ GEM
tzinfo (~> 1.0)
tzinfo-data (~> 1.0)
yajl-ruby (~> 1.0)
hashdiff (0.3.7)
http (3.3.0)
addressable (~> 2.3)
http-cookie (~> 1.0)
Expand All @@ -36,6 +40,7 @@ GEM
domain_name (~> 0.5)
http-form_data (2.1.1)
http_parser.rb (0.6.0)
json (2.1.0)
kubeclient (4.0.0)
http (~> 3.0)
recursive-open-struct (~> 1.0, >= 1.0.4)
Expand All @@ -46,7 +51,7 @@ GEM
msgpack (1.2.4)
multi_json (1.13.1)
netrc (0.11.0)
oj (3.6.7)
oj (3.6.10)
power_assert (1.1.3)
public_suffix (3.0.3)
rake (12.3.1)
Expand All @@ -55,20 +60,30 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
safe_yaml (1.0.4)
serverengine (2.0.7)
sigdump (~> 0.2.2)
sigdump (0.2.4)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
strptime (0.2.3)
test-unit (3.2.8)
power_assert
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
tzinfo-data (1.2018.5)
tzinfo-data (1.2018.7)
tzinfo (>= 1.0.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
webmock (3.4.2)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
yajl-ruby (1.4.1)

PLATFORMS
Expand All @@ -78,7 +93,9 @@ DEPENDENCIES
bundler (~> 1.14)
fluent-plugin-kubernetes-metrics!
rake (~> 12.0)
simplecov (~> 0.16.1)
test-unit (~> 3.0)
webmock (~> 3.4.2)

BUNDLED WITH
1.16.1
1.16.6
14 changes: 7 additions & 7 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM centos:7.5.1804

LABEL maintainer="Gimi Liang <zliang@splunk.com>"
LABEL Description="Splunk Connect for Kubernetes docker image" Vendor="Splunk Inc." Version="1.0"
LABEL maintainer="Don Tregonning <dtregonning@splunk.com>, Chaitanya Phalak <cphalak@splunk.com>"
LABEL Description="Splunk Connect for Kubernetes docker image" Vendor="Splunk Inc." Version="1.1.Alpha"

COPY *.gem /tmp/
RUN curl -L -o /tmp/epel-release-7-11.noarch.rpm http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm \
Expand All @@ -17,14 +17,14 @@ RUN curl -L -o /tmp/epel-release-7-11.noarch.rpm http://dl.fedoraproject.org/pub
&& ./configure \
&& make \
&& make install \
&& gem install -N fluentd:1.2.5 \
&& gem install -N fluentd:1.3.0 \
fluent-plugin-systemd:1.0.1 \
fluent-plugin-concat:2.3.0 \
fluent-plugin-prometheus:1.1.0 \
fluent-plugin-prometheus:1.2.1 \
fluent-plugin-jq:0.5.1 \
fluent-plugin-record-modifier:1.1.0 \
fluent-plugin-record-modifier:1.1.0 \
fluent-plugin-splunk-hec:1.0.1 \
oj:3.6.10 \
oj:3.7.1 \
&& gem install -N /tmp/*.gem \
&& curl -L -o /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64 \
&& chmod +x /usr/bin/dumb-init \
Expand All @@ -42,4 +42,4 @@ ENV LD_PRELOAD="/usr/lib64/libjemalloc.so.1" \
COPY entrypoint.sh /bin/entrypoint.sh
ENTRYPOINT ["/bin/entrypoint.sh"]

CMD exec fluentd -c /fluentd/etc/${FLUENTD_CONF} -p /fluentd/plugins $FLUENTD_OPT
CMD exec fluentd -c /fluentd/etc/${FLUENTD_CONF} -p /fluentd/plugins $FLUENTD_OPT
8 changes: 5 additions & 3 deletions fluent-plugin-kubernetes-metrics.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

Gem::Specification.new do |spec|
spec.name = "fluent-plugin-kubernetes-metrics"
spec.version = "1.0.0"
spec.authors = ["Gimi Liang"]
spec.email = ["zliang@splunk.com"]
spec.version = "1.1.0.Alpha"
spec.authors = ["Don Tregonning", "Chaitanya Phalak"]
spec.email = ["team-da-sf@splunk.com"]

spec.summary = %q{A fluentd input plugin that collects kubernetes cluster metrics.}
spec.description = %q{A fluentd input plugin that collects node and container metrics from a kubernetes cluster via summary API.}
Expand All @@ -23,6 +23,8 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "bundler", "~> 1.14"
spec.add_development_dependency "rake", "~> 12.0"
spec.add_development_dependency "test-unit", "~> 3.0"
spec.add_development_dependency "simplecov", "~> 0.16.1"
spec.add_development_dependency "webmock", "~> 3.4.2"
spec.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
spec.add_runtime_dependency "kubeclient", "~> 4.0"
spec.add_runtime_dependency "multi_json", "~> 1.13"
Expand Down
8 changes: 4 additions & 4 deletions lib/fluent/plugin/in_kubernetes_metrics.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2018- Gimi Liang
# Copyright 2018- Splunk Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,7 +14,6 @@
# limitations under the License.

require 'time'

require 'fluent/plugin/input'
require 'kubeclient'
require 'multi_json'
Expand Down Expand Up @@ -89,6 +88,7 @@ def start

def close
@watchers.each &:finish if @watchers

super
end

Expand Down Expand Up @@ -374,8 +374,8 @@ def handle_response(response)
else
log.error "ExMultiJson.load(response.body) expected 2xx from summary API, but got #{response.code}. Response body = #{response.body}"
end
rescue StandardError
log.error "Failed to scrape metrics, error=#{$ERROR_INFO}"
rescue StandardError => error
log.error "Failed to scrape metrics, error=#{error.inspect}"
log.error_backtrace
end
end
Expand Down