-
Notifications
You must be signed in to change notification settings - Fork 1
/
hands-on1
100 lines (88 loc) · 1.76 KB
/
hands-on1
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
[Kibana - mapping]
GET _cat/indices
DELETE myfile
PUT myfile
{
"mappings": {
"myfile": {
"properties": {
"Country": {
"type": "keyword"
},
"Item Type": {
"type": "keyword"
},
"Order Date": {
"type": "date",
"format": "MM/dd/yyyy"
},
"Order ID": {
"type": "integer"
},
"Order Priority": {
"type": "keyword"
},
"Region": {
"type": "keyword"
},
"Sales Channel": {
"type": "keyword"
},
"Total Cost": {
"type": "float"
},
"Total Profit": {
"type": "float"
},
"Total Revenue": {
"type": "float"
},
"Unit Cost": {
"type": "float"
},
"Unit Price": {
"type": "float"
},
"Units Sold": {
"type": "integer"
}
}
}
}
}
GET myfile/_search
GET myfile/_mapping
[logstash - conf]
$ vi file.conf
input {
file {
path => "/home/ec2-user/data/5000_Sales_Records.csv"
start_position => "beginning"
#sincedb_path => "/dev/null" #only for develop
}
}
filter {
csv {
separator => ","
autodetect_column_names => true
}
date {
match => ["Ship Date", "MM/dd/YYYY", "ISO8601"]
timezone => "Asia/Seoul"
target => "Ship Date"
}
mutate {
remove_field => ["@version", "message", "path"]
}
}
output {
elasticsearch {
hosts => ["ec2-13-209-172-77.ap-northeast-2.compute.amazonaws.com:9200"]
index => "myfile"
document_type => "myfile"
}
#stdout { } #only for develop
}
$ bin/logstash -f file.conf
[scripted field]
doc['Ship Date'].date.dayOfYear - doc['Order Date'].date.dayOfYear