mirror of https://github.com/nicolargo/glances
Too less data using prometheus exporter #1462
parent
c645ef81ae
commit
f9f7bf2f36
|
@ -450,20 +450,23 @@ prefix=G
|
|||
# https://prometheus.io
|
||||
# Create a Prometheus exporter listening on localhost:9091 (default configuration)
|
||||
# Metric are exporter using the following name:
|
||||
# <prefix>_<plugin>_<stats> (all specials character are replaced by '_')
|
||||
# <prefix>_<plugin>_<stats>{labelkey:labelvalue}
|
||||
# Note: You should add this exporter to your Prometheus server configuration:
|
||||
# scrape_configs:
|
||||
# - job_name: 'glances_exporter'
|
||||
# scrape_interval: 5s
|
||||
# static_configs:
|
||||
# - targets: ['localhost:9091']
|
||||
#
|
||||
# Labels will be added for all measurements (default is src:glances)
|
||||
# labels=foo:bar,spam:eggs
|
||||
# You can also use dynamic values
|
||||
# labels=system:`uname -s`
|
||||
#
|
||||
host=localhost
|
||||
port=9091
|
||||
prefix=glances
|
||||
# Labels will be added for all measurements
|
||||
#labels=foo:bar,spam:eggs
|
||||
# You can also use dynamic values
|
||||
#labels=system:`uname -s`
|
||||
#prefix=glances
|
||||
#labels=src:glances
|
||||
|
||||
[restful]
|
||||
# Configuration for the --export RESTful option
|
||||
|
|
|
@ -39,10 +39,6 @@ class Export(GlancesExport):
|
|||
"""Init the Prometheus export IF."""
|
||||
super(Export, self).__init__(config=config, args=args)
|
||||
|
||||
# Optionals configuration keys
|
||||
self.prefix = 'glances'
|
||||
self.labels = None
|
||||
|
||||
# Load the Prometheus configuration file section
|
||||
self.export_enable = self.load_conf('prometheus',
|
||||
mandatories=['host', 'port'],
|
||||
|
@ -50,6 +46,13 @@ class Export(GlancesExport):
|
|||
if not self.export_enable:
|
||||
sys.exit(2)
|
||||
|
||||
# Optionals configuration keys
|
||||
if self.prefix is None:
|
||||
self.prefix = 'glances'
|
||||
|
||||
if self.labels is None:
|
||||
self.labels = 'src:glances'
|
||||
|
||||
# Init the metric dict
|
||||
# Perhaps a better method is possible...
|
||||
self._metric_dict = {}
|
||||
|
@ -77,7 +80,7 @@ class Export(GlancesExport):
|
|||
# Write metrics to the Prometheus exporter
|
||||
for k, v in iteritems(data):
|
||||
# Prometheus metric name: prefix_<glances stats name>
|
||||
metric_name = self.prefix + self.METRIC_SEPARATOR + name + self.METRIC_SEPARATOR + k
|
||||
metric_name = self.prefix + self.METRIC_SEPARATOR + str(name) + self.METRIC_SEPARATOR + str(k)
|
||||
# Prometheus is very sensible to the metric name
|
||||
# See: https://prometheus.io/docs/practices/naming/
|
||||
for c in ['.', '-', '/', ' ']:
|
||||
|
|
Loading…
Reference in New Issue