Skip to content

Commit

Permalink
Add kubernetes autodiscover docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vjsamuel committed Jan 15, 2018
1 parent fa6a2e1 commit fdca86b
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
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`.

0 comments on commit fdca86b

Please sign in to comment.