Skip to content

Commit

Permalink
Docs changes for DB Audit Logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddarth-Baldwa committed Dec 24, 2024
1 parent 3b8ef94 commit 41d1d39
Show file tree
Hide file tree
Showing 10 changed files with 226 additions and 14 deletions.
16 changes: 5 additions & 11 deletions cmd/cluster/audit-log-exporter/db_audit_log_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func init() {
enableDbAuditLoggingCmd.Flags().SortFlags = false
enableDbAuditLoggingCmd.Flags().String("integration-name", "", "[REQUIRED] Name of the Integration")
enableDbAuditLoggingCmd.MarkFlagRequired("integration-name")
enableDbAuditLoggingCmd.Flags().StringToString("ysql-config", nil, `[REQUIRED] The ysql config to setup DB auditting
enableDbAuditLoggingCmd.Flags().StringToString("ysql-config", nil, `[REQUIRED] The ysql config to setup DB audit logging
Please provide key value pairs as follows:
log_catalog=<boolean>,log_level=<LOG_LEVEL>,log_client=<boolean>,log_parameter=<boolean>,
log_relation=<boolean>,log_statement_once=<boolean>`)
Expand All @@ -284,32 +284,26 @@ func init() {
Please provide key value pairs as follows:
statement_classes=READ,WRITE,MISC`)
enableDbAuditLoggingCmd.MarkFlagRequired("statement_classes")
enableDbAuditLoggingCmd.Flags().String("cluster-name", "", "[REQUIRED] The cluster name to assign DB auditting")
enableDbAuditLoggingCmd.MarkFlagRequired("cluster-name")

DbAuditLoggingCmd.AddCommand(describeDbAuditLoggingCmd)
describeDbAuditLoggingCmd.Flags().SortFlags = false
describeDbAuditLoggingCmd.Flags().String("cluster-name", "", "[REQUIRED] The cluster name to list DB audit export config")
describeDbAuditLoggingCmd.MarkFlagRequired("cluster-name")

DbAuditLoggingCmd.AddCommand(updateDbAuditLoggingCmd)
updateDbAuditLoggingCmd.Flags().SortFlags = false
updateDbAuditLoggingCmd.Flags().String("integration-name", "", "[REQUIRED] Name of the Integration")
updateDbAuditLoggingCmd.MarkFlagRequired("integration-name")
updateDbAuditLoggingCmd.Flags().StringToString("ysql-config", nil, `The ysql config to setup DB auditting
updateDbAuditLoggingCmd.Flags().StringToString("ysql-config", nil, `[REQUIRED] The ysql config to setup DB audit logging
Please provide key value pairs as follows:
log_catalog=<boolean>,log_level=<LOG_LEVEL>,log_client=<boolean>,log_parameter=<boolean>,
log_relation=<boolean>,log_statement_once=<boolean>`)
updateDbAuditLoggingCmd.Flags().String("statement_classes", "", `The ysql config statement classes
updateDbAuditLoggingCmd.MarkFlagRequired("ysql-config")
updateDbAuditLoggingCmd.Flags().String("statement_classes", "", `[REQUIRED] The ysql config statement classes
Please provide key value pairs as follows:
statement_classes=READ,WRITE,MISC`)
updateDbAuditLoggingCmd.Flags().String("cluster-name", "", "[REQUIRED] The cluster name to assign DB auditting")
updateDbAuditLoggingCmd.MarkFlagRequired("cluster-name")
updateDbAuditLoggingCmd.MarkFlagRequired("statement_classes")

DbAuditLoggingCmd.AddCommand(disableDbAuditLoggingCmd)
disableDbAuditLoggingCmd.Flags().SortFlags = false
disableDbAuditLoggingCmd.Flags().String("cluster-name", "", "[REQUIRED] The cluster name to assign DB auditting")
disableDbAuditLoggingCmd.MarkFlagRequired("cluster-name")
disableDbAuditLoggingCmd.Flags().BoolP("force", "f", false, "Bypass the prompt for non-interactive usage")
}

Expand Down
18 changes: 16 additions & 2 deletions cmd/db_audit_logs_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,21 @@ log-statement-once false`)))
session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
session.Wait(2)
Expect(session.Err).Should(gbytes.Say(`\bError: required flag\(s\) "integration-name", "cluster-name" not set\b`))
Expect(session.Err).Should(gbytes.Say(`\bError: required flag\(s\) "integration-name", "ysql-config", "statement_classes", "cluster-name" not set\b`))
session.Kill()

cmd = exec.Command(compiledCLIPath, "cluster", "db-audit-logging", "update", "--cluster-name", "stunning-sole")
session, err = gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
session.Wait(2)
Expect(session.Err).Should(gbytes.Say(`\bError: required flag\(s\) "integration-name", "ysql-config", "statement_classes" not set\b`))
session.Kill()

cmd = exec.Command(compiledCLIPath, "cluster", "db-audit-logging", "update", "--cluster-name", "stunning-sole", "--integration-name", "datadog-tp")
session, err = gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
session.Wait(2)
Expect(session.Err).Should(gbytes.Say(`\bError: required flag\(s\) "ysql-config", "statement_classes" not set\b`))
session.Kill()
})
It("should return required log setting when not set", func() {
Expand Down Expand Up @@ -335,7 +349,7 @@ log-statement-once false`)))
ghttp.RespondWithJSONEncodedPtr(&statusCode, responseIntegrationList),
),
)
cmd := exec.Command(compiledCLIPath, "cluster", "db-audit-logging", "update", "--cluster-name", "stunning-sole", "--integration-name", "datadog-tp", "--ysql-config", "log_catalog=true,log_client=true,log_level=NOTICE,log_parameter=false,log_relation=false")
cmd := exec.Command(compiledCLIPath, "cluster", "db-audit-logging", "update", "--cluster-name", "stunning-sole", "--integration-name", "datadog-tp", "--ysql-config", "log_catalog=true,log_client=true,log_level=NOTICE,log_parameter=false,log_relation=false", "--statement_classes", "")
session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
session.Wait(2)
Expand Down
1 change: 1 addition & 0 deletions docs/ybm_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ybm cluster [flags]
* [ybm](ybm.md) - ybm - Effortlessly manage your DB infrastructure on YugabyteDB Aeon (DBaaS) from command line!
* [ybm cluster cert](ybm_cluster_cert.md) - Get the root CA certificate
* [ybm cluster create](ybm_cluster_create.md) - Create a cluster
* [ybm cluster db-audit-logging](ybm_cluster_db-audit-logging.md) - Configure Database Audit Logging for your Cluster.
* [ybm cluster db-query-logging](ybm_cluster_db-query-logging.md) - Configure Database Query Logging for your Cluster.
* [ybm cluster delete](ybm_cluster_delete.md) - Delete a cluster
* [ybm cluster describe](ybm_cluster_describe.md) - Describe a cluster
Expand Down
40 changes: 40 additions & 0 deletions docs/ybm_cluster_db-audit-logging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## ybm cluster db-audit-logging

