Created
June 17, 2022 21:37
-
-
Save artemrys/391d9259f447d4ea78deabfb08098c89 to your computer and use it in GitHub Desktop.
Splunk HEC correct example
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, ensure_ascii=False).encode("utf-8"), | |
) | |
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