# Operation Guide

1. Apply for TiDB Cloud production account changes and applications in Lark Approval, and request ViewOnly permissions for the dbaas-prod-clinic account

2. Configure cli as per https://pingcap.feishu.cn/docx/doxcnylr5yZjtEVkI1xgEOhRXym

3. Make sure there is a similar configuration under ~/.aws/config

```
[profile sso-prod]
sso_start_url = https://pingcap.awsapps.com/start/#/
sso_region = ap-northeast-1
sso_account_id = 557537366020
sso_role_name = DBaaS-Prod-ViewOnly-Role
[profile ob-oncall]
region = us-west-2
source_profile = sso-prod
role_arn = arn:aws:iam::557537366020:role/autonomous-oncall
```
4. Initialize Python runtime environment

```
cd drhouse
python3 -m venv env
source env/bin/activate # Switch to the virtual environment
pip install -r tools/requirements.txt
```

5. Pull slowlog from aws
```
cd tools/slowlogs
export AWS_PROFILE=ob-oncall   
export O11Y_AUTH0_CLIENT_ID="id"
export O11Y_AUTH0_CLIENT_SECRET="secret"
python3 main.py --help # Check help
python3 main.py clusterid starttimestemp endtimestemp --serverless # --serverless if want to get serverless cluster
```

6. pull slowlog from gcs

    6.1. Apply for TiDB Cloud production account changes and applications in Lark Approval, and request gcp-autonomous-prod for gcp account

    6.2. init gcloud cli，only do once,ref: https://cloud.google.com/sdk/docs/install
    ```
    gcloud auth application-default login # init ADC

    ```
    6.3 pull slowlog
    ```
    export O11Y_AUTH0_CLIENT_ID="id"
    export O11Y_AUTH0_CLIENT_SECRET="secret"
    python3 main.py clusterid starttimestemp endtimestemp --no-serverless
    ```