Skip to content

Commit

Permalink
Merge pull request #330 from TeskaLabs/fix/watch-metrics
Browse files Browse the repository at this point in the history
Fix "watch" metrics endpoint
  • Loading branch information
eliska-n authored Jan 2, 2023
2 parents 9a903d8 + 282415e commit 18ca098
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions asab/metrics/web_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,16 @@ async def watch(self, request):
def watch_table(metric_records: list(), filter, tags):
lines = []
m_name_len = max([len(i["name"]) for i in metric_records])
v_name_len = max(
[
len(str(value_name))
for i in metric_records
if i["fieldset"][0].get("values") is not None
for value_name in i["fieldset"][0].get("values").keys()
]
) + 10

v_name_len = 0
for i in metric_records:
if len(i["fieldset"]) == 0:
continue
if len(i["fieldset"][0].get("values", {})) == 0:
continue
metric_name_len = max([len(str(value_name)) for value_name in i["fieldset"][0].get("values").keys()]) + 10
if metric_name_len > v_name_len:
v_name_len = metric_name_len

t_name_len = max([len(str(field["tags"])) for i in metric_records for field in i["fieldset"]])

Expand Down
2 changes: 1 addition & 1 deletion doc/asab/metrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ Configuration is required.
[asab:metrics]
target=http
[asab:metrics:influxdb]
[asab:metrics:http]
url=http://consumer_example:8080/consume
Expand Down

0 comments on commit 18ca098

Please sign in to comment.