mirror of https://github.com/nicolargo/glances
Feature request: Include hostname in all (e.g. kafka) exports #1594
parent
1e8bf7bd5f
commit
f6533272a5
|
@ -488,6 +488,10 @@ host=localhost
|
||||||
port=9092
|
port=9092
|
||||||
topic=glances
|
topic=glances
|
||||||
#compression=gzip
|
#compression=gzip
|
||||||
|
# Tags will be added for all events
|
||||||
|
#tags=foo:bar,spam:eggs
|
||||||
|
# You can also use dynamic values
|
||||||
|
#tags=hostname:`hostname -f`
|
||||||
|
|
||||||
[zeromq]
|
[zeromq]
|
||||||
# Configuration for the --export zeromq option
|
# Configuration for the --export zeromq option
|
||||||
|
|
|
@ -16,7 +16,10 @@ following:
|
||||||
user=root
|
user=root
|
||||||
password=root
|
password=root
|
||||||
db=glances
|
db=glances
|
||||||
tags=foo:bar,spam:eggs
|
# Tags will be added for all measurements
|
||||||
|
#tags=foo:bar,spam:eggs
|
||||||
|
# You can also use dynamic values
|
||||||
|
#tags=system:`uname -s`
|
||||||
|
|
||||||
and run Glances with:
|
and run Glances with:
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,10 @@ following:
|
||||||
port=9092
|
port=9092
|
||||||
topic=glances
|
topic=glances
|
||||||
#compression=gzip
|
#compression=gzip
|
||||||
|
# Tags will be added for all events
|
||||||
|
#tags=foo:bar,spam:eggs
|
||||||
|
# You can also use dynamic values
|
||||||
|
#tags=hostname:`hostname -f`
|
||||||
|
|
||||||
Note: you can enable the compression but it consume CPU on your host.
|
Note: you can enable the compression but it consume CPU on your host.
|
||||||
|
|
||||||
|
@ -43,4 +47,4 @@ Python code example to consume Kafka Glances plugin:
|
||||||
|
|
||||||
consumer = KafkaConsumer('glances', value_deserializer=json.loads)
|
consumer = KafkaConsumer('glances', value_deserializer=json.loads)
|
||||||
for s in consumer:
|
for s in consumer:
|
||||||
print s
|
print(s)
|
||||||
|
|
|
@ -42,11 +42,14 @@ class Export(GlancesExport):
|
||||||
|
|
||||||
# Optionals configuration keys
|
# Optionals configuration keys
|
||||||
self.compression = None
|
self.compression = None
|
||||||
|
self.tags = None
|
||||||
|
|
||||||
# Load the Kafka configuration file section
|
# Load the Kafka configuration file section
|
||||||
self.export_enable = self.load_conf('kafka',
|
self.export_enable = self.load_conf('kafka',
|
||||||
mandatories=['host', 'port', 'topic'],
|
mandatories=['host', 'port',
|
||||||
options=['compression'])
|
'topic'],
|
||||||
|
options=['compression',
|
||||||
|
'tags'])
|
||||||
if not self.export_enable:
|
if not self.export_enable:
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
|
@ -79,6 +82,8 @@ class Export(GlancesExport):
|
||||||
|
|
||||||
# Create DB input
|
# Create DB input
|
||||||
data = dict(zip(columns, points))
|
data = dict(zip(columns, points))
|
||||||
|
if self.tags is not None:
|
||||||
|
data.update(self.parse_tags(self.tags))
|
||||||
|
|
||||||
# Send stats to the kafka topic
|
# Send stats to the kafka topic
|
||||||
# key=<plugin name>
|
# key=<plugin name>
|
||||||
|
|
Loading…
Reference in New Issue