Skip to content

Commit

Permalink
metric_viz fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
algorandskiy committed May 14, 2024
1 parent b98c722 commit 92b7d16
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions test/heapwatch/metrics_viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def main():
ap.add_argument('-l', '--list-nodes', default=False, action='store_true', help='list available node names with metrics')
ap.add_argument('--nick-re', action='append', default=[], help='regexp to filter node names, may be repeated')
ap.add_argument('--nick-lre', action='append', default=[], help='label:regexp to filter node names, may be repeated')
ap.add_argument('-s', '--save', type=str, choices=['png', 'html'], default='html', help=f'save plot to \'{default_img_filename}\' or \'{default_html_filename}\' file instead of showing it')
ap.add_argument('-s', '--save', type=str, choices=['png', 'html'], help=f'save plot to \'{default_img_filename}\' or \'{default_html_filename}\' file instead of showing it')
ap.add_argument('--diff', action='store_true', default=None, help='diff two gauge metrics instead of plotting their values. Requires two metrics names to be set')
ap.add_argument('--verbose', default=False, action='store_true')

Expand All @@ -138,6 +138,15 @@ def main():
# remap ip addresses to node names
ip_to_name = terraform_inventory_ip_not_names(tf_inventory_path)
filesByNick2 = {}
for nick in filesByNick.keys():
parsed = urlparse('//' + nick)
name: str = ip_to_name.get(parsed.hostname)
val = filesByNick[nick]
filesByNick2[name] = val

filesByNick = filesByNick2
filesByNick2 = {}

for nick in filesByNick.keys():
if args.nick_re or not args.nick_re and not args.nick_lre:
# filter by regexp or apply default renaming
Expand All @@ -149,14 +158,13 @@ def main():
# regex is given but not matched, continue to the next node
continue

parsed = urlparse('//' + nick)
name: str = ip_to_name.get(parsed.hostname)
if name:
idx = name.find('_')
if idx != -1:
name = name[:idx]
val = filesByNick[nick]
filesByNick2[name] = val
# apply default renaming
name = nick
idx = name.find('_')
if idx != -1:
name = name[idx+1:]
val = filesByNick[nick]
filesByNick2[name] = val

elif args.nick_lre:
# filter by label:regexp
Expand All @@ -170,8 +178,8 @@ def main():
# regex is given but not matched, continue to the next node
continue

val = filesByNick[nick]
filesByNick2[label] = val
val = filesByNick[nick]
filesByNick2[label] = val
else:
raise RuntimeError('unexpected options combination')

Expand Down

0 comments on commit 92b7d16

Please sign in to comment.