Skip to content

Instantly share code, notes, and snippets.

@artemrys
Created June 17, 2022 21:29
Show Gist options
  • Save artemrys/cc19d7c253faba4d8fd42395b52335ef to your computer and use it in GitHub Desktop.
Save artemrys/cc19d7c253faba4d8fd42395b52335ef to your computer and use it in GitHub Desktop.
Splunk HEC example 1
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