UNIX and Linux package logs: Reduce log size and convert to TSV format¶
Disclaimer
By using SPL2 templates for data processing (the “templates”), you understand and agree that templates are provided “as is”. Splunk disclaims any and all warranties, express or implied, including without limitation the implied warranties of merchantability, fitness for a particular purpose and warranties arising out of course of dealing or usage of trade or by statute or in law. Splunk specifically does not warrant that templates will meet your requirements, the operation or output of templates will be error-free, accurate, reliable, complete or uninterrupted.
Use case¶
Reduce the size of Unix and Linux package
logs by removing unnecessary fields, replacing invalid values, and optimizing log storage. Extract essential fields while maintaining compatibility with the Splunk Common Information Model (CIM).
Version 0.4.2¶
Version 0.4.2 of the UNIX and Linux package logs: Reduce log size and convert to TSV format
template was released on April 18, 2025.
Template details¶
Compatibility¶
This template is compatible with Splunk Add-on for Unix and Linux v9.2.0 and v10.0.0.
Template description¶
This is a sample pipeline that reduces the size of package
logs coming from the Splunk Add-on for Unix and Linux while preserving compatibility with the Splunk Common Information Model (CIM). This pipeline processes data with the package
source type and performs the following:
- Replaces repeated space characters used as delimiters in the logs with a single tab character (
\t
) or a custom delimiter. - Removes unnecessary data from the logs.
- Converts the logs into tab-separated values (TSV) format.
- Optionally updates the values of the
source
andsourcetype
event fields.
Supported sourcetype¶
This pipeline only works on complete package
events that include the header row and all subsequent rows.
Template outline¶
The template consists of several custom functions followed by a pipeline that uses these functions.
Functions¶
The following table shows all functions, including possible configuration options.
Function name | Description | Configuration options |
---|---|---|
replace_multiple_whitespaces |
Replaces repeated space characters in the logs with a single tab character (\t ) or a custom delimiter. |
$delimiter : The replacement delimiter to use instead of repeated space characters (default: \t ). |
extract_split_rows |
Splits the logs into rows using the newline character (\n ) as the delimiter and further splits the rows into columns using the tab character (\t ) or a custom delimiter. |
$row_split_separator : The delimiter for splitting rows into columns (default: \t ). |
find_header_indexes |
Assigns a number to each log field. Other functions in this pipeline use these numbers as indexes for accessing the log contents. | No configuration options. |
drop_events_with_value_System_Environment_Base |
Removes rows where the value of the GROUP field is System Environment/Base . |
No configuration options. |
drop_events_with_value_System_Environment_Kernel |
Removes rows where the value of the GROUP field is System Environment/Kernel . |
No configuration options. |
drop_events_with_value_Development_Debuggers |
Removes rows where the value of the GROUP field is Development/Debuggers . |
No configuration options. |
drop_events_with_value_Applications_Archiving |
Removes rows where the value of the GROUP field is Applications/Archiving . |
No configuration options. |
drop_fields_arch_noarch |
Replaces any noarch or (none) values in the ARCH field with an empty value. |
No configuration options. |
drop_fields_group_Unspecified |
Replaces any Unspecified values in the GROUP field with an empty value. |
No configuration options. |
drop_fields_vendor_none |
Replaces any (none) values in the VENDOR field with an empty value. |
No configuration options. |
rows_to_delimiter_separated |
Transforms the logs from JSON array format to tab-separated key-value pair format. | $delimiter : The delimiter to use between columns (default: \t ). |
apply_transformations |
Groups the previously defined custom functions together to apply transformations to the logs. | No configuration options. |
update_source_and_source_type |
Appends a suffix to the values in the source and sourcetype fields, if those fields exist in the event. |
$suffix : The suffix to append to the source and sourcetype values. |
Pipeline¶
This pipeline has the following outline:
- Replaces repeated space characters with tabs using the
replace_multiple_whitespaces
function. - Splits the logs into rows and columns using the
extract_split_rows
function. - Assigns indexes to the log fields using the
find_header_indexes
function. - Removes rows where the
GROUP
field has specific values using the following functions: -drop_events_with_value_System_Environment_Base
-drop_events_with_value_System_Environment_Kernel
-drop_events_with_value_Development_Debuggers
-drop_events_with_value_Applications_Archiving
- Replaces invalid values in specific fields using the following functions:
-
drop_fields_arch_noarch
-drop_fields_group_Unspecified
-drop_fields_vendor_none
- Transforms the logs into tab-separated key-value pair format using the
rows_to_delimiter_separated
function. - Optionally updates the
source
andsourcetype
fields using theupdate_source_and_source_type
function. - Sends the transformed logs to the destination.
Configuration instructions¶
For significant license savings, use the drop_events_with_value_*
and drop_fields_*
functions to remove unnecessary rows and replace redundant or irrelevant values in specific fields. You can comment out any of these functions you do not want to apply by prefixing it with //
, allowing you to retain specific data that might otherwise be removed or modified.
Optionally, use the update_source_and_source_type
function to append a suffix to the source
and sourcetype
fields, helping to distinguish modified logs from unmodified ones.
Notes¶
- Ensure that the
package
source type is properly configured in your Splunk deployment. - Customize the pipeline as needed to meet your specific requirements.
- If using the
update_source_and_source_type
function, ensure that the suffixed source type is configured in your Splunk platform deployment with appropriate time extraction and line-breaking settings.