[id="configuration-{beatname_lc}-gcp-options"]
[role="xpack"]
== Configure Google Functions

++++
<titleabbrev>Google functions</titleabbrev>
++++

beta[]

{beatname_uc} runs as a Google Function on Google Cloud Platform (GCP).

Before deploying {beatname_uc}, you need to configure one or more functions and
specify details about the services that will trigger the functions.

You configure the functions in the the +{beatname_lc}.yml+ configuration file.
When you're done, you can <<deploy-to-cloud-provider,deploy the functions>>
to your serverless environment.

The following example configures two functions: `pubsub` and `storage`. The
`pubsub` function collects log events from https://cloud.google.com/pubsub/[Google
Pub/Sub]. The `storage` function collects log events from
https://cloud.google.com/storage/[Google Cloud Storage]. Both functions in the
example forward the events to {es}.

["source","sh",subs="attributes"]
----
functionbeat.provider.gcp.location_id: "europe-west2"
functionbeat.provider.gcp.project_id: "my-project-123456"
functionbeat.provider.gcp.storage_name: "functionbeat-deploy"
functionbeat.provider.gcp.functions:
  - name: pubsub
    enabled: true
    type: pubsub
    description: "Google Cloud Function for Pub/Sub"
    trigger:
      resource: "projects/_/pubsub/myPubSub"
      #service: "pubsub.googleapis.com"
  - name: storage
    enabled: true
    type: storage
    description: "Google Cloud Function for Cloud Storage"
    trigger:
      resource: "projects/my-project/buckets/my-storage"
      event_type: "google.storage.object.finalize"

cloud.id: "MyESDeployment:SomeLongString=="
cloud.auth: "elastic:mypassword"
----

[id="{beatname_lc}-gcp-options"]
[float]
=== Configuration options
Specify the following options to configure the functions
that you want to deploy to Google Cloud Platform (GCP).

TIP: If you change the configuration after deploying the function, use
the <<update-command,`update` command>> to update your deployment.

[float]
[id="{beatname_lc}-gcp-location_id"]
==== `provider.gcp.location_id`

The region where your GCP project is located.

[float]
[id="{beatname_lc}-gcp-project_id"]
==== `provider.gcp.project_id`

The ID of the GCP project where the function artifacts will be deployed. See the
https://cloud.google.com/about/locations/[Google Cloud Function documentation]
to verify that Cloud Functions are supported in the region you specify.

[float]
[id="{beatname_lc}-gcp-storage_name"]
==== `provider.gcp.storage_name`

The name of the Google Cloud storage bucket where the function artifacts will be
deployed. If the bucket doesn't exist, it will be created, if you have the
correct project permissions (`storage.objects.create`).

[float]
[id="{beatname_lc}-gcp-functions"]
==== `functionbeat.provider.gcp.functions`
A list of functions that are available for deployment.

[float]
[id="{beatname_lc}-gcp-name"]
===== `name`

A unique name for the Google function.

[float]
[id="{beatname_lc}-gcp--type"]
===== `type`

The type of GCP service to monitor. For this release, the supported types
are:

[horizontal]
`pubsub`:: Collect log events from Google Pub/Sub.
`storage`:: Collect log events from Google Cloud storage buckets. 

[float]
[id="{beatname_lc}-gcp-description"]
===== `description`

A description of the function. This description is useful when you are running
multiple functions and need more context about how each function is used.

[float]
[id="{beatname_lc}-gcp-memory-size"]
==== `memory_size`

The maximum amount of memory to allocate for this function. 
The default is `256MB`.

[float]
[id="{beatname_lc}-gcp-timeout"]
==== `timeout`

The execution timeout in seconds. If the function does not finish in time,
it is considered failed and terminated. The default is `60s`. Increase this
value if you see timeout messages is the Google Stackdriver logs.

[float]
[id="{beatname_lc}-gcp-service_account_email"]
==== `service_account_email`

The email of the service account that the function will assume as its identity.
The default is {projectid}@appspot.gserviceaccount.com.email.

[float]
[id="{beatname_lc}-gcp-labels"]
==== `labels`

One or more labels to apply to the function. A label is a key-value pair that
helps you organize your Google Cloud resources.

[float]
[id="{beatname_lc}-gcp-vpc_connector"]
==== `vpc_connector`

A VPC connector that the function can connect to when sending requests to
resources in your VPC network.

Use the format `projects/*/locations/*/connectors/*` or a fully qualified
URI.

[float]
[id="{beatname_lc}-gcp-maximum_instances"]
==== `maximum_instances`

The maximum instances that can be running at the same time. The default is
unlimited.

[float]
[id="{beatname_lc}-gcp-triggers"]
===== `trigger`

The trigger that will cause the function to execute.

* If `type` is `pubsub`, specify the name of the Pub/Sub topic to watch for
messages.

* If `type` is `storage`, specify the Cloud Storage bucket to watch for object
events. For `event_type`, specify the type of object event that will trigger the
function. See the https://cloud.google.com/functions/docs/calling/storage[Google Cloud
docs] for a list of available event types.

[float]
[id="{beatname_lc}-gcp-keep_null"]
==== `keep_null`

If `true`, fields with null values will be published in the output document. By
default, `keep_null` is `false`.

[float]
[id="{beatname_lc}-gcp-fields"]
==== `fields`

Optional fields that you can specify to add additional information to the
output. Fields can be scalar values, arrays, dictionaries, or any nested
combination of these.

[float]
[id="{beatname_lc}-gcp-processors"]
==== `processors`

Define custom processors for this function. For example, you can specify a
dissect processor to tokenize a string:

[source,yaml]
----
processors:
  - dissect:
      tokenizer: "%{key1} %{key2}"
----
