Skip to content

Commit

Permalink
Added tables gcp_alloydb_cluster and gcp_alloydb_instance Closes #594 #…
Browse files Browse the repository at this point in the history
  • Loading branch information
ParthaI committed Jun 7, 2024
1 parent 35abe44 commit 00db235
Show file tree
Hide file tree
Showing 29 changed files with 1,316 additions and 0 deletions.
137 changes: 137 additions & 0 deletions docs/tables/gcp_alloydb_cluster.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
title: "Steampipe Table: gcp_alloydb_cluster - Query Google Cloud Platform AlloyDB Clusters using SQL"
description: "Allows users to query Google Cloud Platform AlloyDB Clusters, providing insights into cluster configurations, status, and associated metadata."
---

# Table: gcp_alloydb_cluster - Query Google Cloud Platform AlloyDB Clusters using SQL

Google Cloud AlloyDB is a fully managed, PostgreSQL-compatible database service optimized for performance and scalability. Built on Google's infrastructure, AlloyDB provides high availability, security, and integration with other services, making it ideal for enterprise database management solutions.

## Table Usage Guide

The `gcp_alloydb_cluster` table enables you to query information about AlloyDB clusters within Google Cloud Platform. It is useful for database administrators and developers to monitor the operational aspects of their AlloyDB environments, including configuration details, current state, and resource utilization.

## Examples

### Basic info
Retrieve basic information about your Google Cloud Platform's AlloyDB clusters. Useful for a quick overview and operational monitoring of cluster attributes.

```sql+postgres
select
name,
state,
display_name,
database_version,
location
from
gcp_alloydb_cluster;
```

```sql+sqlite
select
name,
state,
display_name,
database_version,
location
from
gcp_alloydb_cluster;
```

### List clusters by state
Identify AlloyDB clusters in a specific state to manage and troubleshoot operational needs effectively.

```sql+postgres
select
name,
state
from
gcp_alloydb_cluster
where
state = 'MAINTENANCE';
```

```sql+sqlite
select
name,
state
from
gcp_alloydb_cluster
where
state = 'MAINTENANCE';
```

### Detailed configuration of a cluster
Access detailed configuration settings of an AlloyDB cluster to understand its setup and make informed decisions about scaling and modifications.

```sql+postgres
select
name,
encryption_config,
network_config
from
gcp_alloydb_cluster
where
display_name = 'your-cluster-name';
```

```sql+sqlite
select
name,
json_extract(encryption_config, '$') as encryption_config,
json_detail(network_config, '$') as network_config
from
gcp_alloydb_cluster
where
display_name = 'your-cluster-name';
```

### List Clusters with Specific Database Version
This query retrieves all AlloyDB clusters that are using a specific database version, which is helpful for auditing purposes or planning upgrades.

```sql+postgres
select
name,
database_version,
state,
location
from
gcp_alloydb_cluster
where
database_version = 'POSTGRES_14';
```

```sql+sqlite
select
name,
database_version,
state,
location
from
gcp_alloydb_cluster
where
database_version = 'POSTGRES_14';
```

### Find Clusters with Encryption Enabled
This query is useful to ensure compliance by checking which clusters have encryption configured.

```sql+postgres
select
name,
encryption_config
from
gcp_alloydb_cluster
where
encryption_config is not null;
```

```sql+sqlite
select
name,
json_extract(encryption_config, '$')
from
gcp_alloydb_cluster
where
encryption_config is not null;
```
168 changes: 168 additions & 0 deletions docs/tables/gcp_alloydb_instance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
---
title: "Steampipe Table: gcp_alloydb_instance - Query Google Cloud Platform AlloyDB Instances using SQL"
description: "Allows users to query Google Cloud Platform AlloyDB Instances, offering insights into instance configurations, status, and associated metadata."
---

# Table: gcp_alloydb_instance - Query Google Cloud Platform AlloyDB Instances using SQL

Google Cloud AlloyDB is a fully managed PostgreSQL-compatible database service, optimized for high performance with the reliability of Google's infrastructure. AlloyDB Instances within a cluster offer flexible options for scaling and redundancy, meeting the needs of demanding database applications.

## Table Usage Guide

The `gcp_alloydb_instance` table can be queried to retrieve detailed information about individual AlloyDB instances within a cluster. It is invaluable for database administrators and system architects looking to monitor instance-specific performance, understand configuration details, and manage resource allocation effectively.

## Examples

### Basic Information Query

