Skip to content

Commit

Permalink
Make kube_service tag collection configurable:
Browse files Browse the repository at this point in the history
- add collect_service_tags option to disable collection
- add service_tag_update_freq to reduce event requests
  • Loading branch information
xvello authored and olivielpeau committed Jun 15, 2017
1 parent 0a93691 commit cc59639
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 8 additions & 3 deletions kubernetes/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
DEFAULT_COLLECT_EVENTS = False
DEFAULT_NAMESPACES = ['default']

DEFAULT_SERVICE_EVENT_FREQ = 5 * 60 # seconds

NET_ERRORS = ['rx_errors', 'tx_errors', 'rx_dropped', 'tx_dropped']

DEFAULT_ENABLED_GAUGES = [
Expand Down Expand Up @@ -106,14 +108,17 @@ def __init__(self, name, init_config, agentConfig, instances=None):
self._collect_events = _is_affirmative(inst.get('collect_events', DEFAULT_COLLECT_EVENTS))
if self._collect_events:
self.event_retriever = self.kubeutil.get_event_retriever()
elif self.kubeutil.collect_service_tag:
# Only fetch service and pod events for service mapping
event_delay = inst.get('service_tag_update_freq', DEFAULT_SERVICE_EVENT_FREQ)
self.event_retriever = self.kubeutil.get_event_retriever(kinds=['Service', 'Pod'],
delay=event_delay)
else:
# Only fetch service and pod events for service mapping and SD
self.event_retriever = self.kubeutil.get_event_retriever(kinds=['Service', 'Pod'])
self.event_retriever = None
else:
self._collect_events = None
self.event_retriever = None


def _perform_kubelet_checks(self, url):
service_check_base = NAMESPACE + '.kubelet.check'
is_ok = True
Expand Down
7 changes: 7 additions & 0 deletions kubernetes/conf.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ instances:
#
# collect_events: false
#
# Matching the pods to Kubernetes services requires to retrieve events regularly.
# To reduce the traffic to the apiserver, we only query them every 5 minutes, adding a delay
# in pod -> service matching. You can configure it below (in seconds) or disable kube_service
# tagging completely
#
# collect_service_tags: true
# service_tag_update_freq: 300
#
# The namespaces for which events should be collected.
# If not modified, the 'default' namespace will be used.
Expand Down

0 comments on commit cc59639

Please sign in to comment.