Skip to content

Commit

Permalink
Rename kubernetes processor -> add_kubernetes_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
exekias committed Jun 8, 2017
1 parent 8ba93a7 commit a86d05f
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package kubernetes
package add_kubernetes_metadata

import (
"fmt"
"strings"

"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/logp"
"github.com/elastic/beats/libbeat/processors/kubernetes"
"github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata"
)

func init() {
kubernetes.Indexing.AddMatcher(LogPathMatcherName, newLogsPathMatcher)
add_kubernetes_metadata.Indexing.AddMatcher(LogPathMatcherName, newLogsPathMatcher)
cfg := common.NewConfig()

//Add a container indexer config by default.
kubernetes.Indexing.AddDefaultIndexerConfig(kubernetes.ContainerIndexerName, *cfg)
add_kubernetes_metadata.Indexing.AddDefaultIndexerConfig(add_kubernetes_metadata.ContainerIndexerName, *cfg)

//Add a log path matcher which can extract container ID from the "source" field.
kubernetes.Indexing.AddDefaultMatcherConfig(LogPathMatcherName, *cfg)
add_kubernetes_metadata.Indexing.AddDefaultMatcherConfig(LogPathMatcherName, *cfg)
}

const LogPathMatcherName = "logs_path"
Expand All @@ -26,7 +26,7 @@ type LogPathMatcher struct {
LogsPath string
}

func newLogsPathMatcher(cfg common.Config) (kubernetes.Matcher, error) {
func newLogsPathMatcher(cfg common.Config) (add_kubernetes_metadata.Matcher, error) {
config := struct {
LogsPath string `config:"logs_path"`
}{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kubernetes
package add_kubernetes_metadata

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion libbeat/beat/beat.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ import (
_ "github.com/elastic/beats/libbeat/processors/actions"
_ "github.com/elastic/beats/libbeat/processors/add_cloud_metadata"
_ "github.com/elastic/beats/libbeat/processors/add_docker_metadata"
_ "github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata"
_ "github.com/elastic/beats/libbeat/processors/add_locale"
_ "github.com/elastic/beats/libbeat/processors/kubernetes"

// Register default monitoring reporting
_ "github.com/elastic/beats/libbeat/monitoring/report/elasticsearch"
Expand Down
17 changes: 9 additions & 8 deletions libbeat/docs/processors-using.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The supported processors are:
* <<drop-event,`drop_event`>>
* <<drop-fields,`drop_fields`>>
* <<include-fields,`include_fields`>>
* <<kubernetes,`kubernetes`>>
* <<add-kubernetes-metadata,`add_kubernetes_metadata`>>
* <<add-docker-metadata,`add_docker_metadata`>>

[[conditions]]
Expand Down Expand Up @@ -492,17 +492,18 @@ section.
NOTE: If you define an empty list of fields under `include_fields`, then only
the required fields, `@timestamp` and `type`, are exported.

[[kubernetes]]
[[add-kubernetes-metadata]]
=== Adding Kubernetes Metadata

The `kubernetes` processor annotates each event with relevant metadata based on
which Kubernetes pod the event originated from. Each event is annotated with:
The `add_kubernetes_metadata` processor annotates each event with relevant
metadata based on which Kubernetes pod the event originated from. Each event is
annotated with:

* Pod Name
* Namespace
* Labels

The `kubernetes` processor has two basic building blocks which are:
The `add_kubernetes_metadata` processor has two basic building blocks which are:

* Indexers
* Matchers
Expand All @@ -526,7 +527,7 @@ Kubernetes.
[source,yaml]
-------------------------------------------------------------------------------
processors:
- kubernetes:
- add_kubernetes_metadata:
in_cluster: true
-------------------------------------------------------------------------------

Expand All @@ -536,7 +537,7 @@ the Kubernetes node.
[source,yaml]
-------------------------------------------------------------------------------
processors:
- kubernetes:
- add_kubernetes_metadata:
in_cluster: false
host: <hostname>
kube_config: ${HOME}/.kube/config
Expand All @@ -548,7 +549,7 @@ enables ones that the user is interested in.
[source,yaml]
-------------------------------------------------------------------------------
processors:
- kubernetes:
- add_kubernetes_metadata:
in_cluster: false
host: <hostname>
kube_config: ~/.kube/config
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kubernetes
package add_kubernetes_metadata

import (
"time"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kubernetes
package add_kubernetes_metadata

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kubernetes
package add_kubernetes_metadata

import (
"testing"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kubernetes
package add_kubernetes_metadata

import (
"context"
Expand Down Expand Up @@ -30,7 +30,7 @@ type kubernetesAnnotator struct {
}

func init() {
processors.RegisterPlugin("kubernetes", newKubernetesAnnotator)
processors.RegisterPlugin("add_kubernetes_metadata", newKubernetesAnnotator)

// Register default indexers
Indexing.AddIndexer(PodNameIndexerName, NewPodNameIndexer)
Expand Down Expand Up @@ -208,7 +208,7 @@ func (k kubernetesAnnotator) Run(event common.MapStr) (common.MapStr, error) {
return event, nil
}

func (k kubernetesAnnotator) String() string { return "kubernetes" }
func (k kubernetesAnnotator) String() string { return "add_kubernetes_metadata" }

func validate(config kubeAnnotatorConfig) error {
if !config.InCluster && config.KubeConfig == "" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kubernetes
package add_kubernetes_metadata

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kubernetes
package add_kubernetes_metadata

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kubernetes
package add_kubernetes_metadata

type ObjectMeta struct {
Annotations map[string]string `json:"annotations"`
Expand Down

0 comments on commit a86d05f

Please sign in to comment.