Skip to content

Commit

Permalink
Merge pull request python-diamond#694 from acampoh/custom_metrics_kafka
Browse files Browse the repository at this point in the history
Custom metrics kafka
  • Loading branch information
shortdudey123 authored Feb 12, 2022
2 parents e70fe7d + 9b2b3df commit 4832a2c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/collectors/KafkaCollector.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ measure_collector_time | False | Collect the collector run time in ms | bool
metrics_blacklist | None | Regex to match metrics to block. Mutually exclusive with metrics_whitelist | NoneType
metrics_whitelist | None | Regex to match metrics to transmit. Mutually exclusive with metrics_blacklist | NoneType
port | 8082 | | int
query_paths | *kafka*:* | list of metrics to be read, separated by commas | str

#### Example Output

Expand Down
10 changes: 7 additions & 3 deletions src/collectors/kafkastat/kafkastat.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ class KafkaCollector(diamond.collector.Collector):
def get_default_config_help(self):
config_help = super(KafkaCollector, self).get_default_config_help()
config_help.update({
'host': "",
'port': "",
'host': "JMX host to connect. default: localhost",
'port': "JMX port. default: 8082",
'query_paths': "list of metrics process, separated by commas",
})
return config_help

Expand All @@ -51,6 +52,7 @@ def get_default_config(self):
'host': '127.0.0.1',
'port': 8082,
'path': 'kafka',
'query_paths': "*kafka*:*",
})
return config

Expand Down Expand Up @@ -158,12 +160,14 @@ def collect(self):
self.log.error('Failed to import xml.etree.ElementTree')
return

query_elements = self.config['query_paths'].split(',')
# Get list of gatherable stats
query_list = [
'*kafka*:*',
'java.lang:type=GarbageCollector,name=*',
'java.lang:type=Threading'
]

query_list = query_elements + query_list
mbeans = set()
for pattern in query_list:
match = self.get_mbeans(pattern)
Expand Down

0 comments on commit 4832a2c

Please sign in to comment.