Skip to content

Commit 14e1922

Browse files
committed
dev
1 parent ba4623e commit 14e1922

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ https://netdata-ml-app.herokuapp.com/
1212

1313
https://netdata-ml-app-develop.herokuapp.com/
1414

15+
### Streamlit Apps
16+
17+
- __AR TOC__: `streamlit_app_ar_toc.py` - Anomaly Rates in netdata menu - try it [here](https://andrewm4894-netdata-ml-app-streamlit-app-ar-toc-5b9d7r.streamlitapp.com/).
18+
1519
### Apps
1620

1721
Each app focuses on a particular use case:

streamlit_app_ar_toc.py

+21-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11

22
import requests
3-
import pandas as pd
4-
import numpy as np
5-
from netdata_pandas.data import get_data
6-
import matplotlib.pyplot as plt
73
import streamlit as st
84
from collections import OrderedDict
95
from urllib.parse import urlparse
106
import re
117

128

13-
149
def parse_netdata_url(url):
1510
if url.startswith('http'):
1611
url_parsed = urlparse(url)
@@ -71,13 +66,32 @@ def parse_netdata_url(url):
7166
url_weights = f"http://{host}/api/v1/weights?after={after}&before={before}&options=raw"
7267
print(url_weights)
7368

69+
url_charts = f"http://{host}/api/v1/charts"
70+
charts_data = requests.get(url_charts).json()['charts']
71+
data_chart_order = dict()
72+
for chart in charts_data:
73+
data_chart_order[chart] = dict()
74+
data_chart_order[chart]['priority'] = charts_data[chart]['priority']
75+
data_chart_order[chart]['context'] = charts_data[chart]['context']
76+
print(data_chart_order)
77+
78+
#%%
79+
80+
import pandas as pd
81+
82+
df_chart_order = pd.DataFrame.from_dict(data_chart_order).transpose().reset_index()
83+
df_chart_order.columns = ['chart', 'priority', 'context']
84+
df_chart_order = df_chart_order[['context', 'chart', 'priority']].sort_values('priority')
85+
86+
#%%
87+
7488
weights_data = requests.get(url_weights).json()
7589

7690
data = OrderedDict()
77-
for context in weights_data['contexts']:
91+
for context in df_chart_order['context'].unique():
7892
context_key = f"{context}: {round(weights_data['contexts'][context]['weight'],2)}"
7993
data[context_key] = dict()
80-
for chart in weights_data['contexts'][context]['charts']:
94+
for chart in df_chart_order[df_chart_order['context'] == context]['chart'].unique():
8195
chart_key = f"{chart}: {round(weights_data['contexts'][context]['charts'][chart]['weight'],2)}"
8296
data[context_key][chart_key] = dict()
8397
for dim in weights_data['contexts'][context]['charts'][chart]['dimensions']:

0 commit comments

Comments
 (0)