Created
October 31, 2019 12:46
-
-
Save shaikkhajaibrahim/ff985def8117dea9867f0a8a846dc08e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from datetime import timedelta, date, datetime | |
import random | |
import string | |
import requests | |
import os | |
start_date = datetime.today() - timedelta(days=2) | |
# 2 days of fake data | |
total_minutes = 60*24*2 | |
for minute in range(total_minutes): | |
print("{} of {}".format(minute,total_minutes)) | |
current_iter_date_unformated = start_date + timedelta(minutes=minute) | |
current_iter_date = current_iter_date_unformated.strftime("%Y-%m-%d") | |
url = "http://{}:9200/{}-fakecpuindex/fake".format(os.getenv('IP_ADDRESS',"34.220.166.4"),current_iter_date) | |
fake_document = { | |
"user": "directdevops.blog", | |
"date_posted": current_iter_date_unformated.isoformat(), | |
"message": ''.join(random.choice(string.ascii_uppercase + string.digits + string.ascii_lowercase) for _ in range(20)), | |
"cpu": random.randint(40,100), | |
"minute": minute | |
} | |
response = requests.post(url, json=fake_document) | |
print(response.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment