Skip to content

HTTP Event Collector

This helper provides developers with a simple solution for ingesting data into Falcon NG-SIEM. A code sample that uses this helper has been posted to the FalconPy sample library.

The HEC class was first introduced in FalconPy v1.5.1.

PLEASE NOTE: This helper only provides a solution for ingesting data, and does not address parsing requirements. For more detail regarding parser development and configuration refer to the Parser Development documentation.

The HEC helper class leverages simple keywords to specify NG-SIEM ingestion and logging options. The following keywords are supported when creating an instance of the HEC helper class.

ArgumentData typeDefaultDescription
api_keystringNoneFalcon NG-SIEM API key.
api_url_keystringNoneFalcon NG-SIEM URL key. Used to craft the target URL.
debugbooleanFalseEnable debugging.
ingest_formatstringjsonIngest data format. Allowed values: json, yaml, xml, csv
ingest_regionstringus1NG-SIEM ingest region. Allowed values: us1, us2, eu1, usgov1, usgov2
ingest_timeoutstring5Ingest submission request timeout (in seconds).
raw_ingestbooleanFalseUse the NG-SIEM raw ingestion endpoint.
retry_countinteger3Number of request retries before erroring on a thread.
sanitize_logbooleanTrueSanitize bearer tokens from debug logs.
thread_countintegerCPU count × 2, or 50 (whichever is smaller)Number of threads to use for asynchronous processing.

Once created, the following properties are available within an instance of the HEC helper class.

PropertyData typeMutable?CategoryDescription
file_logintegerYesLoggingInteger used to indicate if log data is being written to a file.
hec_headersdictionaryNoIngest ConfigThe authorization headers provided as part of a ingestion HTTP request. Calculated from the ingest_key and ingest_format.
ingest_base_urlstringYesIngest ConfigBase URL used during NG-SIEM endpoint creation.
ingest_configIngestConfigYesIngest ConfigThe object used for storing ingestion configuration settings.
ingest_formatstringYesIngest ConfigFormat for ingested data.
ingest_format_namestringNoIngest ConfigThe string used to identify the ingestion data format type.
ingest_keystringYesIngest ConfigNG-SIEM API key.
ingest_timeoutintegerYesIngest ConfigURL request timeout.
ingest_timeunitstringYesIngest ConfigTimeunits used for data ingested.
ingest_urlstringNoIngest ConfigThe destination URL used for data import, calculated from the ingest_url_key and ingest_base_url.
ingest_url_keystringYesIngest ConfigNG-SIEM URL key.
last_messagestringYesCollectorThe last received HTTP status message.
last_statusintegerYesCollectorThe last received HTTP status code.
logLoggerNoLoggingLog object provided by the log facility.
log_facilityLogFacilityYesLoggingLogging facility used for API debug output.
raw_ingestbooleanYesIngest ConfigFlag indicating if the raw ingestion endpoint should be used.
raw_ingest_urlstringNoIngest ConfigThe destination URL used for raw data import, calculated from the ingest_url.
retry_countintegerYesSession ManagementHTTP request retry count.
sanitize_logbooleanYesLoggingFlag indicating if log sanitization is enabled.
session_managerSessionManagerYesSession ManagementManager object used to handle sessions during asynchronous processing.
sessionslist of SessionYesSession ManagementReturns the list of sessions currently in use.
thread_countintegerYesSession ManagementThreads used in asynchronous session management.

The HEC helper class provides several methods for ingesting data and testing connectivity.

Sends a single event to Falcon NG-SIEM.

ArgumentData typeDescription
evtdictionary or stringEvent data to be consumed.

Processes and sends a file to Falcon NG-SIEM.

ArgumentData typeDescription
event_filestringFile location containing the event data to be consumed.

Sends a list of events to Falcon NG-SIEM.

ArgumentData typeDescription
event_listlist of dictionaries or IngestPayloadList of data events to be consumed.
show_progressbooleanFlag indicating if a progress indicator should be shown.

Tests connectivity to the Falcon NG-SIEM endpoint.

No arguments required.

This example imports a single JSON formatted event.

from falconpy import HEC
payload = {
"host": "sample-host",
"message": "Sample message",
"fields": {
"#falconpy": "Sample payload"
}
}
hec = HEC(api_key=NGSIEM_API_KEY,
api_url_key=NGSIEM_URL_KEY
)
hec.send_event(payload)

This example imports a single JSON formatted event using the HEC context manager.

from falconpy import HEC
payload = {
"host": "sample-host",
"message": "Sample message",
"fields": {
"#falconpy": "Sample payload"
}
}
with HEC(api_key=NGSIEM_API_KEY,
api_url_key=NGSIEM_URL_KEY
) as hec:
hec.send_event(payload)

This example imports a list of JSON formatted events.

from falconpy import HEC
payload = [{
"host": "sample-host",
"message": "Sample message",
"fields": {
"#falconpy": "Sample payload"
}
},
{
"host": "sample-host",
"message": "Sample message",
"fields": {
"#falconpy": "Sample payload"
}
}]
hec = HEC(api_key=NGSIEM_API_KEY,
api_url_key=NGSIEM_URL_KEY
)
hec.send_event_list(payload)

This example imports a raw file of JSON events.

from falconpy import HEC
hec = HEC(api_key=NGSIEM_API_KEY,
api_url_key=NGSIEM_URL_KEY,
raw_ingest=True
)
hec.send_event_file("sample_import_file.json")
{"event": {"category": ["host"], "host": "IV1IDSBP", "kind": "event", "module": "crowdstrike-falconpy-hec", "timestamp": 1747771778324434944, "type": ["info"], "timeunit": "nanoseconds", "message": "VP35ya83siwOC9bThq0U"}}
{"event": {"category": ["host"], "host": "XIHQBIOV", "kind": "event", "module": "crowdstrike-falconpy-hec", "timestamp": 1747771778324711936, "type": ["info"], "timeunit": "nanoseconds", "message": "ngZbqZroR8763eMODCWN"}}
{"event": {"category": ["host"], "host": "6MNTM8B8", "kind": "event", "module": "crowdstrike-falconpy-hec", "timestamp": 1747771778324791808, "type": ["info"], "timeunit": "nanoseconds", "message": "S4TCr7nY6u8fALOKHAQt"}}

Page Updated: v1.5.3