-
Notifications
You must be signed in to change notification settings - Fork 1
/
sample-multi-csv-csv-noheader.conf
117 lines (94 loc) · 3.33 KB
/
sample-multi-csv-csv-noheader.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
####################### INPUT ############################
# An input enables a specific source of
# events to be read by Logstash.
##########################################################
input {
file {
type => "sales"
path => "/data/sales/sales.csv"
start_position => "beginning"
sincedb_path => "/dev/null"
}
file {
type => "orders"
path => "/data/orders/orders.csv"
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
####################### FILTER ###########################
# A filter performs intermediary processing on an event.
# Filters are often applied conditionally depending on the
# characteristics of the event.
##########################################################
filter {
# The CSV filter takes an event field containing CSV data,
# parses it, and stores it as individual fields (can optionally specify the names).
# This filter can also parse data with any separator, not just commas.
csv {
# Set the comma delimiter
separator => ","
# We want to exclude these system columns
remove_field => [
"message",
"host",
"@timestamp",
"@version",
"path"
]
# Define the layout of the input file
if [type] == "sales" { columns => [ "Sku","Name","SearchKeywords","Main","Price","ID","Brands" ] }
if [type] == "orders" { columns => [ "Sku","Name","SearchKeywords","Main","Price","ID","Brands" ] }
}
##############################
# Replaces non-ASCII characters with an ASCII approximation, or if none exists, a replacement character which defaults to ?
i18n { transliterate => [ "Sku","Name","SearchKeywords","Main","Price","ID","Brands" ] }
#############################
# Create consistent hashes (fingerprints) of one or more fields and store the result in a new field.
fingerprint { method => "SHA1" key => "MySecretKeyForMyEyesOnlyOk?" source => "Brands" target => "Brands" }
#############################
# The mutate filter allows you to perform general
# mutations on fields. You can rename, remove, replace
# and modify fields in your events
# We need to set the target column to "string" to allow for find and replace
mutate {
convert => [ "Sku", "string" ]
}
# Strip backslashes, question marks, equals, hashes, and minuses from the target column
mutate {
gsub => [ "Sku", "[\\?#=]", "" ]
}
# Strip extraneous white space from records
mutate {
strip => [
"Sku","Name","SearchKeywords","Main","Price","ID","Brands"
]
}
# Set everything to lowercase
mutate {
lowercase => [ "Sku","Name","SearchKeywords","Main","Price","ID","Brands"
]
}
}
####################### OUTPUT ###########################
# An output sends event data to a particular
# destination. Outputs are the final stage in the
# event pipeline.
##########################################################
output {
# Saving output to CSV so we define the layout of the file
if [type] == "sales" {
csv {
fields => [ "Sku","Name","SearchKeywords","Main","Price","ID","Brands" ]
path => "/data/clean-sales.csv"
codec => plain { charset => 'UTF-8' }
}
}
if [type] == "orders" {
csv {
fields => [ "Sku","Name","SearchKeywords","Main","Price","ID","Brands" ]
path => "/data/clean-orders.csv"
codec => plain { charset => 'UTF-8' }
}
}
}