add active gauge to prometheus
@@ -81,10 +81,13 @@ def schedule_job_kickurl(func, logger):
'record_sources':{},
'port_tenants':{},
'port_hosts':{},
- 'inactives':0}
+ 'inactives':0,
+ 'actives':0}
for host in hosts:
if host['active'] == 0:
metrics['inactives'] += 1
+ if host['active'] == 1:
+ metrics['actives'] += 1
if (host['record_source'], host['role']) in metrics['roles']:
if host['active'] == 1:
metrics['roles'][(host['record_source'], host['role'])] += 1
@@ -193,6 +196,7 @@ def schedule_job_kickurl(func, logger):
for port_host in metrics['port_hosts']:
func.prom_metrics['port_hosts'].labels(port=port_host).set(metrics['port_hosts'][port_host])
func.prom_metrics['inactive'].set(metrics['inactives'])
+ func.prom_metrics['active'].set(metrics['actives'])
except Exception as e:
logger.error('unable to send results to prometheus because {0}'.format(str(e)))
@@ -705,6 +709,8 @@ def main(skip_rabbit=False): # pragma: no cover
# declare prometheus variables
pmain.prom_metrics['inactive'] = Gauge('poseidon_endpoint_inactive',
'Number of endpoints that are inactive')
+ pmain.prom_metrics['active'] = Gauge('poseidon_endpoint_active',
+ 'Number of endpoints that are active')
pmain.prom_metrics['behavior'] = Gauge('poseidon_endpoint_behavior',
'Behavior of an endpoint, 0 is normal, 1 is abnormal',
['ip',
