When I filter HTTP 500 code I have only 3 hits.
Here is what I get when I catch HTTP 500 code, as you can see in the message, the value is related to HTTP protocol and not the stacktrace of the application:
{
"_index": "k8s-test-app-admin-2024.02",
"_id": "x8Aix40BRPoEsDWM",
"_version": 1,
"_score": 1,
"_ignored": [
"message.keyword"
],
"_source": {
"container": {
"image": {
"name": "gitlab.app.002.fr:5005/ln/nto:ln_admin_nto"
},
"id": "b2d2bcc5ab8a9ef64aecbf41a8c758e998217e5c22",
"runtime": "docker"
},
"tags": [
"beats_input_codec_plain_applied"
],
"method": "POST",
"kubernetes": {
"labels": {
"workloadID_ingress-3c032470f6d1a567dcd068ce4889bf3b": "true",
"logme": "true",
"workloadID_ingress-ea457564d91bc9b1d4997822ea1e97ac": "true",
"workloadID_ingress-9de728feae5c3ffa112d6d840a43c4d0": "true"
},
"namespace_labels": {
"cattle_io/creator": "norman"
},
"replicaset": {
"name": "app-test-admin-77bd68f65d"
},
"pod": {
"ip": "10.42.3.30",
"name": "app-test-admin-77bd68f65d-9wsb6"
},
"container": {
"name": "app-test-admin"
},
"deployment": {
"name": "app-test-admin"
},
"namespace": "app-test",
"node": {
"labels": {},
"name": "von-wor-01",
"hostname": "von-wor-01"
}
},
"request_size": "1825",
"request": "/secured/honorary-consul/declaration/17/edit",
"app_access_full_request": "POST /secured/honorary-consul/declaration/17/edit HTTP/1.1",
"host": {
"name": "von-wor-01"
},
"@version": "1",
"client_ip": "0.0.1.187",
"app_access_timestamp": "20/Feb/2024:15:29:15 +0000",
"status_code": "500",
"client_identity": "-",
"user_id": "-",
"@timestamp": "2024-02-20T15:29:15Z",
"ecs": {
"version": "8.0.0"
},
"input": {
"type": "container"
},
"agent": {
"version": "8.0.1",
"name": "von-wor-01",
"type": "filebeat",
"id": "e28625b4-85dc-489b-9ffd-f39d2a4a23f7",
"ephemeral_id": "eea74980-db4e-4ccb-b4e6-e48b4e782d00"
},
"referer": "https://ln-protocole-qual.intranet.ste.fr/secured/honorary-consul/declaration/17/edit",
"http_version": "1.1",
"event": {},
"stream": "stdout",
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0",
"log": {
"file": {
"path": "/var/log/containers/app-test-admin-77bd68f65d-9wsb6_app-test_app-test-admin-b2d2bcc0f92ac283255ab8a9ef5866c83f94764aecbf41a8c758e998217e5c22.log"
},
"offset": 8766689
},
"message": "0.0.1.187 - - [20/Feb/2024:15:29:15 +0000] \"POST /secured/honorary-consul/declaration/17/edit HTTP/1.1\" 500 1825 \"https://ln-protocole-qual.intranet.ste.fr/secured/honorary-consul/declaration/17/edit\" \"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0\""
}
}
But actually if I remove the filter status_code:500, I have 51 hits. Among them there are the logs of the application:
Here is one of the hit log. In this one THERE IS NO CODE HTTP 500, but there is the a part of the stack trace in the value of message key
{
"_index": "k8s-app-test-app-test-admin-2024.02",
"_id": "1sAix40BRPoEE3WhsDWO",
"_version": 1,
"_score": 1,
"_source": {
"container": {
"image": {
"name": "gitlab.app.ste.lu:5005/ind/app:mae_admin_oidc"
},
"id": "b2d2bcc0f92ac283255ab8a9ef5866c83f94764aecbf41a8c758e998217e5c22",
"runtime": "docker"
},
"host": {
"name": "von-wor-01"
},
"@version": "1",
"tags": [
"beats_input_codec_plain_applied",
"_grokparsefailure"
],
"kubernetes": {
"labels": {
"logme": "true",
"workloadID_ingress-3c032470f6d1a567dcd068ce4889bf3b": "true",
"workloadID_ingress-ea457564d91bc9b1d4997822ea1e97ac": "true",
"workloadID_ingress-9de728feae5c3ffa112d6d840a43c4d0": "true"
},
"namespace_labels": {
"cattle_io/creator": "norman"
},
"replicaset": {
"name": "app-test-admin-77bd68f65d"
},
"pod": {
"ip": "10.42.3.30",
"name": "app-test-admin-77bd68f65d-9wsb6"
},
"container": {
"name": "app-test-admin"
},
"deployment": {
"name": "app-test-admin"
},
"namespace": "app-test",
"node": {
"labels": {},
"name": "von-wor-01",
"hostname": "von-wor-01"
}
},
"@timestamp": "2024-02-20T15:29:15.673Z",
"ecs": {
"version": "8.0.0"
},
"input": {
"type": "container"
},
"agent": {
"version": "8.0.1",
"name": "von-wor-01",
"type": "filebeat",
"id": "e28625b4-85dc-489b-9ffd-f39d2a4a23f7",
"ephemeral_id": "eea74980-db4e-4ccb-b4e6-e48b4e782d00"
},
"event": {},
"stream": "stdout",
"log": {
"offset": 8764433,
"file": {
"path": "/var/log/containers/app-test-admin-77bd68f65d-9wsb6_app-test_app-test-admin-b2d2bcc0f92ac283255ab8a9ef5866c83f94764aecbf41a8c758e998217e5c22.log"
}
},
"message": "#8 /var/www/html/vendor/symfony/form/Extension/HttpFoundation/HttpFoundationRequestHandler.php(110): Symfony\\\\Component\\\\Form\\\\Form->submit()"
},
By the way I have just understood that all my stack traces logs are split each time ELK encounters "\n".
So my questions now are different.
- How can I merge the stack traces so they are not split each time ELK encounters "\n"?
As when I look at a status_code:500 log, the value of the key "message" doesn't show any messages related to the stack traces and the logs which are related to the stack traces don't include the status_code:500 key/value pair. The only link that I see is that both type of logs are in the same time frame.
- How can I catch the logs related to stack traces when I listen to logs with a status_code:500?