-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
48c52a9
Add health to standalone container
cef2bc8
Add node metricset
0168682
Add node module for docker metricset
8f0ed13
Fix docker dependency issue
bebac8f
Add docker service metricset
1009222
Fix service index mapping and add comment
b95e76a
add healthcheck metricset in docker module
cd0cebc
add healthcheck metricset in docker module
3d743aa
delete old fsouza lib (node.go and service.go)
2e29629
Set metricbeat.full.yml to default value
6ff4edf
Fix shell in metricbeat.full.yml
2e9ab40
Last commit, add comment
d8e7256
set metricset list in alphabetical order, remap event healtcheck data…
2e8d78e
Add health to standalone container
3e83526
Rebase on top of elastic/beats:master
619b19f
Add node module for docker metricset
76bb65a
Fix docker dependency issue
b604279
Add docker service metricset
4a8e710
Fix service index mapping and add comment
daeba37
add healthcheck metricset in docker module
61273fc
add healthcheck metricset in docker module
3391a69
Set metricbeat.full.yml to default value
09aa8c8
Fix shell in metricbeat.full.yml
b14b290
Last commit, add comment
fc031d8
set metricset list in alphabetical order, remap event healtcheck data…
8a2e17b
Merge branch 'master' of https://github.com/Treeptik/beats
0be7340
Delete external libs folder
ffceff3
fix healtheck layer, add node.go and service.go, compare event to nil
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//// | ||
This file is generated! See scripts/docs_collector.py | ||
//// | ||
|
||
[[metricbeat-metricset-docker-healthcheck]] | ||
include::../../../module/docker/healthcheck/_meta/docs.asciidoc[] | ||
|
||
|
||
==== Fields | ||
|
||
For a description of each field in the metricset, see the | ||
<<exported-fields-docker,exported fields>> section. | ||
|
||
Here is an example document generated by this metricset: | ||
|
||
[source,json] | ||
---- | ||
include::../../../module/docker/healthcheck/_meta/data.json[] | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,4 @@ | |
"rtt": 115 | ||
}, | ||
"type": "metricsets" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"@timestamp": "2016-05-23T08:05:34.853Z", | ||
"beat": { | ||
"hostname": "host.example.com", | ||
"name": "host.example.com" | ||
}, | ||
"docker": { | ||
"healthcheck": { | ||
"failingstreak": 0, | ||
"status": "healthy", | ||
"event": { | ||
"end_date": "2017-01-09T20:38:13.080472813+01:00", | ||
"exit_code": 0, | ||
"output": "this is an event output", | ||
"start_date": "2017-01-09T20:38:12.999970865+01:00", | ||
} | ||
} | ||
}, | ||
"metricset": { | ||
"host": "/var/run/docker.sock", | ||
"module": "docker", | ||
"name": "container", | ||
"rtt": 115 | ||
}, | ||
"type": "metricsets" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
=== Docker healthcheck Metricset | ||
|
||
The Docker `healthcheck` metricset collects information and statistics about | ||
running Docker containers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
- name: healthcheck | ||
type: group | ||
description: > | ||
Docker container metrics. | ||
fields: | ||
- name: failingstreak | ||
type: integer | ||
description: > | ||
concurent failed check | ||
- name: status | ||
type: keyword | ||
description: > | ||
Healthcheck status code | ||
- name: event | ||
type: group | ||
description: > | ||
event fields. | ||
fields: | ||
- name: end_date | ||
type: date | ||
description: > | ||
Healthcheck end date | ||
- name: start_date | ||
type: date | ||
description: > | ||
Healthcheck start date | ||
- name: output | ||
type: keyword | ||
description: > | ||
Healthcheck output | ||
- name: exit_code | ||
type: integer | ||
description: > | ||
Healthcheck status code |
25 changes: 25 additions & 0 deletions
25
metricbeat/module/docker/healthcheck/container_integration_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// +build integration | ||
|
||
package healthcheck | ||
|
||
import ( | ||
"testing" | ||
|
||
mbtest "github.com/elastic/beats/metricbeat/mb/testing" | ||
) | ||
|
||
func TestData(t *testing.T) { | ||
f := mbtest.NewEventsFetcher(t, getConfig()) | ||
err := mbtest.WriteEvents(f, t) | ||
if err != nil { | ||
t.Fatal("write", err) | ||
} | ||
} | ||
|
||
func getConfig() map[string]interface{} { | ||
return map[string]interface{}{ | ||
"module": "docker", | ||
"metricsets": []string{"healthcheck"}, | ||
"hosts": []string{"unix:///var/run/docker.sock"}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package healthcheck | ||
|
||
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" | ||
"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 returnevent != nil { | ||
myEvents = append(myEvents, returnevent) | ||
} | ||
} | ||
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), | ||
"id": cont.ID, | ||
}, | ||
}, | ||
"status": container.State.Health.Status, | ||
"failingstreak": container.State.Health.FailingStreak, | ||
"event": common.MapStr{ | ||
"start_date": common.Time(container.State.Health.Log[last_event].Start), | ||
"end_date": common.Time(container.State.Health.Log[last_event].End), | ||
"exit_code": container.State.Health.Log[last_event].ExitCode, | ||
"output": container.State.Health.Log[last_event].Output, | ||
}, | ||
} | ||
return event | ||
} | ||
} | ||
return nil | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?