Appreciate your response, How we can implement a logic like below in the logstash conf?
Below I mentioned the json documents of the above csv file(output of logstash) before passing to elasticsearch index.
{
"@version":"1",
"ecs":{
"version":"1.5.0"
},
"agent":{
"type":"filebeat",
"id":"168be642-9aa7-4db6-97f2-f01474f6b576",
"version":"7.8.0",
"ephemeral_id":"0743b908-7cee-42b8-b667-fe715cbbe44b",
"name":"8c2f87a95468",
"hostname":"8c2f87a95468"
},"log":{
"file":{
"path":"/usr/share/filebeat/reports/test/1/report.csv"
},
"offset":82
},
"fields":{
"log_type":"katalon_ui_reports"
},
"message":"API_Test_suite,,,,2020-07-31 12:45:19,2020-07-31 12:45:34,14.513s,PASSED",
"host":{
"id":"83a8f1f835d84a9a9bf5417cecaf0c8e",
"os":{
"version":"7 (Core)",
"family":"redhat",
"name":"CentOS Linux",
"kernel":"4.19.104-microsoft-standard",
"codename":"Core",
"platform":"centos"
},
"containerized":true,
"name":"8c2f87a95468",
"ip":["10.1.4.1"],
"mac":["02:42:0a:01:04:01"],
"architecture":"x86_64",
"hostname":"8c2f87a95468"
},
"Suite/Test/Step Name":"API_Test_suite",
"Start time":"2020-07-31T12:45:19.000Z",
"input":{"type":"log"},
"Status":"PASSED",
"@timestamp":"2020-08-01T06:35:14.668Z",
"End time":"2020-07-31T12:45:34.000Z",
"tags":["katalon_ui_reports","beats_input_codec_plain_applied"],
"Duration":"14.513s"
}
{
"@version":"1",
"input":{
"type":"log"
},
"ecs":{
"version":"1.5.0"
},
"agent":{
"type":"filebeat",
"id":"168be642-9aa7-4db6-97f2-f01474f6b576",
"version":"7.8.0",
"ephemeral_id":"0743b908-7cee-42b8-b667-fe715cbbe44b",
"name":"8c2f87a95468",
"hostname":"8c2f87a95468"
},
"@timestamp":"2020-08-01T06:35:14.669Z",
"log":{
"file":{
"path":"/usr/share/filebeat/reports/test/1/report.csv"
},"offset":156
},
"message":",,,,,,,",
"tags":["katalon_magnify_ui_reports","beats_input_codec_plain_applied"],
"fields":{
"log_type":"katalon_ui_reports"
},
"host":{
"id":"83a8f1f835d84a9a9bf5417cecaf0c8e",
"os":{
"version":"7 (Core)",
"family":"redhat",
"name":"CentOS Linux",
"kernel":"4.19.104-microsoft-standard",
"codename":"Core"
,"platform":"centos"
},
"containerized":true,
"name":"8c2f87a95468",
"ip":["10.1.4.1"],
"mac":["02:42:0a:01:04:01"],
"architecture":"x86_64",
"hostname":"8c2f87a95468"
}
}
{
"@version":"1",
"ecs":{
"version":"1.5.0"
},
"log":{
"file":{
"path":"/usr/share/filebeat/reports/test/1/report.csv"
},
"offset":165
},
"agent":{
"type":"filebeat",
"id":"168be642-9aa7-4db6-97f2-f01474f6b576",
"version":"7.8.0",
"ephemeral_id":"0743b908-7cee-42b8-b667-fe715cbbe44b",
"name":"8c2f87a95468",
"hostname":"8c2f87a95468"
},
"fields":{
"log_type":"katalon_magnify_ui_reports"
},
"message":"Test Cases/API/C7PingTest/TC - 004,,Valid parameter for c7 ping test,,2020-07-31 12:45:26,2020-07-31 12:45:32,6.426s,PASSED",
"host":{
"id":"83a8f1f835d84a9a9bf5417cecaf0c8e",
"os":{
"version":"7 (Core)",
"family":"redhat",
"name":"CentOS Linux",
"kernel":"4.19.104-microsoft-standard",
"codename":"Core",
"platform":"centos"
},
"containerized":true,
"name":"8c2f87a95468",
"mac":["02:42:0a:01:04:01"],
"ip":["10.1.4.1"],
"architecture":"x86_64",
"hostname":"8c2f87a95468"
},
"Suite/Test/Step Name":"Test Cases/API/C7PingTest/TC - 004",
"Start time":"2020-07-31T12:45:26.000Z",
"input":{
"type":"log"
},
"Status":"PASSED",
"@timestamp":"2020-08-01T06:35:14.669Z",
"End time":"2020-07-31T12:45:32.000Z",
"tags":["katalon_ui_reports","beats_input_codec_plain_applied"],
"Duration":"6.426s",
"Description":"Valid parameter for c7 ping test"
}
{
"@version":"1",
"ecs":{
"version":"1.5.0"
},
"agent":{
"type":"filebeat",
"id":"168be642-9aa7-4db6-97f2-f01474f6b576",
"version":"7.8.0",
"ephemeral_id":"0743b908-7cee-42b8-b667-fe715cbbe44b",
"name":"8c2f87a95468",
"hostname":"8c2f87a95468"
},
"log":{
"file":{
"path":"/usr/share/filebeat/reports/test/1/report.csv"
},
"offset":290
},
"fields":{
"log_type":"katalon_ui_reports"
},
"message":"\"response = sendRequest(findTestObject(\"\"API/C7PingTest - End Point/Request - 004\"\"))\",,,,2020-07-31 12:45:26,2020-07-31 12:45:32,5.827s,PASSED",
"host":{
"id":"83a8f1f835d84a9a9bf5417cecaf0c8e",
"containerized":true,
"os":{
"version":"7 (Core)",
"family":"redhat",
"name":"CentOS Linux",
"kernel":"4.19.104-microsoft-standard",
"codename":"Core",
"platform":"centos"
},
"name":"8c2f87a95468",
"ip":["10.1.4.1"],
"mac":["02:42:0a:01:04:01"],
"architecture":"x86_64",
"hostname":"8c2f87a95468"
},
"Suite/Test/Step Name":"response = sendRequest(findTestObject(\"API/C7PingTest - End Point/Request - 004\"))",
"Start time":"2020-07-31T12:45:26.000Z",
"input":{"type":"log"},
"Status":"PASSED",
"@timestamp":"2020-08-01T06:35:14.669Z",
"End time":"2020-07-31T12:45:32.000Z",
"tags":["katalon_ui_reports","beats_input_codec_plain_applied"],
"Duration":"5.827s"
}
{
"@version":"1",
"ecs":{"version":"1.5.0"},
"agent":{
"type":"filebeat",
"id":"168be642-9aa7-4db6-97f2-f01474f6b576",
"version":"7.8.0",
"ephemeral_id":"0743b908-7cee-42b8-b667-fe715cbbe44b",
"name":"8c2f87a95468",
"hostname":"8c2f87a95468"
},
"log":{
"file":{
"path":"/usr/share/filebeat/reports/test/1/report.csv"
},
"offset":435
},
"fields":{
"log_type":"katalon_ui_reports"
},
"message":"\"verifyResponseStatusCode(response, 200)\",,,,2020-07-31 12:45:32,2020-07-31 12:45:32,0.003s,PASSED",
"host":{
"id":"83a8f1f835d84a9a9bf5417cecaf0c8e",
"containerized":true,
"os":{
"version":"7 (Core)",
"family":"redhat",
"name":"CentOS Linux",
"kernel":"4.19.104-microsoft-standard",
"codename":"Core",
"platform":"centos"
},
"name":"8c2f87a95468",
"ip":["10.1.4.1"],
"mac":["02:42:0a:01:04:01"],
"architecture":"x86_64",
"hostname":"8c2f87a95468"
},
"Suite/Test/Step Name":"verifyResponseStatusCode(response, 200)",
"Start time":"2020-07-31T12:45:32.000Z",
"input":{"type":"log"},
"Status":"PASSED",
"@timestamp":"2020-08-01T06:35:14.669Z",
"End time":"2020-07-31T12:45:32.000Z",
"tags":["katalon_ui_reports","beats_input_codec_plain_applied"],
"Duration":"0.003s"
}
{
"@version":"1",
"ecs":{
"version":"1.5.0"
},
"agent":{
"type":"filebeat",
"id":"168be642-9aa7-4db6-97f2-f01474f6b576",
"version":"7.8.0",
"ephemeral_id":"0743b908-7cee-42b8-b667-fe715cbbe44b",
"name":"8c2f87a95468",
"hostname":"8c2f87a95468"
},
"log":{
"file":{
"path":"/usr/share/filebeat/reports/test/1/report.csv"
},
"offset":535
},
"fields":{
"log_type":"katalon_ui_reports"
},
"message":"\"verifyElementPropertyValue(response, \"\"success\"\", true)\",,,,2020-07-31 12:45:32,2020-07-31 12:45:32,0.056s,PASSED",
"host":{
"id":"83a8f1f835d84a9a9bf5417cecaf0c8e",
"os":{
"version":"7 (Core)",
"family":"redhat",
"name":"CentOS Linux",
"kernel":"4.19.104-microsoft-standard",
"codename":"Core",
"platform":"centos"
},
"containerized":true,
"name":"8c2f87a95468",
"ip":["10.1.4.1"],
"mac":["02:42:0a:01:04:01"],
"architecture":"x86_64",
"hostname":"8c2f87a95468"
},
"Suite/Test/Step Name":"verifyElementPropertyValue(response, \"success\", true)",
"Start time":"2020-07-31T12:45:32.000Z",
"input":{"type":"log"},
"Status":"PASSED",
"@timestamp":"2020-08-01T06:35:14.669Z",
"End time":"2020-07-31T12:45:32.000Z",
"tags":["katalon_ui_reports","beats_input_codec_plain_applied"],
"Duration":"0.056s"
}
{
"@version":"1",
"ecs":{
"version":"1.5.0"
},
"agent":{
"type":"filebeat",
"id":"168be642-9aa7-4db6-97f2-f01474f6b576",
"version":"7.8.0",
"ephemeral_id":"0743b908-7cee-42b8-b667-fe715cbbe44b",
"name":"8c2f87a95468",
"hostname":"8c2f87a95468"
},
"log":{
"file":{
"path":"/usr/share/filebeat/reports/test/1/report.csv"
},
"offset":651
},
"fields":{
"log_type":"katalon_ui_reports"
},
"message":"\"verifyElementPropertyValue(response, \"\"testResult\"\", true)\",,,,2020-07-31 12:45:32,2020-07-31 12:45:32,0.036s,PASSED",
"host":{
"id":"83a8f1f835d84a9a9bf5417cecaf0c8e",
"containerized":true,
"os":{
"version":"7 (Core)",
"family":"redhat",
"name":"CentOS Linux",
"kernel":"4.19.104-microsoft-standard",
"codename":"Core",
"platform":"centos"
},
"name":"8c2f87a95468",
"ip":["10.1.4.1"],
"mac":["02:42:0a:01:04:01"],
"architecture":"x86_64",
"hostname":"8c2f87a95468"
},
"Suite/Test/Step Name":"verifyElementPropertyValue(response, \"testResult\", true)",
"Start time":"2020-07-31T12:45:32.000Z",
"input":{"type":"log"},
"Status":"PASSED",
"@timestamp":"2020-08-01T06:35:14.669Z",
"End time":"2020-07-31T12:45:32.000Z",
"tags":["katalon_ui_reports","beats_input_codec_plain_applied"],
"Duration":"0.036s"
}
This how csv file looks like,
as you can see in the json file, for each row in the csv file, there is json document in the above json(logstash output). Each json document there is a field called "message" which has the katalon test result data; I need to get the test case name and apply that name to it's test steps as a new field. As an example, according to above data, first non header row has the test suite name, second none header row is a empty row(it has the message: ',,,,,,,') ; third none header row has the first test case name of the test suite; 4th none header row to 8th none header row have test steps of that particular test case. I need to get that test case name which is in the 3rd none header row and put that name in all it's test steps(4th to 8th none header rows) as a new field? One file may have multiple test cases. how to loop above implementation?
In the above picture,
Test Cases/API/C7PingTest/TC - 004
Test Cases/API/Diversions Lookup/TC - 004
are the test case names.