Hi,
We are trying to implement a decision tree algorithm in order to see if our resource usage can classify our servers in different categories.
First step in that process is querying Prometheus from Python and create some data frames with some basic information in order to get them aggregated.
To that purpose, you can also use the following lines of code:
import requests
import copy
URL = "http://[node_hostname]:9090/api/v1/query?query=metric_to_be_quried[1d]"
r = requests.get(url = URL)
data = r.json()
data_dict={}
metric_list = []
for i in data['data']['result']:
data_dict = copy.deepcopy(i['metric'])
for j in i['values']:
data_dict['time'] = j[0]
data_dict['value'] = j[1]
metric_list.append(data_dict)
df_metric = pd.DataFrame(metric_list)
Other pieces will follow.
Cheers