Retrieve essential details about all AlloyDB instances to quickly get an overview of your instances' configurations and statuses.

```sql+postgres
select
name,
state,
availability_type,
display_name
from
gcp_alloydb_instance;
```

```sql+sqlite
select
name,
state,
availability_type,
display_name
from
gcp_alloydb_instance;
```

### List Instances by Availability Type

This query is useful for identifying instances according to their availability setup, which helps in understanding your database's fault tolerance and geographic distribution.

```sql+postgres
select
name,
availability_type,
state
from
gcp_alloydb_instance
where
availability_type = 'REGIONAL';
```

```sql+sqlite
select
name,
availability_type,
state
from
gcp_alloydb_instance
where
availability_type = 'REGIONAL';
```

### Find Instances with Specific Labels

Labels are key-value pairs assigned to instances and can be used for organization and access control. This query helps filter instances based on these labels.

```sql+postgres
select
name,
labels
from
gcp_alloydb_instance
where
labels -> 'environment' = 'production';
```

```sql+sqlite
select
name,
json_extract(labels, '$.environment') as environment
from
gcp_alloydb_instance
where
environment = 'production';
```

### Instances Currently in Maintenance

This query helps in identifying which instances are currently undergoing maintenance, allowing for better planning and reduced downtime impact.

```sql+postgres
select
name,
state
from
gcp_alloydb_instance
where
state = 'MAINTENANCE';
```

```sql+sqlite
select
name,
state
from
gcp_alloydb_instance
where
state = 'MAINTENANCE';
```

### Detailed View of Instance Configurations

Gain a deeper understanding of the configurations for a specific instance, useful for troubleshooting or planning upgrades.

```sql+postgres
select
name,
machine_config,
client_connection_config,
ip_address
from
gcp_alloydb_instance
where
name = 'instance-12345';
```

```sql+sqlite
select
name,
json_extract(machine_config, '$') as machine_config,
json_extract(client_connection_config, '$') as client_connection_config,
ip_address
from
gcp_alloydb_instance
where
name = 'instance-12345';
```

### Get node details of the instances

Retrieve information about the nodes.

```sql+postgres
select
name,
node -> 'Id' as node_id,
node -> 'Ip' as node_ip,
node -> 'State' as node_state,
node -> 'ZoneId' as node_zone_id
from
gcp_alloydb_instance,
jsonb_array_elements(nodes) as node;
```

```sql+sqlite
select
name,
json_extract(node, '$.Id') as node_id,
json_extract(node, '$.Ip') as node_ip,
json_extract(node, '$.State') as node_state,
json_extract(node, '$.ZoneId') as node_zone_id
from
gcp_alloydb_instance,
json_each(json(nodes)) as node;
```
Empty file.
6 changes: 6 additions & 0 deletions gcp-test/tests/gcp_alloydb_cluster/test-get-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"display_name": "{{ resourceName }}",
"name": "{{ output.resource_id.value }}"
}
]
3 changes: 3 additions & 0 deletions gcp-test/tests/gcp_alloydb_cluster/test-get-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, display_name
from gcp.gcp_alloydb_cluster
where display_name = '{{ resourceName }}';
6 changes: 6 additions & 0 deletions gcp-test/tests/gcp_alloydb_cluster/test-list-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"display_name": "{{ resourceName }}",
"name": "{{ output.resource_id.value }}"
}
]
3 changes: 3 additions & 0 deletions gcp-test/tests/gcp_alloydb_cluster/test-list-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, display_name
from gcp.gcp_alloydb_cluster
where akas::text = '["{{ output.resource_aka.value }}"]'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
3 changes: 3 additions & 0 deletions gcp-test/tests/gcp_alloydb_cluster/test-notfound-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select name, title, akas
from gcp.gcp_alloydb_cluster
where display_name = '{{ resourceName }}:asdf'
8 changes: 8 additions & 0 deletions gcp-test/tests/gcp_alloydb_cluster/test-turbot-expected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"akas": [
"{{ output.resource_aka.value }}"
],
"title": "{{ resourceName }}"
}
]
3 changes: 3 additions & 0 deletions gcp-test/tests/gcp_alloydb_cluster/test-turbot-query.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
select title, akas
from gcp.gcp_alloydb_cluster
where display_name = '{{ resourceName }}';
1 change: 1 addition & 0 deletions gcp-test/tests/gcp_alloydb_cluster/variables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading

0 comments on commit 00db235

Please sign in to comment.