Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(storage): add support for IBM cloud object storage as storage client #8826

Merged
merged 18 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/sources/alert/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ ruler:

## Ruler storage

The Ruler supports five kinds of storage: azure, gcs, s3, swift, and local. Most kinds of storage work with the sharded Ruler configuration in an obvious way, i.e. configure all Rulers to use the same backend.
The Ruler supports the following types of storage: `azure`, `gcs`, `s3`, `swift`, `cos` and `local`. Most kinds of storage work with the sharded Ruler configuration in an obvious way, that is, configure all Rulers to use the same backend.

The local implementation reads the rule files off of the local filesystem. This is a read-only backend that does not support the creation and deletion of rules through the [Ruler API]({{<relref "../api/#ruler">}}). Despite the fact that it reads the local filesystem this method can still be used in a sharded Ruler configuration if the operator takes care to load the same rules to every Ruler. For instance, this could be accomplished by mounting a [Kubernetes ConfigMap](https://kubernetes.io/docs/concepts/configuration/configmap/) onto every Ruler pod.

Expand Down
100 changes: 93 additions & 7 deletions docs/sources/configuration/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ The `ruler` block configures the Loki ruler.
# options instead.
storage:
# Method to use for backend rule storage (configdb, azure, gcs, s3, swift,
# local, bos)
# local, bos, cos)
# CLI flag: -ruler.storage.type
[type: <string> | default = ""]

Expand Down Expand Up @@ -802,6 +802,10 @@ storage:
# The CLI flags prefix for this block configuration is: ruler.storage
[swift: <swift_storage_config>]

# Configures backend rule storage for IBM Cloud Object Storage (COS).
# The CLI flags prefix for this block configuration is: ruler.storage
[cos: <cos_storage_config>]

# Configures backend rule storage for a local file system directory.
local:
# Directory to scan for rules
Expand Down Expand Up @@ -1775,6 +1779,10 @@ hedging:
# in period_config.
[named_stores: <named_stores_config>]

# The cos_storage_config block configures the connection to IBM Cloud Object
# Storage (COS) backend.
[cos: <cos_storage_config>]

# Cache validity for active index entries. Should be no higher than
# -ingester.max-chunk-idle.
# CLI flag: -store.index-cache-validity
Expand All @@ -1797,16 +1805,16 @@ hedging:
# CLI flag: -store.max-chunk-batch-size
[max_chunk_batch_size: <int> | default = 50]

# Configures storing index in an Object Store (GCS/S3/Azure/Swift/Filesystem) in
# the form of boltdb files. Required fields only required when boltdb-shipper is
# defined in config.
# Configures storing index in an Object Store
# (GCS/S3/Azure/Swift/COS/Filesystem) in the form of boltdb files. Required
# fields only required when boltdb-shipper is defined in config.
boltdb_shipper:
# Directory where ingesters would write index files which would then be
# uploaded by shipper to configured storage
# CLI flag: -boltdb.shipper.active-index-directory
[active_index_directory: <string> | default = ""]

# Shared store for keeping index files. Supported types: gcs, s3, azure,
# Shared store for keeping index files. Supported types: gcs, s3, azure, cos,
# filesystem
# CLI flag: -boltdb.shipper.shared-store
[shared_store: <string> | default = ""]
Expand Down Expand Up @@ -1870,7 +1878,7 @@ tsdb_shipper:
# CLI flag: -tsdb.shipper.active-index-directory
[active_index_directory: <string> | default = ""]

# Shared store for keeping index files. Supported types: gcs, s3, azure,
# Shared store for keeping index files. Supported types: gcs, s3, azure, cos,
# filesystem
# CLI flag: -tsdb.shipper.shared-store
[shared_store: <string> | default = ""]
Expand Down Expand Up @@ -1965,7 +1973,7 @@ The `compactor` block configures the compactor component, which compacts index s
[working_directory: <string> | default = ""]

# The shared store used for storing boltdb files. Supported types: gcs, s3,
# azure, swift, filesystem, bos.
# azure, swift, filesystem, bos, cos.
# CLI flag: -boltdb.shipper.compactor.shared-store
[shared_store: <string> | default = ""]

Expand Down Expand Up @@ -2940,6 +2948,11 @@ storage:
# CLI flag: -common.storage.hedge-max-per-second
[max_per_second: <int> | default = 5]

# The cos_storage_config block configures the connection to IBM Cloud Object
# Storage (COS) backend.
# The CLI flags prefix for this block configuration is: common.storage
[cos: <cos_storage_config>]

[persist_tokens: <boolean>]

[replication_factor: <int>]
Expand Down Expand Up @@ -4209,6 +4222,77 @@ The `swift_storage_config` block configures the connection to OpenStack Object S
[request_timeout: <duration> | default = 5s]
```

### cos_storage_config

The `cos_storage_config` block configures the connection to IBM Cloud Object Storage (COS) backend. The supported CLI flags `<prefix>` used to reference this configuration block are:

- `common.storage`
- `ruler.storage`

&nbsp;

```yaml
# Set this to `true` to force the request to use path-style addressing.
# CLI flag: -<prefix>.cos.force-path-style
[forcepathstyle: <boolean> | default = false]

# Comma separated list of bucket names to evenly distribute chunks over.
# CLI flag: -<prefix>.cos.buckets
[bucketnames: <string> | default = ""]

# COS Endpoint to connect to.
# CLI flag: -<prefix>.cos.endpoint
[endpoint: <string> | default = ""]

# COS region to use.
# CLI flag: -<prefix>.cos.region
[region: <string> | default = ""]

# COS HMAC Access Key ID.
# CLI flag: -<prefix>.cos.access-key-id
[access_key_id: <string> | default = ""]

# COS HMAC Secret Access Key.
# CLI flag: -<prefix>.cos.secret-access-key
[secret_access_key: <string> | default = ""]

http_config:
# The maximum amount of time an idle connection will be held open.
# CLI flag: -<prefix>.cos.http.idle-conn-timeout
[idle_conn_timeout: <duration> | default = 1m30s]

# If non-zero, specifies the amount of time to wait for a server's response
# headers after fully writing the request.
# CLI flag: -<prefix>.cos.http.response-header-timeout
[response_header_timeout: <duration> | default = 0s]

# Configures back off when cos get Object.
backoff_config:
# Minimum backoff time when cos get Object.
# CLI flag: -<prefix>.cos.min-backoff
[min_period: <duration> | default = 100ms]

# Maximum backoff time when cos get Object.
# CLI flag: -<prefix>.cos.max-backoff
[max_period: <duration> | default = 3s]

# Maximum number of times to retry when cos get Object.
# CLI flag: -<prefix>.cos.max-retries
[max_retries: <int> | default = 5]

# IAM API key to access COS.
# CLI flag: -<prefix>.cos.api-key
[api_key: <string> | default = ""]

# COS service instance id to use.
# CLI flag: -<prefix>.cos.service-instance-id
[service_instance_id: <string> | default = ""]

# IAM Auth Endpoint for authentication.
# CLI flag: -<prefix>.cos.auth-endpoint
[auth_endpoint: <string> | default = "https://iam.cloud.ibm.com/identity/token"]
```

### local_storage_config

The `local_storage_config` block configures the usage of local file system as object storage backend.
Expand Down Expand Up @@ -4246,6 +4330,8 @@ Named store from this example can be used by setting object_store to store-1 in
[alibabacloud: <map of string to alibabacloud_storage_config>]

[swift: <map of string to swift_storage_config>]

[cos: <map of string to cos_storage_config>]
```

## Runtime Configuration file
Expand Down
55 changes: 55 additions & 0 deletions docs/sources/configuration/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,58 @@ storage_config:
kms_key_id: 0987dcba-09fe-87dc-65ba-ab0987654321
```


## 11-COS-HMAC-Example.yaml

```yaml

# This partial configuration uses IBM Cloud Object Storage (COS) for chunk storage. HMAC will be used for authenticating with COS.

schema_config:
configs:
- from: 2020-10-01
index:
period: 24h
prefix: loki_index_
object_store: "cos"
schema: v11
store: "boltdb-shipper"

storage_config:
cos:
bucketnames: <bucket1, bucket2>
endpoint: <endpoint>
region: <region>
access_key_id: <access_key_id>
secret_access_key: <secret_access_key>

```


## 12-COS-APIKey-Example.yaml

```yaml

# This partial configuration uses IBM Cloud Object Storage (COS) for chunk storage. APIKey will be used for authenticating with COS.

schema_config:
configs:
- from: 2020-10-01
index:
period: 24h
prefix: loki_index_
object_store: "cos"
schema: v11
store: "boltdb-shipper"

storage_config:
cos:
bucketnames: <bucket1, bucket2>
endpoint: <endpoint>
region: <region>
api_key: <api_key_to_authenticate_with_cos>
service_instance_id: <cos_service_instance_id>
auth_endpoint: <iam_endpoint_for_authentication>

```

19 changes: 19 additions & 0 deletions docs/sources/configuration/examples/11-COS-HMAC-Example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This partial configuration uses IBM Cloud Object Storage (COS) for chunk storage. HMAC will be used for authenticating with COS.

schema_config:
configs:
- from: 2020-10-01
index:
period: 24h
prefix: loki_index_
object_store: "cos"
schema: v11
store: "boltdb-shipper"

storage_config:
cos:
bucketnames: <bucket1, bucket2>
endpoint: <endpoint>
region: <region>
access_key_id: <access_key_id>
secret_access_key: <secret_access_key>
20 changes: 20 additions & 0 deletions docs/sources/configuration/examples/12-COS-APIKey-Example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This partial configuration uses IBM Cloud Object Storage (COS) for chunk storage. APIKey will be used for authenticating with COS.

schema_config:
configs:
- from: 2020-10-01
index:
period: 24h
prefix: loki_index_
object_store: "cos"
schema: v11
store: "boltdb-shipper"

storage_config:
cos:
bucketnames: <bucket1, bucket2>
endpoint: <endpoint>
region: <region>
api_key: <api_key_to_authenticate_with_cos>
service_instance_id: <cos_service_instance_id>
auth_endpoint: <iam_endpoint_for_authentication>
2 changes: 1 addition & 1 deletion docs/sources/installation/tanka.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Revise the YAML contents of `environments/loki/main.jsonnet`, updating these var
- Update the `username`, `password`, and the relevant `htpasswd` variable values.
- Update the S3 or GCS variable values, depending on your object storage type. See [storage_config](/docs/loki/latest/configuration/#storage_config) for more configuration details.
- Remove from the configuration the S3 or GCS object storage variables that are not part of your setup.
- Update the value of `boltdb_shipper_shared_store` to the type of object storage you are using. Options are `gcs`, `s3`, `azure`, or `filesystem`. Update the `object_store` variable under the `schema_config` section to the same value.
- Update the value of `boltdb_shipper_shared_store` to the type of object storage you are using. Options are `gcs`, `s3`, `azure`, `cos` or `filesystem`. Update the `object_store` variable under the `schema_config` section to the same value.
- Update the Promtail configuration `container_root_path` variable's value to reflect your root path for the Docker daemon. Run `docker info | grep "Root Dir"` to acquire your root path.
- Update the `from` value in the Loki `schema_config` section to no more than 14 days prior to the current date. The `from` date represents the first day for which the `schema_config` section is valid. For example, if today is `2021-01-15`, set `from` to `2021-01-01`. This recommendation is based on Loki's default acceptance of log lines up to 14 days in the past. The `reject_old_samples_max_age` configuration variable controls the acceptance range.

Expand Down
7 changes: 7 additions & 0 deletions docs/sources/operations/storage/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ The following are supported for the chunks:
- [Google Cloud Storage](https://cloud.google.com/storage/)
- [Filesystem]({{<relref "filesystem">}}) (please read more about the filesystem to understand the pros/cons before using with production data)
- [Baidu Object Storage](https://cloud.baidu.com/product/bos.html)
- [IBM Cloud Object Storage](https://www.ibm.com/cloud/object-storage)

## Cloud Storage Permissions

Expand Down Expand Up @@ -109,6 +110,12 @@ Resources: `*`
Resources: `arn:aws:iam::<aws_account_id>:role/<role_name>`


### IBM Cloud Object Storage

When using IBM Cloud Object Storage (COS) as object storage, IAM `Writer` role is needed.

See the [IBM Cloud Object Storage section]({{<relref "../../storage/#ibm-cloud-object-storage">}}) on the storage page for a detailed setup guide.

## Chunk Format

```
Expand Down
26 changes: 26 additions & 0 deletions docs/sources/storage/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ S3 is AWS's hosted object store. It is a good candidate for a managed object sto
Blob Storage is Microsoft Azure's hosted object store. It is a good candidate for a managed object store, especially when you're already running on Azure, and is production safe.
You can authenticate Blob Storage access by using a storage account name and key or by using a Service Principal.

### IBM Cloud Object Storage (COS)
[COS](https://www.ibm.com/cloud/object-storage) is IBM Cloud hosted object store. It is a good candidate for a managed object store, especially when you're already running on IBM Cloud, and is production safe.

### Notable Mentions

You may use any substitutable services, such as those that implement the S3 API like [MinIO](https://min.io/).
Expand Down Expand Up @@ -305,6 +308,29 @@ This guide assumes a provisioned EKS cluster.
`bucket_name` variable.


### IBM Cloud Object Storage

```yaml
schema_config:
configs:
- from: 2020-10-01
index:
period: 24h
prefix: loki_index_
object_store: "cos"
schema: v11
store: "boltdb-shipper"

storage_config:
cos:
bucketnames: <bucket1, bucket2>
endpoint: <endpoint>
api_key: <api_key_to_authenticate_with_cos>
region: <region>
service_instance_id: <cos_service_instance_id>
auth_endpoint: <iam_endpoint_for_authentication>
```

### On prem deployment (Cassandra+Cassandra)

**Keeping this for posterity, but this is likely not a common config. Cassandra should work and could be faster in some situations but is likely much more expensive.**
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/upgrading/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ Following 2 compactor configs that were defined as command line arguments in jso
[working_directory: <string>]

# The shared store used for storing boltdb files.
# Supported types: gcs, s3, azure, swift, filesystem.
# Supported types: gcs, s3, azure, swift, cos, filesystem.
# CLI flag: -boltdb.shipper.compactor.shared-store
[shared_store: <string>]
```
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ require (

require (
github.com/Azure/go-autorest/autorest v0.11.28
github.com/IBM/ibm-cos-sdk-go v1.9.4
github.com/fsnotify/fsnotify v1.6.0
github.com/grafana/loki/pkg/push v0.0.0-20230127102416-571f88bc5765
github.com/heroku/x v0.0.55
Expand Down
Loading