-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.py
More file actions
35 lines (28 loc) · 1.2 KB
/
init.py
File metadata and controls
35 lines (28 loc) · 1.2 KB
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
35
import requests
import urllib
import time
print("waiting 3 min before executing the script")
time.sleep(3 * 60)
print("start script")
print("Create and start rollup_job_kheops_metrics")
response = requests.post("http://elasticsearch:9200/_rollup/job/rollup_job_kheops_metrics/_start")
if response.status_code == 404:
headers = {"Content-Type": "application/json"}
response = requests.put("http://elasticsearch:9200/_rollup/job/rollup_job_kheops_metrics", headers=headers, data=open("rollup_job_kheops_metrics.json", "rb"))
print("Create")
print(response.status_code)
print(response.content)
response = requests.post("http://elasticsearch:9200/_rollup/job/rollup_job_kheops_metrics/_start")
print("Start")
print(response.status_code)
print(response.content)
else:
print("rollup_job_kheops_metrics already exist and already started")
print("import kinana saved objects")
headers = {"kbn-xsrf": "true"}
params={'overwrite': 'true'}
files = {'file': open('export.ndjson', 'rb')}
response = requests.post("http://kibana:5601/api/saved_objects/_import", params=params, files=files, headers=headers)
print(response.status_code)
print(response.content)
print("End of the script")