turbot/cloudflare
steampipe plugin install cloudflare

Table: cloudflare_r2_object - Query Cloudflare R2 Objects using SQL

Cloudflare R2 is a storage service that provides fast, reliable, and cost-effective object storage. It is designed to handle data from any source, making it a versatile solution for storing, retrieving, and managing data. With R2, users can store any amount of data and access it anywhere at any time.

Table Usage Guide

The cloudflare_r2_object table provides insights into the R2 Objects within Cloudflare. As a DevOps engineer, explore object-specific details through this table, such as the object ID, object type, and object content. Utilize it to manage and monitor your Cloudflare R2 Objects, ensuring optimal data storage and retrieval.

Important Notes

  • Using this table adds to cost to your monthly bill from Cloudflare. Optimizations have been put in place to minimize the impact as much as possible. Please refer to Cloudflare R2 Pricing to understand the cost implications.

Examples

Basic info

Explore the specific details of an account's stored objects within a particular Cloudflare bucket to understand their size and changes. This can be useful for assessing storage usage and tracking modifications to objects within a specific time period.

select
key,
etag,
size
from
cloudflare_r2_object
where
account_id = 'fb1696f453testaccount39e734f5f96e9'
and bucket = 'cloudflare_logs_2021_03_01';
select
key,
etag,
size
from
cloudflare_r2_object
where
account_id = 'fb1696f453testaccount39e734f5f96e9'
and bucket = 'cloudflare_logs_2021_03_01';

List all objects with a fixed prefix

Discover the segments that have a specific prefix within your Cloudflare account. This is beneficial for organizing and locating specific sets of data, such as logs from a certain date.

select
key,
etag,
size,
prefix
from
cloudflare_r2_object
where
account_id = 'fb1696f453testaccount39e734f5f96e9'
and bucket = 'cloudflare_logs_2021_03_01'
and prefix = '/logs/2021/03/01/12';
select
key,
etag,
size,
prefix
from
cloudflare_r2_object
where
account_id = 'fb1696f453testaccount39e734f5f96e9'
and bucket = 'cloudflare_logs_2021_03_01'
and prefix = '/logs/2021/03/01/12';

List all objects with a fixed key

Discover the segments that contain specific objects within a given account and bucket, which can be useful for pinpointing where certain data is stored or identifying patterns in data storage.

select
key,
etag,
size,
prefix
from
cloudflare_r2_object
where
account_id = 'fb1696f453testaccount39e734f5f96e9'
and bucket = 'cloudflare_logs_2021_03_01'
and key = '/logs/2021/03/01/12/05/32.log';
select
key,
etag,
size,
prefix
from
cloudflare_r2_object
where
account_id = 'fb1696f453testaccount39e734f5f96e9'
and bucket = 'cloudflare_logs_2021_03_01'
and key = '/logs/2021/03/01/12/05/32.log';

List all objects which were not modified in the last 3 months

Explore the objects within a specific account and bucket that have remained unmodified over the past three months. This query can be used to identify stagnant or unused data, aiding in efficient data management and potential cleanup efforts.

select
key,
bucket,
last_modified,
etag,
size
from
cloudflare_r2_object
where
account_id = 'fb1696f453testaccount39e734f5f96e9'
and bucket = 'cloudflare_logs_2021_03_01'
and prefix = 'static_assets'
and last_modified < current_date - interval '3 months';
select
key,
bucket,
last_modified,
etag,
size
from
cloudflare_r2_object
where
account_id = 'fb1696f453testaccount39e734f5f96e9'
and bucket = 'cloudflare_logs_2021_03_01'
and prefix = 'static_assets'
and last_modified < date('now', '-3 months');

List objects created in the last 30 days

Explore objects that have been created in the past month within a specific account and bucket. This can be useful for monitoring recent activity or changes in your Cloudflare data.

select
key,
bucket,
last_modified,
etag,
size
from
cloudflare_r2_object
where
creation_date >= now() - interval '30' day
and account_id = 'fb1696f453testaccount39e734f5f96e9'
and bucket = 'cloudflare_logs_2021_03_01'
and key = '/logs/2021/03/01/12/05/32.log';
select
key,
bucket,
last_modified,
etag,
size
from
cloudflare_r2_object
where
creation_date >= datetime('now', '-30 day')
and account_id = 'fb1696f453testaccount39e734f5f96e9'
and bucket = 'cloudflare_logs_2021_03_01'
and key = '/logs/2021/03/01/12/05/32.log';

List objects that return truncated results

Determine the instances where certain objects are yielding incomplete results within a specific Cloudflare account and bucket, allowing you to identify and address potential issues with data integrity or retrieval.

select
key,
bucket,
last_modified,
etag,
size
from
cloudflare_r2_object
where
is_truncated
and account_id = 'fb1696f453testaccount39e734f5f96e9'
and bucket = 'cloudflare_logs_2021_03_01'
and key = '/logs/2021/03/01/12/05/32.log';
select
key,
bucket,
last_modified,
etag,
size
from
cloudflare_r2_object
where
is_truncated
and account_id = 'fb1696f453testaccount39e734f5f96e9'
and bucket = 'cloudflare_logs_2021_03_01'
and key = '/logs/2021/03/01/12/05/32.log';

List objects that have bucket key enabled

Explore which objects within a specific Cloudflare account have the bucket key enabled. This is particularly useful for identifying potential security risks or for auditing purposes.

select
key,
bucket,
last_modified,
etag,
size
from
cloudflare_r2_object
where
bucket_key_enabled
and account_id = 'fb1696f453testaccount39e734f5f96e9'
and bucket = 'cloudflare_logs_2021_03_01'
and key = '/logs/2021/03/01/12/05/32.log';
select
key,
bucket,
last_modified,
etag,
size
from
cloudflare_r2_object
where
bucket_key_enabled = 1
and account_id = 'fb1696f453testaccount39e734f5f96e9'
and bucket = 'cloudflare_logs_2021_03_01'
and key = '/logs/2021/03/01/12/05/32.log';

Schema for cloudflare_r2_object

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form, e.g. connection_name.
account_idtext=ID of the account.
buckettext=The name of the container bucket of the object.
bucket_key_enabledbooleanIndicates whether the object uses an R2 Bucket Key for server-side encryption with Amazon Web Services KMS (SSE-KMS).
content_encodingtextSpecifies what content encodings have been applied to the object.
content_lengthbigintSize of the body in bytes.
content_typetextA standard MIME type describing the format of the object data.
delete_markerbooleanSpecifies whether the object retrieved was (true) or was not (false) a delete marker.
etagtextA a hash of the object.
keytext=The name assigned to an object.
last_modifiedtimestamp with time zoneSpecifies the time when the object is last modified.
metadatajsonbA map of metadata to store with the object in R2.
ownerjsonbThe owner of the object
prefixtext=The prefix of the key of the object.
restoretextProvides information about object restoration action and expiration time of the restored object copy.
server_side_encryptiontextThe server-side encryption algorithm used when storing this object in Cloudflare R2.
sizebigintSize in bytes of the object
storage_classtextProvides storage class information of the object.
titletextTitle of the resource.
versiontextVersion of the object.
website_redirection_locationtextIf the bucket is configured as a website, redirects requests for this object to another object in the same bucket or to an external URL.

Export

This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.

You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh script:

/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- cloudflare

You can pass the configuration to the command with the --config argument:

steampipe_export_cloudflare --config '<your_config>' cloudflare_r2_object