-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopulate_logs.py
36 lines (31 loc) · 969 Bytes
/
populate_logs.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
35
36
import requests
import json
from datetime import datetime
import time
# Log ingestor endpoint
ingestor_url = "http://127.0.0.1:5000/ingest"
# Sample log data
log_data = {
"level": "error",
"message": "Application started",
"resourceId": "server-1234",
"timestamp": "",
"traceId": "abc-xyz-123",
"spanId": "span-456",
"commit_hash": "5e5342f",
"metadata": {"parentResourceId": "server-0987"},
}
# Number of logs to generate
num_logs = 10
# Send logs to the log ingestor
for _ in range(num_logs):
# Update timestamp for each log
log_data["timestamp"] = datetime.utcnow().isoformat() + "Z"
try:
response = requests.post(ingestor_url, json=log_data)
if response.status_code == 200:
print("Log ingested successfully.")
else:
print(f"Failed to ingest log. Status code: {response.status_code}")
except requests.RequestException as e:
print(f"Error sending log: {e}")