Skip to content

Commit

Permalink
Rename google-pubsub Filebeat input to gcp-pubsub (#22213)
Browse files Browse the repository at this point in the history
* Rename google-pubsub Filebeat input to gcp-pubsub

* change to gcp-pubsub input name in elastic-agent

* add warning log message for deprecated old input name
  • Loading branch information
kaiyan-sheng committed Nov 9, 2020
1 parent 0bab1d3 commit 42428a8
Show file tree
Hide file tree
Showing 21 changed files with 51 additions and 32 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ from being added to events by default. {pull}18159[18159]
- Add SSL option to checkpoint module {pull}19560[19560]
- Add max_number_of_messages config into s3 input. {pull}21993[21993]
- Update Okta documentation for new stateful restarts. {pull}22091[22091]
- Rename google-pubsub input to gcp-pubsub. {pull}22213[22213]
- Copy tag names from MISP data into events. {pull}21664[21664]
- Added DNS response IP addresses to `related.ip` in Suricata module. {pull}22291[22291]
- Added TLS JA3 fingerprint, certificate not_before/not_after, certificate SHA1 hash, and certificate subject fields to Zeek SSL dataset. {pull}21696[21696]
Expand Down
4 changes: 2 additions & 2 deletions filebeat/docs/filebeat-options.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ You can configure {beatname_uc} to use the following inputs:
* <<{beatname_lc}-input-cloudfoundry>>
* <<{beatname_lc}-input-container>>
* <<{beatname_lc}-input-docker>>
* <<{beatname_lc}-input-google-pubsub>>
* <<{beatname_lc}-input-gcp-pubsub>>
* <<{beatname_lc}-input-http_endpoint>>
* <<{beatname_lc}-input-httpjson>>
* <<{beatname_lc}-input-kafka>>
Expand Down Expand Up @@ -96,7 +96,7 @@ include::inputs/input-docker.asciidoc[]

include::inputs/input-filestream.asciidoc[]

include::../../x-pack/filebeat/docs/inputs/input-google-pubsub.asciidoc[]
include::../../x-pack/filebeat/docs/inputs/input-gcp-pubsub.asciidoc[]

include::../../x-pack/filebeat/docs/inputs/input-http-endpoint.asciidoc[]

Expand Down
2 changes: 1 addition & 1 deletion x-pack/elastic-agent/pkg/agent/program/supported.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion x-pack/elastic-agent/spec/filebeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ rules:
- cloudfoundry
- container
- docker
- google-pubsub
- gcp-pubsub
- http_endpoint
- httpjson
- kafka
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#---------------------------- Google Cloud Pub/Sub Input -----------------------
# Input for reading messages from a Google Cloud Pub/Sub topic subscription.
- type: google-pubsub
- type: gcp-pubsub
enabled: false

# Google Cloud project ID. Required.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[role="xpack"]

:type: google-pubsub
:type: gcp-pubsub

[id="{beatname_lc}-input-{type}"]
=== Google Cloud Pub/Sub input
=== GCP Pub/Sub input

++++
<titleabbrev>Google Pub/Sub</titleabbrev>
<titleabbrev>GCP Pub/Sub</titleabbrev>
++++

Use the `google-pubsub` input to read messages from a Google Cloud Pub/Sub topic
Use the `gcp-pubsub` input to read messages from a Google Cloud Pub/Sub topic
subscription.

This input can, for example, be used to receive Stackdriver logs that have been
Expand All @@ -23,7 +23,7 @@ Example configuration:
["source","yaml",subs="attributes"]
----
{beatname_lc}.inputs:
- type: google-pubsub
- type: gcp-pubsub
project_id: my-gcp-project-id
topic: vpc-firewall-logs-topic
subscription.name: filebeat-vpc-firewall-logs-sub
Expand All @@ -33,7 +33,7 @@ Example configuration:

==== Configuration options

The `google-pubsub` input supports the following configuration options plus the
The `gcp-pubsub` input supports the following configuration options plus the
<<{beatname_lc}-input-{type}-common-options>> described later.

[float]
Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/filebeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2388,7 +2388,7 @@ filebeat.inputs:

#---------------------------- Google Cloud Pub/Sub Input -----------------------
# Input for reading messages from a Google Cloud Pub/Sub topic subscription.
- type: google-pubsub
- type: gcp-pubsub
enabled: false

# Google Cloud project ID. Required.
Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/include/list.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package googlepubsub
package gcppubsub

import (
"context"
"fmt"
"os"

"github.com/elastic/beats/v7/filebeat/harvester"

"cloud.google.com/go/pubsub"
"golang.org/x/oauth2/google"
)

type config struct {
harvester.ForwarderConfig `config:",inline"`
// Google Cloud project name.
ProjectID string `config:"project_id" validate:"required"`

Expand Down Expand Up @@ -62,6 +65,9 @@ func (c *config) Validate() error {

func defaultConfig() config {
var c config
c.ForwarderConfig = harvester.ForwarderConfig{
Type: "gcp-pubsub",
}
c.Subscription.NumGoroutines = 1
c.Subscription.MaxOutstandingMessages = 1000
c.Subscription.Create = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package googlepubsub
package gcppubsub

import (
"os"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package googlepubsub
package gcppubsub

import (
"context"
Expand All @@ -26,14 +26,20 @@ import (
)

const (
inputName = "google-pubsub"
inputName = "gcp-pubsub"
oldInputName = "google-pubsub"
)

func init() {
err := input.Register(inputName, NewInput)
if err != nil {
panic(errors.Wrapf(err, "failed to register %v input", inputName))
}

err = input.Register(oldInputName, NewInput)
if err != nil {
panic(errors.Wrapf(err, "failed to register %v input", oldInputName))
}
}

type pubsubInput struct {
Expand Down Expand Up @@ -64,6 +70,15 @@ func NewInput(
return nil, err
}

logger := logp.NewLogger("gcp.pubsub").With(
"pubsub_project", conf.ProjectID,
"pubsub_topic", conf.Topic,
"pubsub_subscription", conf.Subscription)

if conf.Type == oldInputName {
logger.Warnf("%s input name is deprecated, please use %s instead", oldInputName, inputName)
}

// Wrap input.Context's Done channel with a context.Context. This goroutine
// stops with the parent closes the Done channel.
inputCtx, cancelInputCtx := context.WithCancel(context.Background())
Expand All @@ -80,11 +95,8 @@ func NewInput(
workerCtx, workerCancel := context.WithCancel(inputCtx)

in := &pubsubInput{
config: conf,
log: logp.NewLogger("google.pubsub").With(
"pubsub_project", conf.ProjectID,
"pubsub_topic", conf.Topic,
"pubsub_subscription", conf.Subscription),
config: conf,
log: logger,
inputCtx: inputCtx,
workerCtx: workerCtx,
workerCancel: workerCancel,
Expand All @@ -109,7 +121,7 @@ func NewInput(
if err != nil {
return nil, err
}
in.log.Info("Initialized Google Pub/Sub input.")
in.log.Info("Initialized GCP Pub/Sub input.")
return in, nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package googlepubsub
package gcppubsub

import (
"context"
Expand Down
4 changes: 2 additions & 2 deletions x-pack/filebeat/module/googlecloud/audit/config/input.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ if eq .input "google-pubsub" }}
{{ if eq .input "gcp-pubsub" }}

type: google-pubsub
type: gcp-pubsub
project_id: {{ .project_id }}
topic: {{ .topic }}
subscription.name: {{ .subscription_name }}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/module/googlecloud/audit/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module_version: "1.0"

var:
- name: input
default: google-pubsub
default: gcp-pubsub
- name: project_id
default: SET_PROJECT_NAME
- name: topic
Expand Down
4 changes: 2 additions & 2 deletions x-pack/filebeat/module/googlecloud/firewall/config/input.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ if eq .input "google-pubsub" }}
{{ if eq .input "gcp-pubsub" }}

type: google-pubsub
type: gcp-pubsub
project_id: {{ .project_id }}
topic: {{ .topic }}
subscription.name: {{ .subscription_name }}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/filebeat/module/googlecloud/firewall/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module_version: "1.0"

var:
- name: input
default: google-pubsub
default: gcp-pubsub
- name: project_id
default: SET_PROJECT_NAME
- name: topic
Expand Down
4 changes: 2 additions & 2 deletions x-pack/filebeat/module/googlecloud/vpcflow/config/input.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ if eq .input "google-pubsub" }}
{{ if eq .input "gcp-pubsub" }}

type: google-pubsub
type: gcp-pubsub
project_id: {{ .project_id }}
topic: {{ .topic }}
subscription.name: {{ .subscription_name }}
Expand Down

0 comments on commit 42428a8

Please sign in to comment.