Skip to content

Add prometheus data collection #271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions f5_cccl/service/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


import logging
import json
from time import time

import f5_cccl.exceptions as exc
Expand Down Expand Up @@ -676,6 +677,24 @@ def apply_ltm_config(self, service_config, user_agent):
LOGGER.debug(
"apply_ltm_config took %.5f seconds.", (time() - start_time))

try:
prom_data = {}
for i in service_config.get('iapps', []):
prom_data[i['name']] = {
'timecost': int((time() - start_time)*1000),
'members': []
}
pmt = i.get('poolMemberTable', {})
for m in pmt.get('members', []):
prom_data[i['name']]['members'].append(m['address'])
# TODO: handle ingress type under cccl mode.
# for i in service_config.get('pools'/'l7Policies'/'monitors'/'virtualServers'/)
# pass
except Exception as e:
LOGGER.error("failed to handle ltm prom data: %s" % e)

LOGGER.info("prometheus.data.ltm="+json.dumps(prom_data))

return retval

def apply_net_config(self, service_config):
Expand Down Expand Up @@ -711,4 +730,13 @@ def apply_net_config(self, service_config):
LOGGER.debug(
"apply_net_config took %.5f seconds.", (time() - start_time))

try:
prom_data = {}
for i in service_config.get('arps', []):
prom_data[i['ipAddress']] = int((time() - start_time)*1000)
except Exception as e:
LOGGER.error("failed to handle net prom data: %s" % e)

LOGGER.info("prometheus.data.net="+json.dumps(prom_data))

return retval