EventIngestor¶
HEC Event Ingestor¶
HECEventIngestor
¶
Bases: EventIngestor
Class to ingest event via HEC Event
The format for required_configs is::
{
hec_uri: {splunk_hec_scheme}://{splunk_host}:{hec_port}/services/collector,
session_headers(dict):
{
"Authorization": f"Splunk <hec-token>",
}
}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
required_configs |
dict
|
Dictionary containing hec_uri and session headers |
required |
Source code in pytest_splunk_addon/event_ingestors/hec_event_ingestor.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
ingest(events, thread_count)
¶
Ingests event and metric data into splunk using HEC token via event endpoint.
For batch ingestion of events in a single request at event endpoint provide a list of event dict to be ingested.
The format of dictionary for ingesting a single event::
{
"sourcetype": "sample_HEC",
"source": "sample_source",
"host": "sample_host",
"event": "event_str"
}
The format of dictionary for ingesting a batch of events::
[
{
"sourcetype": "sample_HEC",
"source": "sample_source",
"host": "sample_host",
"event": "event_str1"
},
{
"sourcetype": "sample_HEC",
"source": "sample_source",
"host": "sample_host",
"event": "event_str2"
},
]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
events |
list
|
List of events (SampleEvent) to be ingested |
required |
Source code in pytest_splunk_addon/event_ingestors/hec_event_ingestor.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|
HEC Raw Ingestor¶
HECRawEventIngestor
¶
Bases: EventIngestor
Class to ingest event via HEC Raw
The format for required_configs is::
{
hec_uri: {splunk_hec_scheme}://{splunk_host}:{hec_port}/services/collector,
session_headers(dict):
{
"Authorization": f"Splunk <hec-token>",
}
}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
required_configs |
dict
|
Dictionary containing hec_uri and session headers |
required |
Source code in pytest_splunk_addon/event_ingestors/hec_raw_ingestor.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
ingest(events, thread_count)
¶
Ingests data into splunk via raw endpoint.
For batch ingestion of events in a single request at raw endpoint provide a string of events in data to be ingested.
The format of event and params for ingesting a single event::
'127.0.0.1 - admin [28/Sep/2016:09:05:26.875 -0700] "GET /servicesNS/admin/launcher/data/ui/views?count=-1 HTTP/1.0" 200 126721 - - - 6ms'
{
"sourcetype": "sample_HEC",
"source": "sample_source",
"host": "sample_host",
}
The format of event and params for ingesting a batch of events::
'''127.0.0.1 - admin [28/Sep/2016:09:05:26.875 -0700] "GET /servicesNS/admin/launcher/data/ui/views?count=-1 HTTP/1.0" 200 126721 - - - 6ms
127.0.0.1 - admin [28/Sep/2016:09:05:26.917 -0700] "GET /servicesNS/admin/launcher/data/ui/nav/default HTTP/1.0" 200 4367 - - - 6ms
127.0.0.1 - admin [28/Sep/2016:09:05:26.941 -0700] "GET /services/apps/local?search=disabled%3Dfalse&count=-1 HTTP/1.0" 200 31930 - - - 4ms'''
{
"sourcetype": "sample_HEC",
"source": "sample_source",
"host": "sample_host",
}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
events |
list
|
List of events (SampleEvent) to be ingested |
required |
params |
dict
|
dict with the info of the data to be ingested. |
required |
Source code in pytest_splunk_addon/event_ingestors/hec_raw_ingestor.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
SC4S Event Ingestor¶
SC4SEventIngestor
¶
Bases: EventIngestor
Class to Ingest Events via SC4S
The format for required_configs is::
{
sc4s_host (str): Address of the Splunk Server. Do not provide http scheme in the host.
sc4s_port (int): Port number of the above host address
}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
required_configs |
dict
|
Dictionary containing splunk host and sc4s port |
required |
Source code in pytest_splunk_addon/event_ingestors/sc4s_event_ingestor.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
ingest(events, thread_count)
¶
Ingests events in the splunk via sc4s (Single/Batch of Events)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
events |
list
|
Events with newline character or LineBreaker as separator |
required |
Source code in pytest_splunk_addon/event_ingestors/sc4s_event_ingestor.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
File Monitor Ingestor¶
FileMonitorEventIngestor
¶
Bases: EventIngestor
Class to ingest event via File monitor This ingestor will only work if splunk_type is docker and container of universal forwarder is linked with container of splunk instance as ‘splunk’ service.
The format for required_configs is::
{
uf_host: Host of universal forwarder
uf_port: Management port of universal forwarder
uf_username: Name of user for universal forwarder
uf_password: Password of universal forwarder
}
Parameters:
Name | Type | Description | Default |
---|---|---|---|
required_configs |
dict
|
Dictionary containing information about universal forwarder |
required |
Source code in pytest_splunk_addon/event_ingestors/file_monitor_ingestor.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
create_event_file(event)
¶
Write each tokenized event in files with host name as name of file. The host of all events will be unique.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event |
SampleEvent
|
Instance containing event info |
required |
Source code in pytest_splunk_addon/event_ingestors/file_monitor_ingestor.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
|
create_inputs_stanza(event)
¶
Create stanza in inputs.conf on universal forwarder for each tokenized event.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event |
SampleEvent
|
Instance containing event info |
required |
Source code in pytest_splunk_addon/event_ingestors/file_monitor_ingestor.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
create_output_conf()
¶
Create stanza in outputs.conf file of universal forwarder to send on splunk(indexer).
Source code in pytest_splunk_addon/event_ingestors/file_monitor_ingestor.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
get_file_path(event)
¶
Returns absolute path for tokenized events.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
event |
SampleEvent
|
Instance containing event info |
required |
Source code in pytest_splunk_addon/event_ingestors/file_monitor_ingestor.py
180 181 182 183 184 185 186 187 188 189 190 |
|
ingest(events, thread_count)
¶
Ingests data into splunk via file monitor. Args: events (list): List of events (SampleEvent) to be ingested
Source code in pytest_splunk_addon/event_ingestors/file_monitor_ingestor.py
64 65 66 67 68 69 70 71 72 73 74 |
|