Skip to content
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 kubernetes autodiscover docs #6065

Merged
merged 1 commit into from
Jan 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions filebeat/docs/autodiscover-kubernetes-config.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Filebeat supports templates for both prospectors and modules.

["source","yaml",subs="attributes"]
-------------------------------------------------------------------------------------
filebeat.autodiscover:
providers:
- type: kubernetes
templates:
- condition:
equals:
kubernetes.namespace: kube-system
config:
- type: docker
containers.ids:
- "${data.docker.container.id}"
exclude_lines: ["^\\s+[\\-`('.|_]"] # drop asciiart lines
-------------------------------------------------------------------------------------

This configuration launches a `docker` logs prospector for all containers of pods running in the Kubernetes namespace
`kube-system`.

If you are using modules, you can override the default prospector and use the docker prospector instead.

["source","yaml",subs="attributes"]
-------------------------------------------------------------------------------------
filebeat.autodiscover:
providers:
- type: kubernetes
templates:
- condition:
equals:
kubernetes.container.image: "redis"
config:
- module: redis
log:
prospector:
type: docker
containers.ids:
- "${data.docker.container.id}"
-------------------------------------------------------------------------------------
52 changes: 52 additions & 0 deletions libbeat/docs/shared-autodiscover.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,55 @@ Configuration templates can contain variables from the autodiscover event. They
For example, with the example event, "`${data.port}`" will resolves to `6379`.

include::../../{beatname_lc}/docs/autodiscover-docker-config.asciidoc[]

[float]
===== Kubernetes

Kubernetes autodiscover provider watches for Kubernetes pods start, update and stop. These are the available fields on every
event:

* host
* port
* kubernetes.container.id
* kubernetes.container.image
* kubernetes.container.name
* kubernetes.labels
* kubernetes.namespace
* kubernetes.node.name
* kubernetes.pod.name

If the `include_annotations` config is added to the provider config then the list of annotations present in the config
are added to the event.

For example:

[source,yaml]
-------------------------------------------------------------------------------------
{
"host": "172.17.0.21",
"port": 9090,
"kubernetes": {
"container": {
"id": "bb3a50625c01b16a88aa224779c39262a9ad14264c3034669a50cd9a90af1527",
"image": "prom/prometheus",
"name": "prometheus"
},
"labels": {
"project": "prometheus",
...
},
"namespace": "default",
"node": {
"name": "minikube"
},
"pod": {
"name": "prometheus-2657348378-k1pnh"
}
},
}
-------------------------------------------------------------------------------------

Configuration of templates and conditions are exactly similar as that of Docker provider. Configuration templates can
contain variables from the autodiscover event. They can be accessed under data namespace.

include::../../{beatname_lc}/docs/autodiscover-kubernetes-config.asciidoc[]
19 changes: 19 additions & 0 deletions metricbeat/docs/autodiscover-kubernetes-config.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Metricbeat supports templates for modules:

["source","yaml",subs="attributes"]
-------------------------------------------------------------------------------------
metricbeat.autodiscover:
providers:
- type: kubernetes
include_annotations: ["prometheus.io.scrape"]
templates:
- condition:
contains:
kubernetes.annotations.prometheus.io.scrape: "true"
config:
- module: prometheus
metricsets: ["collector"]
hosts: "${data.host}:{data.port}"
-------------------------------------------------------------------------------------

This configuration launches a `prometheus` module for all containers of pods annotated `prometheus.io.scrape=true`.