Configure Database Audit Logging for your Cluster.

### Synopsis

Configure Database Audit Logging for your Cluster.

```
ybm cluster db-audit-logging [flags]
```

### Options

```
-c, --cluster-name string [REQUIRED] The name of the cluster.
-h, --help help for db-audit-logging
```

### Options inherited from parent commands

```
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
--timeout duration Wait command timeout, example: 5m, 1h. (default 168h0m0s)
--wait Wait until the task is completed, otherwise it will exit immediately, default to false
```

### SEE ALSO

* [ybm cluster](ybm_cluster.md) - Manage cluster operations
* [ybm cluster db-audit-logging describe](ybm_cluster_db-audit-logging_describe.md) - Describe Database Audit Logging configuration
* [ybm cluster db-audit-logging disable](ybm_cluster_db-audit-logging_disable.md) - Disable Database Audit Logging
* [ybm cluster db-audit-logging enable](ybm_cluster_db-audit-logging_enable.md) - Enable Database Audit Logging
* [ybm cluster db-audit-logging update](ybm_cluster_db-audit-logging_update.md) - Update Database Audit Logging Configuration

36 changes: 36 additions & 0 deletions docs/ybm_cluster_db-audit-logging_describe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## ybm cluster db-audit-logging describe

Describe Database Audit Logging configuration

### Synopsis

Describe Database Audit Logging configuration

```
ybm cluster db-audit-logging describe [flags]
```

### Options

```
-h, --help help for describe
```

### Options inherited from parent commands

```
-a, --apiKey string YugabyteDB Aeon account API key
-c, --cluster-name string [REQUIRED] The name of the cluster.
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
--timeout duration Wait command timeout, example: 5m, 1h. (default 168h0m0s)
--wait Wait until the task is completed, otherwise it will exit immediately, default to false
```

### SEE ALSO

* [ybm cluster db-audit-logging](ybm_cluster_db-audit-logging.md) - Configure Database Audit Logging for your Cluster.

37 changes: 37 additions & 0 deletions docs/ybm_cluster_db-audit-logging_disable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
## ybm cluster db-audit-logging disable

Disable Database Audit Logging

