-
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
Metricbeat module for Traefik #7413
Merged
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
4ac476a
Init checkin
ycombinator 07afa97
Publishing uptime.sec
ycombinator 1da6229
Adding field to fields.yml; adding data.go
ycombinator 6abccaf
Fixing imports formatting
ycombinator 897f576
Adding more metrics
ycombinator 102e5e7
Adding header
ycombinator 1349b5f
Updating generated assets
ycombinator d16cec2
Updating descriptions in field.yml files
ycombinator 4d85bf2
Fleshing out doc
ycombinator 9e9d51d
Adding healthcheck
ycombinator caeee0c
Change uptime type to int (was float)
ycombinator acb87e4
Starting to add unit tests
ycombinator a0c4b10
Unit tests
ycombinator 70b00ff
Adding entry to CHANGELOG
ycombinator 56b8927
Adding integration tests
ycombinator a76b7c7
Fixing function name duplication
ycombinator fe0c7fc
Fixing health check URL in Dockerfile
ycombinator 932073d
Adding flags to unit test files for skipping them during integration …
ycombinator ff5c8a2
Adding system test file (WIP)
ycombinator 7584cf8
Fixing system test
ycombinator b67847f
Update Dockerfile
ycombinator de9c972
Use new interfaces
ycombinator fe80d57
Updating fields.go
ycombinator b027607
Fixing location of CHANGELOG entry
ycombinator 7650731
Updating data.json
ycombinator 48490e9
Using shorter syntax for describing uptime.sec field
ycombinator 8998c45
Changing datatype of average response time to microseconds
ycombinator bd131f7
Updating schema for response counts per status code
ycombinator 41ab4de
Regenerating sample ES document
ycombinator 89b99b5
Store status code counts as ints
ycombinator 2cc6ac6
Actually make a request to the proxy and then assert on its effects
ycombinator c4f6ade
Fiddling with data types
ycombinator f0ab0eb
Extract mock response into test fixture file
ycombinator 6292c7f
Moving system test file into module folder
ycombinator 03d6a9f
Simplifying using helper method
ycombinator a0b5191
Missed an import in the system test script
ycombinator d9ec2fb
Forgot to define FIELDS
ycombinator bed5d3c
Copy pasta fail :(
ycombinator 69e433a
Augmenting import path before importing metricbeat
ycombinator 2f26d10
Fixing up formatting
ycombinator 3b0ef8b
Missed an import
ycombinator 249f97f
Adding guard clause
ycombinator 072dda2
Renaming status code field
ycombinator 32a2914
Adding service.name field
ycombinator 5fb7c35
Move testing config functions into mtest package
ycombinator 51d1f37
Using MapStr.Put to crete service.name nested field
ycombinator 44d4e60
Removing unnecessary newline
ycombinator 5295345
Shortening comments
ycombinator bb54c34
Check that type assertion works
ycombinator 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,41 @@ | ||
//// | ||
This file is generated! See scripts/docs_collector.py | ||
//// | ||
|
||
[[metricbeat-module-traefik]] | ||
== traefik module | ||
|
||
experimental[] | ||
|
||
This module periodically fetches metrics from a https://traefik.io/[Traefik] | ||
instance. The Traefik instance must be configured to expose it's HTTP API. | ||
|
||
=== Compatibility | ||
|
||
The Traefik metricsets were tested with Traefik 1.6. | ||
|
||
|
||
[float] | ||
=== Example configuration | ||
|
||
The traefik module supports the standard configuration options that are described | ||
in <<configuration-metricbeat>>. Here is an example configuration: | ||
|
||
[source,yaml] | ||
---- | ||
metricbeat.modules: | ||
- module: traefik | ||
metricsets: ["health"] | ||
period: 10s | ||
hosts: ["localhost:8080"] | ||
---- | ||
|
||
[float] | ||
=== Metricsets | ||
|
||
The following metricsets are available: | ||
|
||
* <<metricbeat-metricset-traefik-health,health>> | ||
|
||
include::traefik/health.asciidoc[] | ||
|
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,23 @@ | ||
//// | ||
This file is generated! See scripts/docs_collector.py | ||
//// | ||
|
||
[[metricbeat-metricset-traefik-health]] | ||
=== traefik health metricset | ||
|
||
experimental[] | ||
|
||
include::../../../module/traefik/health/_meta/docs.asciidoc[] | ||
|
||
|
||
==== Fields | ||
|
||
For a description of each field in the metricset, see the | ||
<<exported-fields-traefik,exported fields>> section. | ||
|
||
Here is an example document generated by this metricset: | ||
|
||
[source,json] | ||
---- | ||
include::../../../module/traefik/health/_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
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,6 @@ | ||
FROM traefik:1.6-alpine | ||
|
||
COPY ./traefik.toml /etc/traefik/traefik.toml | ||
|
||
RUN apk add --no-cache curl | ||
HEALTHCHECK --interval=1s --retries=90 CMD curl -f http://localhost:8080/health |
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 @@ | ||
- module: traefik | ||
metricsets: ["health"] | ||
period: 10s | ||
hosts: ["localhost:8080"] |
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,6 @@ | ||
This module periodically fetches metrics from a https://traefik.io/[Traefik] | ||
instance. The Traefik instance must be configured to expose it's HTTP API. | ||
|
||
=== Compatibility | ||
|
||
The Traefik metricsets were tested with Traefik 1.6. |
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,2 @@ | ||
TRAEFIK_HOST=traefik | ||
TRAEFIK_API_PORT=8080 |
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,10 @@ | ||
- key: traefik | ||
title: "traefik" | ||
description: > | ||
Traefik reverse proxy / load balancer metrics | ||
fields: | ||
- name: traefik | ||
type: group | ||
description: > | ||
Traefik reverse proxy / load balancer metrics | ||
fields: |
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 @@ | ||
[api] |
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 @@ | ||
// Licensed to Elasticsearch B.V. under one or more contributor | ||
// license agreements. See the NOTICE file distributed with | ||
// this work for additional information regarding copyright | ||
// ownership. Elasticsearch B.V. licenses this file to you under | ||
// the Apache License, Version 2.0 (the "License"); you may | ||
// not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
// Package traefik is a Metricbeat module that contains MetricSets. | ||
package traefik |
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,29 @@ | ||
{ | ||
"@timestamp": "2017-10-12T08:05:34.853Z", | ||
"beat": { | ||
"hostname": "host.example.com", | ||
"name": "host.example.com" | ||
}, | ||
"metricset": { | ||
"host": "127.0.0.1:8080", | ||
"module": "traefik", | ||
"name": "health", | ||
"rtt": 115 | ||
}, | ||
"traefik": { | ||
"health": { | ||
"response": { | ||
"avg_time": { | ||
"us": 32 | ||
}, | ||
"count": 15, | ||
"status_codes": { | ||
"404": 15 | ||
} | ||
}, | ||
"uptime": { | ||
"sec": 1944 | ||
} | ||
} | ||
} | ||
} |
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,3 @@ | ||
=== traefik health MetricSet | ||
|
||
This is the health metricset of the module traefik. |
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,27 @@ | ||
- name: health | ||
type: group | ||
description: > | ||
Metrics obtained from Traefik's health API endpoint | ||
fields: | ||
- name: uptime.sec | ||
type: long | ||
description: > | ||
Uptime of Traefik instance in seconds | ||
- name: response | ||
type: group | ||
description: > | ||
Response metrics | ||
fields: | ||
- name: count | ||
type: long | ||
description: > | ||
Number of responses | ||
- name: avg_time.us | ||
type: long | ||
description: > | ||
Average response time in microseconds | ||
- name: status_code | ||
type: object | ||
object_type: long | ||
description: > | ||
Number of responses per status code |
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,18 @@ | ||
{ | ||
"pid": 1, | ||
"uptime": "17h51m23.252891567s", | ||
"uptime_sec": 64283.252891567, | ||
"time": "2018-06-27 22:07:28.966768969 +0000 UTC m=+64283.314491879", | ||
"unixtime": 1530137248, | ||
"status_code_count": {}, | ||
"total_status_code_count": { | ||
"200": 17, | ||
"404": 1 | ||
}, | ||
"count": 0, | ||
"total_count": 18, | ||
"total_response_time": "272.119µs", | ||
"total_response_time_sec": 0.000272119, | ||
"average_response_time": "15.117µs", | ||
"average_response_time_sec": 1.5117e-05 | ||
} |
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.
What is the purpose of this file? How is it used?
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 is an example output document that we should in the docs. It is generated by this command here: https://github.com/elastic/beats/blob/master/metricbeat/Makefile#L73 As this updates all data.json I normally run the following command:
In you case this assumes the traefik docker container is running and exposes the port on localhost. This will generate a data.json file and
make update
will link it in the docs.Here you can see an example in the docs: https://www.elastic.co/guide/en/beats/metricbeat/master/metricbeat-metricset-elasticsearch-index.html