-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch.py
34 lines (32 loc) · 877 Bytes
/
fetch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from parides.prom_conv import from_prom_to_df
from datetime import datetime as dt, datetime
from datetime import timedelta
import os
import sys
from matplotlib import pyplot
# List of queries to fetch
from querylist import *
#from myquerylist import *
# Config
from config import *
#from myconfig import *
try:
os.mkdir("prom-metrics")
print("created prom-metrics directory")
except FileExistsError:
print("prom-metrics directory already exists")
now = dt.now()
if len(sys.argv) == 2:
path = sys.argv[1]
else:
path = (now.strftime("%Y-%m-%d-%H_%M"))
os.mkdir("prom-metrics/"+path)
for q in queries:
df = from_prom_to_df(
resolution = resolution,
start_time = start_time,
end_time = end_time,
url = url,
metrics_query = q[1]
)
df.to_csv("prom-metrics/" + path + '/' + q[0] + '.csv')