Hi there,
So I'm probably confusing myself here but I am trying to import logs from our Cloudflare instance into Elasticsearch, via a file that has many json entries and looks like the following (this is just a single log)
{ "brandId":100,"flags":2,"hosterId":0,"ownerId":XXXXXX,"rayId":"XXXXXXXXX","securityLevel":"med","timestamp":1504731172284000000,"unstablePublic":null,"zoneId":XXXXXXX,"zoneName":"test.com","zonePlan":"enterprise","client":{"asNum":4648,"country":"XX","deviceType":"desktop","ip":"XXXXXXXX","ipClass":"noRecord","srcPort":63970,"sslCipher":"NONE","sslFlags":0,"sslProtocol":"none"},"clientRequest":{"accept":"text/html, application/xhtml+xml, /","body":null,"bodyBytes":0,"bytes":246,"cookies":null,"flags":1,"headers":,"httpHost":"www.test.com","httpMethod":"GET","httpProtocol":"HTTP/1.1","referer":"","uri":"/","userAgent":"Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"},"edge":{"bbResult":"0","cacheResponseTime":0,"colo":26,"enabledFlags":12,"endTimestamp":1504731172288000000,"flServerIp":"XXXXXXXX","flServerName":"26f27","flServerPort":80,"pathingOp":"wl","pathingSrc":"macro","pathingStatus":"nr","startTimestamp":1504731172284000000,"usedFlags":0,"rateLimit":{"ruleId":0,"mitigationId":null,"sourceId":"","processedRules":null},"dnsResponse":{"rcode":0,"error":"ok","cached":false,"duration":0,"errorMsg":"","overrideError":false}},"edgeResponse":{"bodyBytes":5,"bytes":285,"compressionRatio":0,"contentType":"","headers":null,"setCookies":null,"status":301}}
Originally I set up mappings as follows
curl -XPUT http://localhost:9200/cloudflare -d '
{
"mappings" : {
"default" : {
"properties" : {
"securityLevel" : {"type": "string" },
"zoneName" : {"type": "string" },
"cacheExternalIP" : {"type": "string" },
"cacheInternalIP" : {"type": "string" },
"cacheExternalPort" : { "type" : "integer" },
"ruleType" : { "type" : "integer" }
}
}
}
}
';
When I go to import the logs using curl -XPUT localhost:9200/cloudflare/_bulk --data-binary @cloudflare.json I get the following error message.
{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Malformed action/metadata line [1], expected START_OBJECT or END_OBJECT but found [VALUE_NUMBER]"}],"type":"illegal_argument_exception","reason":"Malformed action/metadata line [1], expected START_OBJECT or END_OBJECT but found [VALUE_NUMBER]"},"status":400}
I did find this threat (_https://discuss.elastic.co/t/bulk-insert-file-having-many-json-entries-into-elasticsearch/46470_) and I understand the format is wrong when I am trying to insert using the Bulk format but I am not having much luck changing it.
Would anyone please be able to help me?
Thank you