Skip to content

Commit 43397d7

Browse files
andrewkrohruflin
authored andcommitted
Add labels to Docker healthcheck output (#3707)
The healthcheck output was inconsistent with the other docker metricsets and did not include labels.
1 parent 96bb79b commit 43397d7

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

CHANGELOG.asciidoc

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ https://github.com/elastic/beats/compare/v5.1.1...master[Check the HEAD diff]
5555
- Fix bug docker module hanging when docker container killed. {issue}3610[3610]
5656
- Set timeout to period instead of 1s by default as documented.
5757
- Add error handling to system process metricset for when Linux cgroups are missing from the kernel. {pull}3692[3692]
58+
- Add labels to the Docker healthcheck metricset output. {pull}3707[3707]
5859

5960
*Packetbeat*
6061

metricbeat/module/docker/healthcheck/_meta/data.json

+13-5
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,23 @@
66
},
77
"docker": {
88
"container": {
9-
"id": "6d01caff41f2f9118c0ced423579d70b6161eec614270e3cbf1b72e2bb40f84e",
10-
"name": "gifted_hugle"
9+
"id": "1bab78b8101e4d4df7de3dd9747512641bd0e97f886ca44be2f3f22a7b90ea2b",
10+
"labels": {
11+
"com_docker_compose_config-hash": "1b78c28e8f14c2d7804c5b002c0f1dd29afac4a82737d38d079d227029013732",
12+
"com_docker_compose_container-number": "1",
13+
"com_docker_compose_oneoff": "False",
14+
"com_docker_compose_project": "metricbeatdocker",
15+
"com_docker_compose_service": "elasticsearch",
16+
"com_docker_compose_version": "1.11.1"
17+
},
18+
"name": "elasticsearch"
1119
},
1220
"healthcheck": {
1321
"event": {
14-
"end_date": "2017-01-25T10:58:51.171Z",
22+
"end_date": "2017-03-02T05:19:07.701Z",
1523
"exit_code": 0,
16-
"output": "",
17-
"start_date": "2017-01-25T10:58:51.114Z"
24+
"output": "{\n \"name\" : \"iElnwHE\",\n \"cluster_name\" : \"elasticsearch\",\n \"cluster_uuid\" : \"phQC_WOFRBK10LUqTQS5lA\",\n \"version\" : {\n \"number\" : \"6.0.0-alpha1\",\n \"build_hash\" : \"d02170b\",\n \"build_date\" : \"2017-02-06T12:00:50.817Z\",\n \"build_snapshot\" : true,\n \"lucene_version\" : \"6.4.1\"\n },\n \"tagline\" : \"You Know, for Search\"\n}\n",
25+
"start_date": "2017-03-02T05:19:07.646Z"
1826
},
1927
"failingstreak": 0,
2028
"status": "healthy"

metricbeat/module/docker/healthcheck/data.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ func eventMapping(cont *dc.APIContainers, m *MetricSet) common.MapStr {
4141

4242
return common.MapStr{
4343
mb.ModuleData: common.MapStr{
44-
"container": common.MapStr{
45-
"name": docker.ExtractContainerName(cont.Names),
46-
"id": cont.ID,
47-
},
44+
"container": docker.NewContainer(cont).ToMapStr(),
4845
},
4946
"status": container.State.Health.Status,
5047
"failingstreak": container.State.Health.FailingStreak,
@@ -55,7 +52,6 @@ func eventMapping(cont *dc.APIContainers, m *MetricSet) common.MapStr {
5552
"output": container.State.Health.Log[lastEvent].Output,
5653
},
5754
}
58-
5955
}
6056

6157
// hasHealthCheck detects if healthcheck is available for container

0 commit comments

Comments
 (0)