Created
June 17, 2022 21:29
-
-
Save artemrys/cc19d7c253faba4d8fd42395b52335ef to your computer and use it in GitHub Desktop.
Splunk HEC example 1
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 json | |
import time | |
import requests | |
while True: | |
event = { | |
"index": "main", | |
"event": {"name": "goodbye", "value": "こんにちは世界"}, | |
} | |
response = requests.post( | |
"http://127.0.0.1:8088/services/collector/event", | |
headers={"Authorization": "Splunk <your-hec-token>"}, | |
data=json.dumps(event), | |
) | |
print(f"Event is sent, status code: {response.status_code}") | |
time.sleep(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment