diff --git a/README.md b/README.md index dd6581b..36f0f55 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/alpha_vantage_to_mqtt.py b/alpha_vantage_to_mqtt.py index 39c29c4..7a2f20a 100755 --- a/alpha_vantage_to_mqtt.py +++ b/alpha_vantage_to_mqtt.py @@ -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: @@ -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}) diff --git a/env-sample b/env-sample index 06c2507..a2b7ab0 100644 --- a/env-sample +++ b/env-sample @@ -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= \ No newline at end of file +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 \ No newline at end of file