From fab03dcada0923b9d7b61ac8a33729671391ffa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20P=C3=A9rez-Aradros=20Herce?= Date: Thu, 15 Jun 2017 04:50:01 +0200 Subject: [PATCH] Rename `kubernetes` processor -> `add_kubernetes_metadata` (#4473) * Rename `kubernetes` processor -> `add_kubernetes_metadata` * Update CHANGELOG --- CHANGELOG.asciidoc | 2 ++ filebeat/beater/filebeat.go | 2 +- .../indexing.go | 12 +++++----- .../indexing_test.go | 2 +- libbeat/beat/beat.go | 2 +- libbeat/docs/processors-using.asciidoc | 17 +++++++------- .../_meta/fields.yml | 0 .../config.go | 2 +- .../indexing.go | 2 +- .../indexing_test.go | 2 +- .../kubernetes.go | 6 ++--- .../podwatcher.go | 2 +- .../registry.go | 2 +- .../types.go | 2 +- metricbeat/beater/metricbeat.go | 2 +- .../indexing.go | 4 ++-- .../indexing_test.go | 23 ++++++++++--------- 17 files changed, 44 insertions(+), 40 deletions(-) rename filebeat/processor/{kubernetes => add_kubernetes_metadata}/indexing.go (72%) rename filebeat/processor/{kubernetes => add_kubernetes_metadata}/indexing_test.go (95%) rename libbeat/processors/{kubernetes => add_kubernetes_metadata}/_meta/fields.yml (100%) rename libbeat/processors/{kubernetes => add_kubernetes_metadata}/config.go (97%) rename libbeat/processors/{kubernetes => add_kubernetes_metadata}/indexing.go (99%) rename libbeat/processors/{kubernetes => add_kubernetes_metadata}/indexing_test.go (99%) rename libbeat/processors/{kubernetes => add_kubernetes_metadata}/kubernetes.go (96%) rename libbeat/processors/{kubernetes => add_kubernetes_metadata}/podwatcher.go (99%) rename libbeat/processors/{kubernetes => add_kubernetes_metadata}/registry.go (97%) rename libbeat/processors/{kubernetes => add_kubernetes_metadata}/types.go (99%) rename metricbeat/processor/{kubernetes => add_kubernetes_metadata}/indexing.go (95%) rename metricbeat/processor/{kubernetes => add_kubernetes_metadata}/indexing_test.go (72%) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 1baa4e5b0592..37ad0fbf2916 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -14,6 +14,8 @@ https://github.com/elastic/beats/compare/v6.0.0-alpha1...master[Check the HEAD d *Affecting all Beats* +- Rename `kubernetes` processor to `add_kubernetes_metadata`. {pull}4473[4473] + *Filebeat* *Heartbeat* diff --git a/filebeat/beater/filebeat.go b/filebeat/beater/filebeat.go index 261be8d5572a..8228bca926ad 100644 --- a/filebeat/beater/filebeat.go +++ b/filebeat/beater/filebeat.go @@ -20,7 +20,7 @@ import ( "github.com/elastic/beats/filebeat/spooler" // Add filebeat level processors - _ "github.com/elastic/beats/filebeat/processor/kubernetes" + _ "github.com/elastic/beats/filebeat/processor/add_kubernetes_metadata" ) var ( diff --git a/filebeat/processor/kubernetes/indexing.go b/filebeat/processor/add_kubernetes_metadata/indexing.go similarity index 72% rename from filebeat/processor/kubernetes/indexing.go rename to filebeat/processor/add_kubernetes_metadata/indexing.go index 9531e36fa7e0..06b580df02e0 100644 --- a/filebeat/processor/kubernetes/indexing.go +++ b/filebeat/processor/add_kubernetes_metadata/indexing.go @@ -1,4 +1,4 @@ -package kubernetes +package add_kubernetes_metadata import ( "fmt" @@ -6,18 +6,18 @@ import ( "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" @@ -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"` }{ diff --git a/filebeat/processor/kubernetes/indexing_test.go b/filebeat/processor/add_kubernetes_metadata/indexing_test.go similarity index 95% rename from filebeat/processor/kubernetes/indexing_test.go rename to filebeat/processor/add_kubernetes_metadata/indexing_test.go index 5ba98056d59e..74c40fc967a3 100644 --- a/filebeat/processor/kubernetes/indexing_test.go +++ b/filebeat/processor/add_kubernetes_metadata/indexing_test.go @@ -1,4 +1,4 @@ -package kubernetes +package add_kubernetes_metadata import ( "fmt" diff --git a/libbeat/beat/beat.go b/libbeat/beat/beat.go index a705a19be744..4a854ec4089c 100644 --- a/libbeat/beat/beat.go +++ b/libbeat/beat/beat.go @@ -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" diff --git a/libbeat/docs/processors-using.asciidoc b/libbeat/docs/processors-using.asciidoc index a3447e2c7dc7..405e3453b3a6 100644 --- a/libbeat/docs/processors-using.asciidoc +++ b/libbeat/docs/processors-using.asciidoc @@ -43,7 +43,7 @@ The supported processors are: * <> * <> * <> - * <> + * <> * <> [[conditions]] @@ -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 @@ -526,7 +527,7 @@ Kubernetes. [source,yaml] ------------------------------------------------------------------------------- processors: -- kubernetes: +- add_kubernetes_metadata: in_cluster: true ------------------------------------------------------------------------------- @@ -536,7 +537,7 @@ the Kubernetes node. [source,yaml] ------------------------------------------------------------------------------- processors: -- kubernetes: +- add_kubernetes_metadata: in_cluster: false host: kube_config: ${HOME}/.kube/config @@ -548,7 +549,7 @@ enables ones that the user is interested in. [source,yaml] ------------------------------------------------------------------------------- processors: -- kubernetes: +- add_kubernetes_metadata: in_cluster: false host: kube_config: ~/.kube/config diff --git a/libbeat/processors/kubernetes/_meta/fields.yml b/libbeat/processors/add_kubernetes_metadata/_meta/fields.yml similarity index 100% rename from libbeat/processors/kubernetes/_meta/fields.yml rename to libbeat/processors/add_kubernetes_metadata/_meta/fields.yml diff --git a/libbeat/processors/kubernetes/config.go b/libbeat/processors/add_kubernetes_metadata/config.go similarity index 97% rename from libbeat/processors/kubernetes/config.go rename to libbeat/processors/add_kubernetes_metadata/config.go index 01fbc5a1bb71..6d53f63a0782 100644 --- a/libbeat/processors/kubernetes/config.go +++ b/libbeat/processors/add_kubernetes_metadata/config.go @@ -1,4 +1,4 @@ -package kubernetes +package add_kubernetes_metadata import ( "time" diff --git a/libbeat/processors/kubernetes/indexing.go b/libbeat/processors/add_kubernetes_metadata/indexing.go similarity index 99% rename from libbeat/processors/kubernetes/indexing.go rename to libbeat/processors/add_kubernetes_metadata/indexing.go index 453a62c75bc2..925ad9bbe248 100644 --- a/libbeat/processors/kubernetes/indexing.go +++ b/libbeat/processors/add_kubernetes_metadata/indexing.go @@ -1,4 +1,4 @@ -package kubernetes +package add_kubernetes_metadata import ( "fmt" diff --git a/libbeat/processors/kubernetes/indexing_test.go b/libbeat/processors/add_kubernetes_metadata/indexing_test.go similarity index 99% rename from libbeat/processors/kubernetes/indexing_test.go rename to libbeat/processors/add_kubernetes_metadata/indexing_test.go index faf1331ea8a8..1c70f10a3cd6 100644 --- a/libbeat/processors/kubernetes/indexing_test.go +++ b/libbeat/processors/add_kubernetes_metadata/indexing_test.go @@ -1,4 +1,4 @@ -package kubernetes +package add_kubernetes_metadata import ( "testing" diff --git a/libbeat/processors/kubernetes/kubernetes.go b/libbeat/processors/add_kubernetes_metadata/kubernetes.go similarity index 96% rename from libbeat/processors/kubernetes/kubernetes.go rename to libbeat/processors/add_kubernetes_metadata/kubernetes.go index 76892adf08fd..1c6331cf01b7 100644 --- a/libbeat/processors/kubernetes/kubernetes.go +++ b/libbeat/processors/add_kubernetes_metadata/kubernetes.go @@ -1,4 +1,4 @@ -package kubernetes +package add_kubernetes_metadata import ( "context" @@ -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) @@ -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 == "" { diff --git a/libbeat/processors/kubernetes/podwatcher.go b/libbeat/processors/add_kubernetes_metadata/podwatcher.go similarity index 99% rename from libbeat/processors/kubernetes/podwatcher.go rename to libbeat/processors/add_kubernetes_metadata/podwatcher.go index f9869bfaff3d..b222eecbdb00 100644 --- a/libbeat/processors/kubernetes/podwatcher.go +++ b/libbeat/processors/add_kubernetes_metadata/podwatcher.go @@ -1,4 +1,4 @@ -package kubernetes +package add_kubernetes_metadata import ( "context" diff --git a/libbeat/processors/kubernetes/registry.go b/libbeat/processors/add_kubernetes_metadata/registry.go similarity index 97% rename from libbeat/processors/kubernetes/registry.go rename to libbeat/processors/add_kubernetes_metadata/registry.go index 463db4eb9102..8ed886cab7cf 100644 --- a/libbeat/processors/kubernetes/registry.go +++ b/libbeat/processors/add_kubernetes_metadata/registry.go @@ -1,4 +1,4 @@ -package kubernetes +package add_kubernetes_metadata import ( "errors" diff --git a/libbeat/processors/kubernetes/types.go b/libbeat/processors/add_kubernetes_metadata/types.go similarity index 99% rename from libbeat/processors/kubernetes/types.go rename to libbeat/processors/add_kubernetes_metadata/types.go index d83194dc25ac..d3bec7c7cfab 100644 --- a/libbeat/processors/kubernetes/types.go +++ b/libbeat/processors/add_kubernetes_metadata/types.go @@ -1,4 +1,4 @@ -package kubernetes +package add_kubernetes_metadata type ObjectMeta struct { Annotations map[string]string `json:"annotations"` diff --git a/metricbeat/beater/metricbeat.go b/metricbeat/beater/metricbeat.go index e1dd812de6cc..6bc4d2750928 100644 --- a/metricbeat/beater/metricbeat.go +++ b/metricbeat/beater/metricbeat.go @@ -14,7 +14,7 @@ import ( "github.com/pkg/errors" // Add metricbeat specific processors - _ "github.com/elastic/beats/metricbeat/processor/kubernetes" + _ "github.com/elastic/beats/metricbeat/processor/add_kubernetes_metadata" ) // Metricbeat implements the Beater interface for metricbeat. diff --git a/metricbeat/processor/kubernetes/indexing.go b/metricbeat/processor/add_kubernetes_metadata/indexing.go similarity index 95% rename from metricbeat/processor/kubernetes/indexing.go rename to metricbeat/processor/add_kubernetes_metadata/indexing.go index 462bdffce687..f896d14a6c2f 100644 --- a/metricbeat/processor/kubernetes/indexing.go +++ b/metricbeat/processor/add_kubernetes_metadata/indexing.go @@ -1,11 +1,11 @@ -package kubernetes +package add_kubernetes_metadata import ( "fmt" "strings" "github.com/elastic/beats/libbeat/common" - "github.com/elastic/beats/libbeat/processors/kubernetes" + kubernetes "github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata" ) const ( diff --git a/metricbeat/processor/kubernetes/indexing_test.go b/metricbeat/processor/add_kubernetes_metadata/indexing_test.go similarity index 72% rename from metricbeat/processor/kubernetes/indexing_test.go rename to metricbeat/processor/add_kubernetes_metadata/indexing_test.go index 4dcd740c483c..86e6003b9c1f 100644 --- a/metricbeat/processor/kubernetes/indexing_test.go +++ b/metricbeat/processor/add_kubernetes_metadata/indexing_test.go @@ -1,15 +1,16 @@ -package kubernetes +package add_kubernetes_metadata import ( "fmt" "testing" - "github.com/elastic/beats/libbeat/common" - "github.com/elastic/beats/libbeat/processors/kubernetes" "github.com/stretchr/testify/assert" + + "github.com/elastic/beats/libbeat/common" + "github.com/elastic/beats/libbeat/processors/add_kubernetes_metadata" ) -var metagen = &kubernetes.GenDefaultMeta{} +var metagen = &add_kubernetes_metadata.GenDefaultMeta{} func TestIpPortIndexer(t *testing.T) { var testConfig = common.NewConfig() @@ -22,19 +23,19 @@ func TestIpPortIndexer(t *testing.T) { container := "container" ip := "1.2.3.4" port := int64(80) - pod := kubernetes.Pod{ - Metadata: kubernetes.ObjectMeta{ + pod := add_kubernetes_metadata.Pod{ + Metadata: add_kubernetes_metadata.ObjectMeta{ Name: podName, Namespace: ns, Labels: map[string]string{ "labelkey": "labelvalue", }, }, - Spec: kubernetes.PodSpec{ - Containers: make([]kubernetes.Container, 0), + Spec: add_kubernetes_metadata.PodSpec{ + Containers: make([]add_kubernetes_metadata.Container, 0), }, - Status: kubernetes.PodStatus{ + Status: add_kubernetes_metadata.PodStatus{ PodIP: ip, }, } @@ -53,10 +54,10 @@ func TestIpPortIndexer(t *testing.T) { }, } - pod.Spec.Containers = []kubernetes.Container{ + pod.Spec.Containers = []add_kubernetes_metadata.Container{ { Name: container, - Ports: []kubernetes.ContainerPort{ + Ports: []add_kubernetes_metadata.ContainerPort{ { Name: container, ContainerPort: port,