### Synopsis

Disable Database Audit Logging, if enabled

```
ybm cluster db-audit-logging disable [flags]
```

### Options

```
-f, --force Bypass the prompt for non-interactive usage
-h, --help help for disable
```

### Options inherited from parent commands

```
-a, --apiKey string YugabyteDB Aeon account API key
-c, --cluster-name string [REQUIRED] The name of the cluster.
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
--timeout duration Wait command timeout, example: 5m, 1h. (default 168h0m0s)
--wait Wait until the task is completed, otherwise it will exit immediately, default to false
```

### SEE ALSO

* [ybm cluster db-audit-logging](ybm_cluster_db-audit-logging.md) - Configure Database Audit Logging for your Cluster.

44 changes: 44 additions & 0 deletions docs/ybm_cluster_db-audit-logging_enable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## ybm cluster db-audit-logging enable

Enable Database Audit Logging

### Synopsis

Enable Database Audit Logging

```
ybm cluster db-audit-logging enable [flags]
```

### Options

```
--integration-name string [REQUIRED] Name of the Integration
--ysql-config stringToString [REQUIRED] The ysql config to setup DB audit logging
Please provide key value pairs as follows:
log_catalog=<boolean>,log_level=<LOG_LEVEL>,log_client=<boolean>,log_parameter=<boolean>,
log_relation=<boolean>,log_statement_once=<boolean> (default [])
--statement_classes string [REQUIRED] The ysql config statement classes
Please provide key value pairs as follows:
statement_classes=READ,WRITE,MISC
-h, --help help for enable
```

### Options inherited from parent commands

```
-a, --apiKey string YugabyteDB Aeon account API key
-c, --cluster-name string [REQUIRED] The name of the cluster.
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
--timeout duration Wait command timeout, example: 5m, 1h. (default 168h0m0s)
--wait Wait until the task is completed, otherwise it will exit immediately, default to false
```

### SEE ALSO

* [ybm cluster db-audit-logging](ybm_cluster_db-audit-logging.md) - Configure Database Audit Logging for your Cluster.

44 changes: 44 additions & 0 deletions docs/ybm_cluster_db-audit-logging_update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## ybm cluster db-audit-logging update

Update Database Audit Logging Configuration

### Synopsis

Update Database Audit Logging Configuration

```
ybm cluster db-audit-logging update [flags]
```

### Options

```
--integration-name string [REQUIRED] Name of the Integration
--ysql-config stringToString [REQUIRED] The ysql config to setup DB audit logging
Please provide key value pairs as follows:
log_catalog=<boolean>,log_level=<LOG_LEVEL>,log_client=<boolean>,log_parameter=<boolean>,
log_relation=<boolean>,log_statement_once=<boolean> (default [])
--statement_classes string [REQUIRED] The ysql config statement classes
Please provide key value pairs as follows:
statement_classes=READ,WRITE,MISC
-h, --help help for update
```

### Options inherited from parent commands

```
-a, --apiKey string YugabyteDB Aeon account API key
-c, --cluster-name string [REQUIRED] The name of the cluster.
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
--timeout duration Wait command timeout, example: 5m, 1h. (default 168h0m0s)
--wait Wait until the task is completed, otherwise it will exit immediately, default to false
```

### SEE ALSO

* [ybm cluster db-audit-logging](ybm_cluster_db-audit-logging.md) - Configure Database Audit Logging for your Cluster.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.17.0
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241219183048-50fe86c058d8
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241224115148-e3b391db3af9
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
golang.org/x/mod v0.20.0
golang.org/x/term v0.25.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,8 @@ github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816 h1
github.com/t-tomalak/logrus-easy-formatter v0.0.0-20190827215021-c074f06c5816/go.mod h1:tzym/CEb5jnFI+Q0k4Qq3+LvRF4gO3E2pxS8fHP8jcA=
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241219183048-50fe86c058d8 h1:criIjOTBfBOy0cZ23Qh2sOI0KLL3P4WKutnUhovUHPA=
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241219183048-50fe86c058d8/go.mod h1:5vW0xIzIZw+1djkiWKx0qqNmqbRBSf4mjc4qw8lIMik=
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241224115148-e3b391db3af9 h1:omB8P+cKd/t5CEvgXCYoiCFg1SU+k4P0Ig28NqPrizw=
github.com/yugabyte/yugabytedb-managed-go-client-internal v0.0.0-20241224115148-e3b391db3af9/go.mod h1:5vW0xIzIZw+1djkiWKx0qqNmqbRBSf4mjc4qw8lIMik=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down

0 comments on commit 41d1d39

Please sign in to comment.