Closed jeremy-cxf closed 1 year ago
Changing sigsci_helper to use the dictionary get method and changing the behaviour to where if the key is not found, an empty list [] is returned, allows the event to be populated, and I can see events in the index after:
headers_out = data.get('headersOut', [])
headers_in = data.get('headersIn', [])
2023-06-06 21:14:27,388 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | corp: jcocks
2023-06-06 21:14:27,388 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | interval: 5
2023-06-06 21:14:27,388 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | Run Type: Concurrent
2023-06-06 21:14:27,388 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | site: chungus
2023-06-06 21:14:27,389 INFO pid=3722 tid=MainThread file=splunk_rest_client.py:_request_handler:99 | Use HTTP connection pooling
2023-06-06 21:14:27,404 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | last_run_until: 1686086062
2023-06-06 21:14:27,436 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | SiteName: chungus
2023-06-06 21:14:27,436 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | Start Period: 2023-06-06 21:14:22
2023-06-06 21:14:27,436 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | End Period: 2023-06-06 21:14:27
2023-06-06 21:14:27,436 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | Single instance mode
2023-06-06 21:14:27,436 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | Inputs: chungusEvents
2023-06-06 21:14:27,436 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | Inputs Num: 13
2023-06-06 21:14:27,436 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | single_name: chungusEvents
2023-06-06 21:14:27,436 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | Pulling results from Events API
2023-06-06 21:14:27,436 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | Processing page 1
2023-06-06 21:14:27,436 INFO pid=3722 tid=MainThread file=setup_util.py:log_info:117 | Proxy is not enabled!
2023-06-06 21:14:28,279 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | Number of Events for Page: 1
2023-06-06 21:14:28,279 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | Data: {'id': '647fa1aedb8096f291edb39a', 'eventType': 'loggingModeChanged', 'msgData': {'mode': 'block', 'oldMode': 'log'}, 'message': 'jeremy (xxx@fastly.com) changed agent mode from "log" to "block"', 'attachments': [], 'created': '2023-06-06T21:14:22Z'}
2023-06-06 21:14:28,279 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | Total Events Pulled: 1
2023-06-06 21:14:28,279 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | Concurrent Mode
2023-06-06 21:14:28,279 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | source_type: sigsci-event
2023-06-06 21:14:28,279 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | source_type_info: <class 'str'>
2023-06-06 21:14:28,279 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | index: default
2023-06-06 21:14:28,280 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | index_info: <class 'str'>
2023-06-06 21:14:28,280 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | single_name: chungusEvents
2023-06-06 21:14:28,280 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | single_name_info: <class 'str'>
2023-06-06 21:14:28,280 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | current_event: "{\"id\": \"647fa1aedb8096f291edb39a\", \"eventType\": \"loggingModeChanged\", \"msgData\": {\"mode\": \"block\", \"oldMode\": \"log\"}, \"message\": \"jeremy (xxx@fastly.com) changed agent mode from \\\"log\\\" to \\\"block\\\"\", \"attachments\": [], \"created\": \"2023-06-06T21:14:22Z\", \"headersOut\": [], \"headersIn\": []}"
2023-06-06 21:14:28,280 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | current_event_info: <class 'str'>
2023-06-06 21:14:28,280 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | Total Event Output Time: 0.0 seconds
2023-06-06 21:14:28,281 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | Finished Pulling Events for chungus
2023-06-06 21:14:28,281 INFO pid=3722 tid=MainThread file=base_modinput.py:log_info:295 | Total Script Time: 0.89 seconds
Will raise PR, however it is more of a quick win. I am assuming those keys are most likely not going to be present in the event data.
@dacoburn Can you take a look at this? Will need a new release if this looks good.
Reproduction steps:
Run Splunk Enterprise:
Exec onto container.
sudo tail -f log/splunk/sigsci_ta_for_splunk_SigsciEvent.log
Where 'headersOut' is not found in the appropriate 'data' dictionary, resulting in a KeyError. This seems to be a regression of the changes in the latest release.