Skip to content

Commit 344e986

Browse files
committed
fix: improve hec batch to be not a JSON array to conform specification: https://docs.splunk.com/Documentation/Splunk/latest/Data/FormateventsforHTTPEventCollector#Example_3:_Batched_data (ADDON-79329)
1 parent cd0c088 commit 344e986

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pytest_splunk_addon/event_ingestors/hec_event_ingestor.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
import json
17+
1618
from .base_event_ingestor import EventIngestor
1719
import requests
1820
from time import time, mktime
@@ -115,20 +117,21 @@ def ingest(self, events, thread_count):
115117

116118
def __ingest(self, data):
117119
try:
120+
batch_data = ''.join(json.dumps(obj) for obj in data)
118121
LOGGER.info(
119122
"Making a HEC event request with the following params:\nhec_uri:{}\nheaders:{}".format(
120123
str(self.hec_uri), str(self.session_headers)
121124
)
122125
)
123126
LOGGER.debug(
124127
"Creating the following sample event to be ingested via HEC event endoipnt:{}".format(
125-
str(data)
128+
str(batch_data)
126129
)
127130
)
128131
response = requests.post( # nosemgrep: splunk.disabled-cert-validation
129132
"{}/{}".format(self.hec_uri, "event"),
130133
auth=None,
131-
json=data,
134+
data=batch_data,
132135
headers=self.session_headers,
133136
verify=False,
134137
)

0 commit comments

Comments
 (0)