I'm trying to import CSV to elastic, I was fallowing this post
My data looks like this:
From,To,NetEnforcer,Total Bandwidth (Gbps),In Bandwidth (Gbps),Out Bandwidth (Gbps),In Packets (Pps),Out Packets (Pps),Live Connections,New Connections (Conn/sec),Dropped Connections
Sep 20 2018 08:50:31,Sep 20 2018 08:51:00,CSC01QOS02,0.913,0.637,0.276,0.0,0.0,54194,887.4,0.0
You can notice straight away the non standard date stamp, please note that there are 2 spaces between 2018 and the time.
I have tested my data with pipeline simulate and it's working fine:
POST _ingest/pipeline/_simulate
{
"pipeline": {
"description": "Parsing the Netenforcer logs",
"processors": [
{
"grok": {
"field": "net_enforcer",
"patterns": [
"%{CUSTOMSTAMP:time_from},%{CUSTOMSTAMP:time_to},%{HOSTNAME:netenforcer},%{BASE16FLOAT:total_bandwidth},%{BASE16FLOAT:in_bandwidth},%{BASE16FLOAT:out_bandwidth},%{BASE16FLOAT:in_packets},%{BASE16FLOAT:out_packets},%{BASE16FLOAT:live_connections},%{BASE16FLOAT:new_connections},%{BASE16FLOAT:dropped_connections}"
],
"pattern_definitions" : {
"CUSTOMSTAMP" : "%{MONTH} +%{MONTHDAY} +%{YEAR} \\s* %{HOUR}:%{MINUTE}:%{SECOND}"
}
}
},
{
"remove": {
"field": "net_enforcer"
}
}
]
},
"docs": [
{
"_index":"netenforcer_log",
"_type":"entry",
"_source": {
"net_enforcer": "Sep 20 2018 08:50:31,Sep 20 2018 08:51:00,CSC01QOS02,0.913,0.637,0.276,0.0,0.0,54194,887.4,0.0"}
}
]
}
My template:
PUT _template/netenforcer_template
{
"index_patterns": "netenforcer_log*",
"settings": {
"number_of_shards": 1
},
"mappings": {
"net_enforcer": {
"properties": {
"time_from": {
"type": "date",
"format": "MMM dd yyyy HH:mm:ss"
},
"time_to": {
"type": "date",
"format": "MMM dd yyyy HH:mm:ss"
},
"netenforcer": {
"type": "keyword"
},
"total_bandwidth": {
"type": "float"
},
"in_bandwidth": {
"type": "float"
},
"out_bandwidth": {
"type": "float"
},
"in_packets": {
"type": "float"
},
"out_packets": {
"type": "float"
},
"live_connections": {
"type": "float"
},
"new_connections": {
"type": "float"
},
"dropped_connections": {
"type": "float"
}
}
}
}
}
My pipeline:
PUT _ingest/pipeline/parse_netenforcer_csv
{
"description": "Parsing the Netenforcer logs",
"processors": [{
"grok": {
"field": "net_enforcer",
"patterns": [
"%{CUSTOMSTAMP:time_from},%{CUSTOMSTAMP:time_to},%{HOSTNAME:netenforcer},%{BASE16FLOAT:total_bandwidth},%{BASE16FLOAT:in_bandwidth},%{BASE16FLOAT:out_bandwidth},%{BASE16FLOAT:in_packets},%{BASE16FLOAT:out_packets},%{BASE16FLOAT:live_connections},%{BASE16FLOAT:new_connections},%{BASE16FLOAT:dropped_connections}"
],
"pattern_definitions" : {
"CUSTOMSTAMP" : "%{MONTH} +%{MONTHDAY} +%{YEAR} \\s* %{HOUR}:%{MINUTE}:%{SECOND}"
}
}
},
{
"remove": {
"field": "net_enforcer"
}
}
]
}
MY test:
curl -XPOST 'http://docker.oc.lab:9200/netenforcer_log_test/net_enforcer?pipeline=parse_netenforcer_csv' -H "Content-Type: application/json" -u elastic:changeme -d "{ \"net_enforcer\": \"Sep 20 2018 08:50:31,Sep 20 2018 08:51:00,CSC01QOS02,0.913,0.637,0.276,0.0,0.0,54194,887.4,0.0\" }"
Error:
{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse [time_to]"}],"type":"mapper_parsing_exception","reason":"failed to parse [time_to]","caused_by":{"type":"illegal_argument_exception","reason":"Invalid format: \"Sep 20 2018 08:51:00\""}},"status":400}
I don't see where I made mistake