Created
April 6, 2019 03:17
-
-
Save hsuyuming/f8bc569c8be6891ab7eb74a668d4e07b to your computer and use it in GitHub Desktop.
use python sent event to splunk
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
import requests as r | |
import time | |
import datetime | |
import random | |
URL='https://localhost:8088/services/collector/event' | |
HEADER = {'Authorization': 'Splunk {}'.format('bf70d86a-1138-4e0a-a372-6e7e6ee4775e')} | |
data_dict={} | |
data_dict["table_name"]="event_msg" | |
for t in range(1554490629,1554990629): | |
data_dict["row_count"]= random.randint(8000,15000) | |
payload = { | |
"time": t, | |
"host": "0.0.0.0", | |
"source": "demo", | |
"event": data_dict | |
} | |
response = r.post(URL, headers=HEADER, json=payload, verify=False) | |
print(response) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment