Skip to content

Commit

Permalink
Added the ability to set some more splunk parms in env file
Browse files Browse the repository at this point in the history
  • Loading branch information
thejeffreystone committed Mar 10, 2019
1 parent 15a74e6 commit 48e1984
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ splunk_hec_port=8088
splunk_hec_ssl=False
# Splunk HEC Token:
splunk_hec_key=
# Splunk index:
splunk_index=main
# Splunk sourcetype:
splunk_sourcetype=alpha_vantage
# Splunk Source:
splunk_source=alpha_vantage_script
# Splunk host:
splunk_host=jarvis
```
If you don't set a token, the script will ignore the Splunk portion.
Expand Down
14 changes: 9 additions & 5 deletions alpha_vantage_to_mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@
user = os.getenv("user")
password = os.getenv("password")
http_event_collector_key = os.getenv("splunk_hec_key")
http_event_collector_host = os.getenv("splunk_host")
http_event_collector_host = os.getenv("splunk_server")
http_event_collector_ssl = os.getenv("splunk_hec_ssl")
http_event_collector_port = int(os.getenv("splunk_hec_port"))
splunk_host = os.getenv("splunk_host")
splunk_source = os.getenv("splunk_source")
splunk_sourcetype = os.getenv("splunk_sourcetype")
splunk_index = os.getenv("splunk_index")

# if splunk hec key set in .env load the splunk libraries
if http_event_collector_key:
Expand Down Expand Up @@ -74,10 +78,10 @@ def splunkIt(records, symbols,total_elapsed_time, api_elapsed_time):
logevent.popNullFields = True

payload = {}
payload.update({"index":"homeassistant"})
payload.update({"sourcetype":"alpha_vantage_mqtt"})
payload.update({"source":"alpha_vantage_script"})
payload.update({"host":"jarvis"})
payload.update({"index":splunk_index})
payload.update({"sourcetype":splunk_sourcetype})
payload.update({"source":splunk_source})
payload.update({"host":splunk_host})
event = {}
event.update({"action":"success"})
event.update({"records":records})
Expand Down
12 changes: 10 additions & 2 deletions env-sample
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@ stocks=GOOG,AMZN,APPL,FB
interval=3600

# Splunk Server:
splunk_host=192.168.1.20
splunk_server=192.168.1.20
# Splunk HEC Port - Default is 8088:
splunk_hec_port=8088
# Splunk Hec SSL:
splunk_hec_ssl=False
# Splunk HEC Token:
splunk_hec_key=
splunk_hec_key=
# Splunk index:
splunk_index=main
# Splunk sourcetype:
splunk_sourcetype=alpha_vantage
# Splunk Source:
splunk_source=alpha_vantage_script
# Splunk host:
splunk_host=jarvis

0 comments on commit 48e1984

Please sign in to comment.