> ## Documentation Index
> Fetch the complete documentation index at: https://cloudanix.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Bigtable Cluster Tables Should Have Timestamp Granularity Set To 1ms

### More Info:

Ensure that Bigtable cluster tables timestamp granularity is set to 1ms.

### Risk Level

Low

### Address

Operational Maturity

### Compliance Standards

CBP

### Triage and Remediation

<Tabs>
  <Tab title="Remediation">
    ### Remediation

    <AccordionGroup>
      <Accordion title="Using Console" defaultOpen="true">
        To remediate the misconfiguration of Bigtable Cluster Tables should have timestamp granularity set to 1ms in GCP using GCP console, follow these steps:

        1. Open the GCP console and navigate to the Cloud Bigtable section.

        2. Select the Bigtable instance that you want to remediate.

        3. In the left navigation pane, click on the "Tables" option.

        4. Select the table that you want to remediate and click on the "Edit" button.

        5. Scroll down to the "Column families" section and click on the column family that contains the timestamp column.

        6. In the "Column family" settings, set the "Timestamp granularity" to "Milliseconds".

        7. Click on the "Save" button to apply the changes.

        8. Repeat steps 4-7 for all the tables in the Bigtable instance that have timestamp columns.

        By following these steps, you will remediate the misconfiguration of Bigtable Cluster Tables should have timestamp granularity set to 1ms in GCP using GCP console.

        #
      </Accordion>

      <Accordion title="Using CLI">
        To remediate the misconfiguration of Bigtable Cluster Tables having timestamp granularity set to 1ms in GCP using GCP CLI, follow these steps:

        1. Open the terminal and ensure that you have the latest version of the Google Cloud SDK installed.

        2. Authenticate yourself with the GCP CLI by running the following command:

        ```
        gcloud auth login
        ```

        3. Set the default project for the CLI by running the following command:

        ```
        gcloud config set project PROJECT_ID
        ```

        Replace `PROJECT_ID` with the ID of the project where your Bigtable Cluster is located.

        4. Run the following command to update the timestamp granularity of your Bigtable Cluster:

        ```
        gcloud bigtable clusters update CLUSTER_NAME --cluster-id=CLUSTER_ID --instance=INSTANCE_NAME --timestamp-granularity=ms
        ```

        Replace `CLUSTER_NAME`, `CLUSTER_ID`, and `INSTANCE_NAME` with the respective names of your Bigtable Cluster, Cluster ID, and Instance.

        5. Verify that the timestamp granularity has been set to 1ms by running the following command:

        ```
        gcloud bigtable clusters describe CLUSTER_NAME --cluster-id=CLUSTER_ID --instance=INSTANCE_NAME
        ```

        This command will display the details of your Bigtable Cluster, including the timestamp granularity.

        By following these steps, you can remediate the misconfiguration of Bigtable Cluster Tables having timestamp granularity set to 1ms in GCP using GCP CLI.
      </Accordion>

      <Accordion title="Using Python">
        To remediate the Bigtable Cluster Tables Timestamp Granularity issue in GCP using Python, you can follow these steps:

        1. Install the `google-cloud-bigtable` library using pip:

        ```
        pip install google-cloud-bigtable
        ```

        2. Import the required libraries:

        ```python theme={null}
        from google.cloud import bigtable
        from google.cloud.bigtable import column_family
        ```

        3. Create a `bigtable.Client` object and a `bigtable.Table` object:

        ```python theme={null}
        client = bigtable.Client(project=<project_id>, admin=True)
        table = client.table('<instance_id>', '<table_id>')
        ```

        4. Get the column family and update the timestamp granularity:

        ```python theme={null}
        column_family_id = '<column_family_id>'
        column_family = column_family.ColumnFamily(column_granularity_millis=1)
        table.column_family(column_family_id).modify_column_family(column_family)
        ```

        5. Confirm that the column family has been updated:

        ```python theme={null}
        column_families = table.list_column_families()
        for column_family_id, column_family in column_families.items():
            print('Column Family:', column_family_id)
            print('Timestamp Granularity:', column_family.column_granularity_millis)
        ```

        This should remediate the Bigtable Cluster Tables Timestamp Granularity issue in GCP using Python.
      </Accordion>
    </AccordionGroup>
  </Tab>
</Tabs>

### Additional Reading:

* [https://cloud.google.com/bigtable/docs/writes](https://cloud.google.com/bigtable/docs/writes)
