diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 28dae652a99..aba9c1f09d5 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -477,6 +477,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d *Heartbeat* +- Add mime type detection for http responses. {pull}22976[22976] *Heartbeat* diff --git a/heartbeat/_meta/config/processors.yml.tmpl b/heartbeat/_meta/config/processors.yml.tmpl new file mode 100644 index 00000000000..2b72d7fa461 --- /dev/null +++ b/heartbeat/_meta/config/processors.yml.tmpl @@ -0,0 +1,13 @@ +{{header "Processors"}} + +processors: + - add_observer_metadata: + # Optional, but recommended geo settings for the location Heartbeat is running in + #geo: + # Token describing this location + #name: us-east-1a + # Lat, Lon " + #location: "37.926868, -78.024902" + - detect_mime_type: + field: http.response.body.content + target: http.response.mime_type diff --git a/heartbeat/heartbeat.yml b/heartbeat/heartbeat.yml index 79a0eb21d8b..a2a802c076b 100644 --- a/heartbeat/heartbeat.yml +++ b/heartbeat/heartbeat.yml @@ -130,7 +130,9 @@ processors: #name: us-east-1a # Lat, Lon " #location: "37.926868, -78.024902" - + - detect_mime_type: + field: http.response.body.content + target: http.response.mime_type # ================================== Logging =================================== diff --git a/heartbeat/tests/system/config/heartbeat.yml.j2 b/heartbeat/tests/system/config/heartbeat.yml.j2 index 40990b39358..3411a9ce510 100644 --- a/heartbeat/tests/system/config/heartbeat.yml.j2 +++ b/heartbeat/tests/system/config/heartbeat.yml.j2 @@ -85,6 +85,11 @@ fields: {% endfor -%} {% endif %} +processors: + - detect_mime_type: + field: http.response.body.content + target: http.response.mime_type + #================================ Queue ===================================== queue.mem: diff --git a/heartbeat/tests/system/test_monitor.py b/heartbeat/tests/system/test_monitor.py index 98ace615bd3..4952ab8d259 100644 --- a/heartbeat/tests/system/test_monitor.py +++ b/heartbeat/tests/system/test_monitor.py @@ -126,6 +126,10 @@ def test_http_json(self, expected_status, body): self.assert_last_status(expected_status) if expected_status == "down": self.assertEqual(self.last_output_line()["http.response.body.content"], body) + if body == "notjson": + self.assertEqual(self.last_output_line()["http.response.mime_type"], "text/plain; charset=utf-8") + else: + self.assertEqual(self.last_output_line()["http.response.mime_type"], "application/json") else: assert "http.response.body.content" not in self.last_output_line() finally: