-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add HealthCheck information for Metricbeat docker module #3357
Conversation
Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run. |
1 similar comment
Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to think where this fits best. As far as I understand it is available when defined in the docker container or on start of the container. It is kind part of the container so it fits here. So far container
provides some information about the container which is fairly constant. state
or health
on the other side changes over time. There could be an argument to put it into a separate metricset because of that. I'm mentioning state as there are potential more infos we could have under a state metricset, not only health? What else is available?
I would really appreciate your help / input here on what you would recommend.
@@ -99,6 +99,21 @@ func (p Port) Proto() string { | |||
return parts[1] | |||
} | |||
|
|||
// HealthCheck represents one check of health. | |||
type HealthCheck struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the docker library is updated, also the commit id in the glide.yml file must be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HealthCheck structure in fsouza/go-dockerclient library have been updated in october :
https://github.com/fsouza/go-dockerclient/commit/45c1a814bcd9b656bdb9813a7c21d0236fc301db
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit id must be updated here: https://github.com/elastic/beats/blob/master/metricbeat/module/docker/glide.yaml Please make sure to copy all changes from this commit to the vendor directory.
@@ -31,7 +32,26 @@ func eventMapping(cont *dc.APIContainers) common.MapStr { | |||
"status": cont.Status, | |||
} | |||
|
|||
// Check id container have health metrics configured | |||
if strings.Contains(cont.Status, "(") && strings.Contains(cont.Status, ")") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which docker versions support this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Healthcheck is available since Docker 1.12, the only way to get bracket in container status is to configure healthcheck eaven in previous versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cont.Status is available since a while now maybe docker 0.6 or even before so this field will always be available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, that means the data fetching will also work with older version as the state is optional also for >= 1.12.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exactly
@@ -40,3 +40,24 @@ | |||
type: long | |||
description: > | |||
Size of the files that have been created or changed since creation. | |||
- name: health |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the field naming, please check our naming conventions: https://www.elastic.co/guide/en/beats/libbeat/5.1/event-conventions.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some more comments. Please make sure to also run make fmt
before pushing to follow the coding style.
@@ -31,7 +32,26 @@ func eventMapping(cont *dc.APIContainers) common.MapStr { | |||
"status": cont.Status, | |||
} | |||
|
|||
// Check id container have health metrics configured | |||
if strings.Contains(cont.Status, "(") && strings.Contains(cont.Status, ")") { | |||
container, _ := m.dockerClient.InspectContainer(cont.ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One issue I have with this is that for each container this does an additional http request. So if we have 100 containers, this can take quite some time. Is there a possibility to get the data already from the existing data we have? Otherwise we should parallel these requests and make container.health
a config option so it can be enabled/disabled based on the needs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed if we have 100 containers with healthcheck enabled it could take some more time.
In order to get these Container Health information precisely, we have to inspect the container, it couldn't be fetch easily so the InspectContainer function. How clould we make container.health option ? as metricbeat docker module ? (like container, disk, cpu ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could just introduce a configuration option as mentioned above with container.health: false
by default. Alternatively we can make it an additional metricset. I like the idea of a separate metricset and we can still merge it into container later if needed. 👍
Can you also add a line to the CHANGELOG? |
@sebastienmusso Ping me when you think it is ready for a next review. |
Hi,
I'm available for the review, on wich topic should we talk ?
Regards.
2017-01-16 15:29 GMT+01:00 Nicolas Ruflin <[email protected]>:
… @sebastienmusso <https://github.com/sebastienmusso> Ping me when you
think it is ready for a next review.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3357 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AERS1yOCMkZ30lP5Yayk8n6gFDhjUR7wks5rS360gaJpZM4Lh7yl>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments. Please make sure to run make update
and make fmt
before pushing the changes, as otherwise CI will fail.
@@ -2,3 +2,6 @@ package: github.com/elastic/beats/metricbeat/module/docker | |||
import: | |||
- package: github.com/fsouza/go-dockerclient | |||
version: 23c589186c2a92a8742da55f19aec4997dae5cbb | |||
import: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docker client is already mentioned above. You must update the version and overwrite all files from the client with the new commit id to make sure the full client is updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comparing these two commits, there are many more changes: fsouza/go-dockerclient@23c5891...45c1a81 I will update the library in a separate commit so you don't have to update it yourself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm working here (#3398) on updating the client. It is trickier then I thought. But as soon as this is merged you can rebase on top and you should not have to think about the vendor update part.
@@ -31,7 +32,26 @@ func eventMapping(cont *dc.APIContainers) common.MapStr { | |||
"status": cont.Status, | |||
} | |||
|
|||
// Check id container have health metrics configured | |||
if strings.Contains(cont.Status, "(") && strings.Contains(cont.Status, ")") { | |||
container, _ := m.dockerClient.InspectContainer(cont.ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could just introduce a configuration option as mentioned above with container.health: false
by default. Alternatively we can make it an additional metricset. I like the idea of a separate metricset and we can still merge it into container later if needed. 👍
For glide I will remove first version of fsouza package.
But I'm thinkin, I cannot add additionnal metricset for healthcheck because
not all container are healthcheck enabled, So we will have empty message
for container without health.
Maybe I could add an option for container metricset.
Regards.
2017-01-17 10:33 GMT+01:00 Nicolas Ruflin <[email protected]>:
… ***@***.**** commented on this pull request.
See comments. Please make sure to run make update and make fmt before
pushing the changes, as otherwise CI will fail.
------------------------------
In metricbeat/module/docker/glide.yaml
<#3357 (review)>:
> @@ -2,3 +2,6 @@ package: github.com/elastic/beats/metricbeat/module/docker
import:
- package: github.com/fsouza/go-dockerclient
version: 23c589186c2a92a8742da55f19aec4997dae5cbb
+import:
docker client is already mentioned above. You must update the version and
overwrite all files from the client with the new commit id to make sure the
full client is updated.
------------------------------
In metricbeat/module/docker/container/data.go
<#3357 (review)>:
> @@ -31,7 +32,26 @@ func eventMapping(cont *dc.APIContainers) common.MapStr {
"status": cont.Status,
}
+// Check id container have health metrics configured
+if strings.Contains(cont.Status, "(") && strings.Contains(cont.Status, ")") {
+ container, _ := m.dockerClient.InspectContainer(cont.ID)
We could just introduce a configuration option as mentioned above with container.health:
false by default. Alternatively we can make it an additional metricset. I
like the idea of a separate metricset and we can still merge it into
container later if needed. 👍
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3357 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AERS15uiH_4yo95L-PsahxeY96yO6qDAks5rTIr6gaJpZM4Lh7yl>
.
|
Hi,
It should be ok now, I add "container.healthcheck: disabled" parameter in
metricbeat.full.yml set at disabled by default.
regards.
2017-01-17 15:23 GMT+01:00 sebastien musso <[email protected]>:
… For glide I will remove first version of fsouza package.
But I'm thinkin, I cannot add additionnal metricset for healthcheck
because not all container are healthcheck enabled, So we will have empty
message for container without health.
Maybe I could add an option for container metricset.
Regards.
2017-01-17 10:33 GMT+01:00 Nicolas Ruflin ***@***.***>:
> ***@***.**** commented on this pull request.
>
> See comments. Please make sure to run make update and make fmt before
> pushing the changes, as otherwise CI will fail.
> ------------------------------
>
> In metricbeat/module/docker/glide.yaml
> <#3357 (review)>:
>
> > @@ -2,3 +2,6 @@ package: github.com/elastic/beats/metricbeat/module/docker
> import:
> - package: github.com/fsouza/go-dockerclient
> version: 23c589186c2a92a8742da55f19aec4997dae5cbb
> +import:
>
> docker client is already mentioned above. You must update the version and
> overwrite all files from the client with the new commit id to make sure the
> full client is updated.
> ------------------------------
>
> In metricbeat/module/docker/container/data.go
> <#3357 (review)>:
>
> > @@ -31,7 +32,26 @@ func eventMapping(cont *dc.APIContainers) common.MapStr {
> "status": cont.Status,
> }
>
> +// Check id container have health metrics configured
> +if strings.Contains(cont.Status, "(") && strings.Contains(cont.Status, ")") {
> + container, _ := m.dockerClient.InspectContainer(cont.ID)
>
> We could just introduce a configuration option as mentioned above with container.health:
> false by default. Alternatively we can make it an additional metricset.
> I like the idea of a separate metricset and we can still merge it into
> container later if needed. 👍
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#3357 (review)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AERS15uiH_4yo95L-PsahxeY96yO6qDAks5rTIr6gaJpZM4Lh7yl>
> .
>
|
If there is no health metrics for a container, no event should be sent. So a metricset should work quite well. Also it will be very similar to what we have now. Most docker metricsets add the container info to their data structure as you can see here: https://github.com/elastic/beats/blob/master/metricbeat/module/docker/cpu/data.go#L19 So health will also contain the container info too. Let me know if I can help further with this PR. |
Great, thanks for your work.
Does the last commit concerning healthcheck option in container metricset
is OK for you or should I rollback my code ?
Le 18 janv. 2017 13:11, "Nicolas Ruflin" <[email protected]> a
écrit :
*@ruflin* commented on this pull request.
------------------------------
In metricbeat/module/docker/glide.yaml
<#3357>:
@@ -2,3 +2,6 @@ package: github.com/elastic/beats/metricbeat/module/docker
import:
- package: github.com/fsouza/go-dockerclient
version: 23c589186c2a92a8742da55f19aec4997dae5cbb
+import:
I'm working here (#3398 <#3398>) on
updating the client. It is trickier then I thought. But as soon as this is
merged you can rebase on top and you should not have to think about the
vendor update part.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3357>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AERS13fGzf3BulF9_2zJfIGNmCHxfdEtks5rTgFVgaJpZM4Lh7yl>
.
|
@sebastienmusso I would really appreciate if we could make it a metricset instead of part of the container metricset if that is ok for you. |
ok no problem
2017-01-18 13:21 GMT+01:00 Nicolas Ruflin <[email protected]>:
… @sebastienmusso <https://github.com/sebastienmusso> I would really
appreciate if we could make it a metricset instead of part of the container
metricset if that is ok for you.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3357 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AERS14ULPlDmOePxKSx87thZEo82IGMHks5rTgO5gaJpZM4Lh7yl>
.
|
@sebastienmusso #3398 was merged. You should be able to rebase on top of master and not require any change to the dependencies (fingers crossed). |
bae5bac
to
cd0cebc
Compare
@sebastienmusso Did you rebase / merge master? Because your dependencies should now not be needed anymore. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making it a metricset. I left some minor feedback.
@@ -1,4 +1,12 @@ | |||
package: github.com/elastic/beats/metricbeat/module/docker | |||
import: | |||
- package: github.com/fsouza/go-dockerclient | |||
version: 23c589186c2a92a8742da55f19aec4997dae5cbb | |||
version: e085edda407c05214cc6e71e4881de47667e77ec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No changes should be needed here anymore.
package healthcheck | ||
|
||
import ( | ||
//"time" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line can be removed.
for _, container := range containersList { | ||
returnevent := eventMapping(&container, m) | ||
// Compare event to empty event | ||
if !reflect.DeepEqual(emptyEvent, returnevent) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eventMapping should just return nil if there is no event.
}, | ||
"status": container.State.Health.Status, | ||
"failingstreak": container.State.Health.FailingStreak, | ||
"event_start_date": common.Time(container.State.Health.Log[last_event].Start), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should map all event data under event.start_date, event.exit_code
etc.
@@ -1,5 +1,5 @@ | |||
#- module: docker | |||
#metricsets: ["cpu", "info", "memory", "network", "diskio", "container"] | |||
#metricsets: ["cpu", "info", "memory", "network", "diskio", "container", "healthcheck"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should sort this alphabetically (not introduce by you).
Hi,
For the glide file I just copied the content of the master one.
I have some issue with the eventMapping return, it seems that even if I
return a nil value, the document is still sent to elasticsearch with only
generic field like below :
"_source": {
"@timestamp": "2017-01-20T13:07:33.965Z",
"beat": {
"hostname": "smusso-ThinkPad",
"name": "smusso-ThinkPad",
"version": "6.0.0-alpha1"
},
"docker": {
"healthcheck": {}
},
"metricset": {
"host": "/var/run/docker.sock",
"module": "docker",
"name": "healthcheck",
"rtt": 6214
},
"type": "metricsets"
}
I have to remove the empty event in the myEvents map.
2017-01-20 13:40 GMT+01:00 Nicolas Ruflin <[email protected]>:
… ***@***.**** commented on this pull request.
Thanks for making it a metricset. I left some minor feedback.
------------------------------
In metricbeat/module/docker/glide.yaml
<#3357 (review)>:
> @@ -1,4 +1,12 @@
package: github.com/elastic/beats/metricbeat/module/docker
import:
- package: github.com/fsouza/go-dockerclient
- version: 23c589186c2a92a8742da55f19aec4997dae5cbb
+ version: e085edda407c05214cc6e71e4881de47667e77ec
No changes should be needed here anymore.
------------------------------
In metricbeat/module/docker/healthcheck/data.go
<#3357 (review)>:
> @@ -0,0 +1,54 @@
+package healthcheck
+
+import (
+ //"time"
This line can be removed.
------------------------------
In metricbeat/module/docker/healthcheck/data.go
<#3357 (review)>:
> + "github.com/elastic/beats/metricbeat/mb"
+ "github.com/elastic/beats/metricbeat/module/docker"
+
+ dc "github.com/fsouza/go-dockerclient"
+ "reflect"
+ "strings"
+)
+
+func eventsMapping(containersList []dc.APIContainers, m *MetricSet) []common.MapStr {
+ myEvents := []common.MapStr{}
+ // Set an empty map in order to detect empty healthcheck event
+ emptyEvent := common.MapStr{}
+ for _, container := range containersList {
+ returnevent := eventMapping(&container, m)
+ // Compare event to empty event
+ if !reflect.DeepEqual(emptyEvent, returnevent) {
eventMapping should just return nil if there is no event.
------------------------------
In metricbeat/module/docker/healthcheck/data.go
<#3357 (review)>:
> + event := common.MapStr{}
+ // Detect if healthcheck is available for container
+ if strings.Contains(cont.Status, "(") && strings.Contains(cont.Status, ")") {
+ container, _ := m.dockerClient.InspectContainer(cont.ID)
+ last_event := len(container.State.Health.Log) - 1
+ // Detect if an healthcheck already occured
+ if last_event >= 0 {
+ event = common.MapStr{
+ mb.ModuleData: common.MapStr{
+ "container": common.MapStr{
+ "name": docker.ExtractContainerName(cont.Names),
+ },
+ },
+ "status": container.State.Health.Status,
+ "failingstreak": container.State.Health.FailingStreak,
+ "event_start_date": common.Time(container.State.Health.Log[last_event].Start),
We should map all event data under event.start_date, event.exit_code etc.
------------------------------
In metricbeat/module/docker/_meta/config.yml
<#3357 (review)>:
> @@ -1,5 +1,5 @@
#- module: docker
- #metricsets: ["cpu", "info", "memory", "network", "diskio", "container"]
+ #metricsets: ["cpu", "info", "memory", "network", "diskio", "container", "healthcheck"]
We should sort this alphabetically (not introduce by you).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3357 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AERS1zWt2vBJkRZEEfL9Kut7zZ9AvQlDks5rUKsngaJpZM4Lh7yl>
.
|
You still need to check for nil, but compare it to nil instead of an empty common.MapStr in your code. Strangely it shows up in the diffs. Did you merge in master or did you rebase? Or just copy over? |
…, compare eventMapping to nil
I push all modifications, concerning the glide.yml, I just copied it over.
regards.
2017-01-20 14:42 GMT+01:00 Nicolas Ruflin <[email protected]>:
… You still need to check for nil, but compare it to nil instead of an empty
common.MapStr in your code.
Strangely it shows up in the diffs. Did you merge in master or did you
rebase? Or just copy over?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3357 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AERS19V2awIGVu_XcO3VHTkk9-iyXNL6ks5rULnEgaJpZM4Lh7yl>
.
|
Can you please rebase on top of master and remove all the changes to glide.yaml and the addition of the dependencies? As these should not change anymore in this PR. Merging in master should also work if you prefer merging. But for the files which should not be there, use |
…, compare eventMapping to nil
rebase on top of master done.
regards.
2017-01-20 15:49 GMT+01:00 Nicolas Ruflin <[email protected]>:
… Can you please rebase on top of master and remove all the changes to
glide.yaml and the addition of the dependencies? As these should not change
anymore in this PR. Merging in master should also work if you prefer
merging. But for the files which should not be there, use git checkout
master .../file.name to reset it to master.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3357 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AERS13ji0J42T_DiNw8cQduSjirqWwnxks5rUMltgaJpZM4Lh7yl>
.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some minor comments. All looks good. I'm ok merging it as soon as the two vendor files are readded and doing afterwards some cleanup PR's.
"healthcheck": { | ||
"failingstreak": 0, | ||
"status": "healthy", | ||
"healthcheck": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have an additional layer here?
@@ -1,128 +0,0 @@ | |||
// Copyright 2016 go-dockerclient authors. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should not be removed.
@@ -1,157 +0,0 @@ | |||
// Copyright 2016 go-dockerclient authors. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should not be removed.
event = common.MapStr{ | ||
mb.ModuleData: common.MapStr{ | ||
"container": common.MapStr{ | ||
"name": docker.ExtractContainerName(cont.Names), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a possibility that we use the same semantics as we have in other docker metricsets to add the full container info?
for _, container := range containersList { | ||
returnevent := eventMapping(&container, m) | ||
// Compare event to empty event | ||
if !reflect.ValueOf(returnevent).IsNil() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should be able to just do returnevent != nil
here instead of using reflect package.
Hi,
Done in the last push.
regards.
2017-01-23 13:14 GMT+01:00 Nicolas Ruflin <[email protected]>:
… ***@***.**** commented on this pull request.
------------------------------
In metricbeat/module/docker/healthcheck/data.go
<#3357 (review)>:
> +import (
+ "github.com/elastic/beats/libbeat/common"
+ "github.com/elastic/beats/metricbeat/mb"
+ "github.com/elastic/beats/metricbeat/module/docker"
+
+ dc "github.com/fsouza/go-dockerclient"
+ "reflect"
+ "strings"
+)
+
+func eventsMapping(containersList []dc.APIContainers, m *MetricSet) []common.MapStr {
+ myEvents := []common.MapStr{}
+ for _, container := range containersList {
+ returnevent := eventMapping(&container, m)
+ // Compare event to empty event
+ if !reflect.ValueOf(returnevent).IsNil() {
You should be able to just do returnevent != nil here instead of using
reflect package.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3357 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AERS1xhey-v6Nqo16Yvvbhpk6Dv_ky-fks5rVJmRgaJpZM4Lh7yl>
.
|
Hi,
I fixed the first three point.
Concerning to common way to get full container info, they are already
available in the cont variable define by the "API.Containers" others
metricsets have in input of eventMapping a structure containing Container
information. I didn't want to rewrite fsouza libs to add another structure
in API.Containers one.
regards
2017-01-23 12:24 GMT+01:00 Nicolas Ruflin <[email protected]>:
… ***@***.**** commented on this pull request.
I left some minor comments. All looks good. I'm ok merging it as soon as
the two vendor files are readded and doing afterwards some cleanup PR's.
------------------------------
In metricbeat/module/docker/healthcheck/_meta/data.json
<#3357 (review)>:
> @@ -0,0 +1,28 @@
+{
+ ***@***.***": "2016-05-23T08:05:34.853Z",
+ "beat": {
+ "hostname": "host.example.com",
+ "name": "host.example.com"
+ },
+ "docker": {
+ "healthcheck": {
+ "failingstreak": 0,
+ "status": "healthy",
+ "healthcheck": {
Why do we have an additional layer here?
------------------------------
In metricbeat/module/docker/vendor/github.com/fsouza/go-
dockerclient/node.go
<#3357 (review)>:
> @@ -1,128 +0,0 @@
-// Copyright 2016 go-dockerclient authors. All rights reserved.
This file should not be removed.
------------------------------
In metricbeat/module/docker/vendor/github.com/fsouza/go-
dockerclient/service.go
<#3357 (review)>:
> @@ -1,157 +0,0 @@
-// Copyright 2016 go-dockerclient authors. All rights reserved.
This file should not be removed.
------------------------------
In metricbeat/module/docker/healthcheck/data.go
<#3357 (review)>:
> + }
+ return myEvents
+}
+
+func eventMapping(cont *dc.APIContainers, m *MetricSet) common.MapStr {
+ event := common.MapStr{}
+ // Detect if healthcheck is available for container
+ if strings.Contains(cont.Status, "(") && strings.Contains(cont.Status, ")") {
+ container, _ := m.dockerClient.InspectContainer(cont.ID)
+ last_event := len(container.State.Health.Log) - 1
+ // Detect if an healthcheck already occured
+ if last_event >= 0 {
+ event = common.MapStr{
+ mb.ModuleData: common.MapStr{
+ "container": common.MapStr{
+ "name": docker.ExtractContainerName(cont.Names),
Is there a possibility that we use the same semantics as we have in other
docker metricsets to add the full container info?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3357 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AERS17PjJJyKe_POJlyi1lOBvyU8CWloks5rVI3fgaJpZM4Lh7yl>
.
|
@sebastienmusso Thanks a lot for your contribution. I merged it as it is. We can think in the future about how we add all container meta data to the event when we replace the fsouza library. Let me know if I can help you somehow with the swarm module. I would recommend to build the swarm module if possible directly based on the official docker client. |
Here is the follow up PR: #3463 |
Simple health check information on container document.
docker.container.health.event_end_date ## last healthcheck execution end
docker.container.health.event_exit_code ## last healthcheck exit code
docker.container.health.event_output ## last healthcheck string output
docker.container.health.event_start_date ## last healthcheck execution start
docker.container.health.failingstreak ## concurent failed healthcheck execution
docker.container.health.status ## healthcheck status
I had Struct mannualy into container.go of fsouza/go-dockerclient.
This could be interresting for simple application monitoring and autoscalling