Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docker_logs source): ensure that docker labels are flattened
Fixes: #5716 Previously labels on docker containers were inserted in such a way that dots in their names would end up creating a nested structure in the log event due to the semantics of `LogEvent.insert`. For example: ```json { "container_created_at": "2021-04-16T18:53:19.946155600Z", "container_id": "d6bd69d4bc64bef20b4e992dcc23113741067e8268762694f92899504ae14319", "container_name": "docker_echo_1", "host": "COMP-C02DV25MML87", "image": "hashicorp/http-echo:latest", "label": { "com": { "docker": { "compose": { "config-hash": "e7e5ba19811180f27a7af36667652d0cd686599e6184cb023d9b71d791ff6a1e", "container-number": "1", "oneoff": "False", "project": { "config_files": "docker-compose.yml", "working_dir": "/private/tmp/docker" }, "service": "echo", "version": "1.27.4" } } } }, "message": "2021/04/16 19:14:10 localhost:5678 172.29.0.1:61824 \"GET / HTTP/1.1\" 200 6 \"curl/7.64.1\" 35.6µs", "source_type": "docker", "stream": "stdout", "timestamp": "2021-04-16T19:14:10.400790400Z" } ``` This change ensures that labels are inserted as-is as keys: ```json { "container_created_at": "2021-04-16T18:53:19.946155600Z", "container_id": "d6bd69d4bc64bef20b4e992dcc23113741067e8268762694f92899504ae14319", "container_name": "docker_echo_1", "host": "COMP-C02DV25MML87", "image": "hashicorp/http-echo:latest", "label": { "com.docker.compose.config-hash": "e7e5ba19811180f27a7af36667652d0cd686599e6184cb023d9b71d791ff6a1e", "com.docker.compose.container-number": "1", "com.docker.compose.oneoff": "False", "com.docker.compose.project": "docker", "com.docker.compose.project.config_files": "docker-compose.yml", "com.docker.compose.project.working_dir": "/private/tmp/docker", "com.docker.compose.service": "echo", "com.docker.compose.version": "1.27.4" }, "message": "2021/04/16 19:12:01 localhost:5678 172.29.0.1:61820 \"GET / HTTP/1.1\" 200 6 \"curl/7.64.1\" 18.1µs", "source_type": "docker", "stream": "stdout", "timestamp": "2021-04-16T19:12:01.622769500Z" } ``` Signed-off-by: Jesse Szwedko <[email protected]>
- Loading branch information