You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e03bed5
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: pipeline/inputs/gcs.md
+20-9Lines changed: 20 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ The _Google Cloud Storage_ (`gcs`) input plugin reads log objects from a [Google
12
12
13
13
This plugin is the counterpart of the [Google Cloud Storage output plugin](../outputs/gcs.md). By default, it reads the objects that the output plugin writes. To archive logs to a bucket, refer to that page.
14
14
15
-
This plugin is available in Fluent Bit version 5.2 and greater. It's included in official builds. If you compile Fluent Bit from source, the `FLB_IN_GCS` build option is enabled by default, but the plugin requires a build with TLS support. When TLS support is disabled, the build system turns `FLB_IN_GCS` off.
15
+
This plugin is available in Fluent Bit version 5.2 and greater. If you compile Fluent Bit from source, the `FLB_IN_GCS` build option is enabled by default, but the plugin requires a build with TLS support. When TLS support is disabled, the build system turns `FLB_IN_GCS` off.
16
16
17
17
## How it works
18
18
@@ -40,7 +40,7 @@ This input always runs in its own [thread](../../administration/multithreading.m
40
40
|`enable_identity_federation`| Authenticate with Workload Identity Federation instead of a service account key. Mutually exclusive with `google_service_credentials`. See [Workload Identity Federation](#workload-identity-federation). |`false`|
41
41
|`end_offset`| Only read objects whose name is lexicographically lower than this value. See [Select objects](#select-objects). |_none_|
42
42
|`endpoint`| Cloud Storage API endpoint. Use `http://` only for tests and emulators. See [Use an emulator](#use-an-emulator). |`https://storage.googleapis.com`|
43
-
|`exit_on_complete`| Stop Fluent Bit after the plugin has processed all the objects. |`false`|
43
+
|`exit_on_complete`| Stop Fluent Bit after the plugin has processed all the objects. Exits with a non-zero status if the run fails or an object failed. |`false`|
44
44
|`google_service_account`| Email address of the service account to impersonate after the token exchange. When unset, the federated token is used directly against Cloud Storage. Only used when `enable_identity_federation` is `true`. See [Workload Identity Federation](#workload-identity-federation). |_none_|
45
45
|`google_service_credentials`| Absolute path to a Google Cloud service account credentials JSON file. See [Authentication](#authentication). |_none_|
46
46
|`identity_token_file`| Path to the file that holds the `OIDC` subject token used as the federation credential source. Required when `enable_identity_federation` is `true`. See [Workload Identity Federation](#workload-identity-federation). |_none_|
@@ -72,7 +72,7 @@ Before using the plugin, you must:
72
72
-`storage.objects.list`, to list the objects.
73
73
-`storage.objects.get`, to download them.
74
74
75
-
The predefined [Storage Object Viewer](https://docs.cloud.google.com/storage/docs/access-control/iam-roles) role (`roles/storage.objectViewer`) includes both permissions. The plugin never writes to the bucket, and it requests only the read-only `https://www.googleapis.com/auth/devstorage.read_only``OAuth 2.0` scope.
75
+
The predefined [Storage Object Viewer](https://docs.cloud.google.com/storage/docs/access-control/iam-roles) role (`roles/storage.objectViewer`) includes both permissions. The plugin never writes to the bucket. For the scope that the plugin requests in each authentication mode, see [Authentication](#authentication).
76
76
1. Make the credentials available to Fluent Bit. See [Authentication](#authentication).
77
77
78
78
For credentials file, metadata server, and impersonated federation modes, the identity is the service account. For Workload Identity Federation with `google_service_account` unset, it's the federated principal itself, so grant that principal bucket access directly.
@@ -92,6 +92,14 @@ The plugin looks for service account credentials in the following order, and use
92
92
93
93
The metadata server isn't a fallback for a failed credentials file. It's used only when no credentials file is configured through the option or either environment variable. If a credentials path is configured but the file can't be opened, read, or parsed as a service account key, the plugin logs an error such as `cannot open credentials file` or `invalid JSON credentials file` and fails to initialize. If you intend to use the metadata server, verify that the plugin logs `using GCE/GKE metadata server authentication` at startup.
94
94
95
+
#### Access scopes
96
+
97
+
The plugin never writes to the bucket in any authentication mode. The scope of the access token depends on the mode:
98
+
99
+
-**Service account key**: the plugin requests the read-only `https://www.googleapis.com/auth/devstorage.read_only``OAuth 2.0` scope.
100
+
-**Workload Identity Federation**: the plugin requests the read-only scope in the `STS` token exchange when you use direct resource access, and in the `IAM``generateAccessToken` call when you use impersonation.
101
+
-**Metadata server**: the plugin doesn't request a scope. The token carries the access scopes of the instance or node and the permissions of its attached service account. To keep the input read-only in this mode, attach a service account that only has read access to the bucket, for example Storage Object Viewer.
102
+
95
103
#### Workload Identity Federation
96
104
97
105
[Workload Identity Federation](https://docs.cloud.google.com/iam/docs/workload-identity-federation) lets Fluent Bit authenticate to Cloud Storage without a service account key. Use it when Fluent Bit runs outside Google Cloud, or on Google Kubernetes Engine where the workload receives a projected `OIDC` token. Set `enable_identity_federation` to `true` to select this mode.
@@ -114,7 +122,7 @@ The federated token can be used two ways:
114
122
-**Impersonation**: set `google_service_account` to the email address of a service account that can read the bucket. Grant the pool principal the `roles/iam.workloadIdentityUser` role on that service account.
115
123
-**Direct resource access**: leave `google_service_account` unset. The plugin uses the federated token directly against Cloud Storage, so the pool principal itself must have the permissions listed in [Google Cloud configuration](#google-cloud-configuration). The bucket must also have [uniform bucket-level access](https://docs.cloud.google.com/storage/docs/uniform-bucket-level-access) enabled.
116
124
117
-
For more details about this mode, refer to [Workload Identity Federation](../outputs/gcs.md#workload-identity-federation) in the Google Cloud Storage output plugin. The options and behavior are the same, except that the input requests the read-only scope.
125
+
For more details about this mode, refer to [Workload Identity Federation](../outputs/gcs.md#workload-identity-federation) in the Google Cloud Storage output plugin. The options and behavior are the same, except that the input requests the read-only scope. See [Access scopes](#access-scopes).
118
126
119
127
## Select objects
120
128
@@ -144,7 +152,7 @@ The plugin splits each object on newline characters (`\n`). It removes a trailin
144
152
- Any other line, including JSON that isn't an object or an object followed by other text, becomes a record with the line as the value of the `log` key: `{"log": "<line>"}`.
145
153
- If you set `parser`, the plugin applies that [parser](../parsers.md) to every line instead. If the parser can't process a line, that line becomes a `{"log": "<line>"}` record.
146
154
147
-
If the plugin can't encode a line, it logs an error and skips that line.
155
+
If the plugin can't encode a line, it logs an error and retries the batch on the next cycle, up to `retry_limit` times. If it still fails, the object counts as failed, the plugin doesn't record it in the [state database](#state-database), and it continues with the next object. Records of that object that the plugin emitted in earlier batches stay in the pipeline.
148
156
149
157
Use `object_key` to add the name of the source object to each record. If the record already has a key with that name, the plugin replaces its value.
150
158
@@ -158,7 +166,7 @@ By default, the plugin looks in each JSON record for the `date` key (`time_key`)
158
166
159
167
| Value | Accepted input |
160
168
| :--- | :--- |
161
-
|`auto`| A string in ISO 8601 or Java SQL timestamp format, or a number. An integer greater than `100000000000` is read as milliseconds since the epoch. Any other number is read as seconds, and a floating-point number can have a fractional part. |
169
+
|`auto`| A string in ISO 8601 or Java SQL timestamp format, or a number. A number greater than `100000000000`, integer or with a fractional part, is read as milliseconds since the epoch. Any other number is read as seconds, and a floating-point number can have a fractional part. |
162
170
|`iso8601`| A string such as `2026-11-23T10:15:30Z`, `2026-11-23T10:15:30.123Z`, or `2026-11-23T10:15:30+02:00`. The fraction of a second and the time zone are optional. A value without a time zone is read as UTC. |
163
171
|`java_sql_timestamp`| A string such as `2026-11-23 10:15:30` or `2026-11-23 10:15:30.123`, read as UTC. |
164
172
|`double`| A number of seconds since the epoch. |
@@ -167,7 +175,7 @@ By default, the plugin looks in each JSON record for the `date` key (`time_key`)
167
175
168
176
Strings are accepted only by `auto`, `iso8601`, and `java_sql_timestamp`. Numbers are accepted only by `auto`, `double`, `epoch`, and `epoch_ms`. Negative numbers aren't valid timestamps.
169
177
170
-
Set `time_keep` to `true` to keep the time key in the record after using it. If the key is missing or its value can't be parsed, the plugin uses the time of ingestion as the timestamp and leaves the record unchanged.
178
+
Set `time_keep` to `true` to keep the time key in the record after using it. If the key is missing or its value can't be parsed, the plugin uses the time of ingestion as the timestamp and leaves the record unchanged. A value that Fluent Bit can't represent as an event time, for example seconds beyond the 32-bit range, is treated the same way: the plugin uses the time of ingestion and leaves the field in the record.
171
179
172
180
When you set `parser`, the plugin ignores `time_key` and `time_format`. It uses the timestamp that the parser extracts, and falls back to the time of ingestion when the parser doesn't extract one. Set `time_key` to `false`, `off`, or `none` to use the time of ingestion for every record.
173
181
@@ -201,7 +209,9 @@ Set `db` to the path of a SQLite file to make the plugin remember which objects
201
209
202
210
Because the key includes the generation, an object that someone overwrites in the bucket has a new generation and is read again.
203
211
204
-
The database provides at-least-once delivery. The plugin records an object only after it emits all of its records. If Fluent Bit stops in the middle of an object, the plugin doesn't record that object, and reads and emits it again in full on the next run. Your destination might receive duplicates of the records from that one object.
212
+
The plugin records an object only after it hands all of its records to the Fluent Bit engine. If Fluent Bit stops or restarts in the middle of an object, the plugin reads that object again in full on the next run, so your destination might receive duplicates of the records from that one object.
213
+
214
+
The database doesn't protect records that the engine has buffered but not yet delivered. If the process is killed or crashes, those records can be lost, as with other inputs, and because the plugin already recorded the object, it doesn't read the object again. [Filesystem buffering](../buffering.md#filesystem-buffering-hybrid) reduces this exposure but doesn't remove it, because this input hands records to the engine from its own thread.
205
215
206
216
Without `db`, the plugin doesn't keep any state, and every run reads all the selected objects again.
207
217
@@ -218,11 +228,12 @@ The plugin processes one object at a time, doing a bounded amount of work on eve
218
228
|`404` (not found) while downloading | The plugin logs a warning and skips the object, for example when someone deleted it after the listing. The run continues. |
219
229
|`429`, `5xx`, connection errors, or no access token | The plugin repeats the request, up to `retry_limit` times. If all attempts fail, the plugin skips the object when downloading, or fails the run when listing. |
220
230
| Any other failure while downloading, including a corrupt gzip object | The plugin logs an error and skips the object. The run continues. |
231
+
| Record encoding failure | The plugin retries the batch on the next cycle, up to `retry_limit` times. If it still fails, the object counts as failed and the plugin doesn't record it in the state database. The plugin continues with the next object. |
221
232
| Any failure while listing | The run fails, after the retries described for `429` and `5xx`. A `404` while listing, for example when the bucket doesn't exist, also fails the run. |
222
233
223
234
`retry_limit` counts retries after the first attempt. With the default value of `3`, the plugin makes up to four attempts for a request: the first one and three retries. Retries run on the next collector cycle, without an additional backoff delay. Set `retry_limit` to `0` to disable retries.
224
235
225
-
When the run fails, the plugin logs the error, stops processing, and doesn't process any remaining objects. If `exit_on_complete` is `true`, Fluent Bit also exits. A skipped object isn't recorded in the [state database](#state-database), so a later run tries it again.
236
+
When the run fails, the plugin logs the error, stops processing, and doesn't process any remaining objects. If `exit_on_complete` is `true`, Fluent Bit also exits, with a non-zero status. It also exits with a non-zero status when the run completes but at least one object failed. Objects skipped because they no longer exist (`404`) don't count as failures. A skipped object isn't recorded in the [state database](#state-database), so a later run tries it again.
226
237
227
238
When the plugin finishes, successfully or not, it logs a summary with the number of objects processed, skipped, and failed, and the number of records emitted.
0 commit comments