Skip to content

Commit

Permalink
feat: add gcp_compute_instance_group_manager table (#669)
Browse files Browse the repository at this point in the history
Co-authored-by: Ved misra <47312748+misraved@users.noreply.github.com>
  • Loading branch information
pdecat and misraved authored Oct 28, 2024
1 parent 378ac45 commit 50d4c0a
Show file tree
Hide file tree
Showing 5 changed files with 413 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docs/tables/gcp_compute_instance_group.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: "Allows users to query Google Cloud Compute Engine Instance Groups,

# Table: gcp_compute_instance_group - Query Google Cloud Compute Engine Instance Groups using SQL

Google Cloud Compute Engine Instance Groups are collections of virtual machine (VM) instances that you can manage as a single entity. These groups are ideal for applications that require a lot of computing power and need to scale rapidly to meet demand. They offer a range of features including autoscaling, load balancing, and rolling updates.
Google Cloud Compute Engine Instance Groups are collections of virtual machine (VM) instances that you can manage as a single entity. When they are managed by Instance Group Managers, these groups are called [Managed Instance Groups (MIG)](https://cloud.google.com/compute/docs/instance-groups#managed_instance_groups), and are ideal for highly available applications that require a lot of computing power and need to scale rapidly to meet demand. They offer a range of features including autoscaling, autohealing, regional (multiple zone) deployment, and automatic updating. Otherwise, these groups are called [Unmanaged Instance Groups](https://cloud.google.com/compute/docs/instance-groups#unmanaged_instance_groups), and can contain heterogeneous instances that you can arbitrarily add and remove from them, but do not offer autoscaling, autohealing, rolling update support, multi-zone support, or the use of instance templates and are not a good fit for deploying highly available and scalable workloads, they can just be used for load balancing.

## Table Usage Guide

Expand Down Expand Up @@ -125,4 +125,4 @@ from
where
g.network = n.self_link
and g.subnetwork = s.self_link;
```
```
70 changes: 70 additions & 0 deletions docs/tables/gcp_compute_instance_group_manager.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
title: "Steampipe Table: gcp_compute_instance_group_manager - Query Google Cloud Compute Engine Instance Group Managers using SQL"
description: "Allows users to query Google Cloud Compute Engine Instance Group Managers, providing insights into the configuration, status, and properties of these group managers."
---

# Table: gcp_compute_instance_group_manager - Query Google Cloud Compute Engine Instance Group Managers using SQL

Google Cloud Compute Engine Instance Group Managers manage [Managed Instance Groups (MIG)](https://cloud.google.com/compute/docs/instance-groups#managed_instance_groups), and are ideal for highly available applications that require a lot of computing power and need to scale rapidly to meet demand. They offer a range of features including autoscaling, autohealing, regional (multiple zone) deployment, and automatic updating.

## Table Usage Guide

The `gcp_compute_instance_group_manager` table provides insights into instance group managers within Google Cloud Compute Engine. As a system administrator, you can explore group-specific details through this table, including configuration, associated instances, and autoscaling policies. Utilize it to monitor the status of your instance groups, manage load balancing, and plan for capacity adjustments.

## Examples

### Basic Info
Discover the segments of your Google Cloud Platform (GCP) that contain instance group managers, gaining insights into aspects like size and location. This can help in project management and resource allocation within the GCP infrastructure.

```sql+postgres
select
name,
description,
self_link,
instance_group,
location,
akas,
project
from
gcp_compute_instance_group_manager;
```

```sql+sqlite
select
name,
description,
self_link,
instance_group,
location,
akas,
project
from
gcp_compute_instance_group_manager;
```

### Get instance group details of each instance group manager
Get the size of the instance groups managed by instance group managers.

```sql+postgres
select
m.name,
g.name as group_name,
g.size as group_size
from
gcp_compute_instance_group_manager as m,
gcp_compute_instance_group as g
where
m.instance_group ->> 'name' = g.name;
```

```sql+sqlite
select
m.name,
g.name as group_name,
g.size as group_size
from
gcp_compute_instance_group_manager as m,
gcp_compute_instance_group as g
where
m.instance_group -> 'name' = g.name;
```
1 change: 1 addition & 0 deletions gcp/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func Plugin(ctx context.Context) *plugin.Plugin {
"gcp_compute_image": tableGcpComputeImage(ctx),
"gcp_compute_instance": tableGcpComputeInstance(ctx),
"gcp_compute_instance_group": tableGcpComputeInstanceGroup(ctx),
"gcp_compute_instance_group_manager": tableGcpComputeInstanceGroupManager(ctx),
"gcp_compute_instance_metric_cpu_utilization": tableGcpComputeInstanceMetricCpuUtilization(ctx),
"gcp_compute_instance_metric_cpu_utilization_daily": tableGcpComputeInstanceMetricCpuUtilizationDaily(ctx),
"gcp_compute_instance_metric_cpu_utilization_hourly": tableGcpComputeInstanceMetricCpuUtilizationHourly(ctx),
Expand Down
7 changes: 2 additions & 5 deletions gcp/table_gcp_compute_instance_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func tableGcpComputeInstanceGroup(ctx context.Context) *plugin.Table {
},
{
Name: "fingerprint",
Description: "The fingerprint of the named ports.",
Description: "The fingerprint of the instance group.",
Type: proto.ColumnType_STRING,
},
{
Expand Down Expand Up @@ -89,7 +89,7 @@ func tableGcpComputeInstanceGroup(ctx context.Context) *plugin.Table {
},
{
Name: "zone",
Description: "URL of the zone where the instance group resides.",
Description: "The URL of the zone where the instance group resides.",
Type: proto.ColumnType_STRING,
},
{
Expand Down Expand Up @@ -148,7 +148,6 @@ func tableGcpComputeInstanceGroup(ctx context.Context) *plugin.Table {
//// LIST FUNCTIONS

func listComputeInstanceGroup(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) {

// Max limit is set as per documentation
pageSize := types.Int64(500)
limit := d.QueryContext.Limit
Expand All @@ -159,7 +158,6 @@ func listComputeInstanceGroup(ctx context.Context, d *plugin.QueryData, h *plugi
}

// Get project details

projectId, err := getProject(ctx, d, h)
if err != nil {
return nil, err
Expand Down Expand Up @@ -202,7 +200,6 @@ func getComputeInstanceGroup(ctx context.Context, d *plugin.QueryData, h *plugin
plugin.Logger(ctx).Trace("getComputeInstanceGroup")

// Get project details

projectId, err := getProject(ctx, d, h)
if err != nil {
return nil, err
Expand Down
Loading

0 comments on commit 50d4c0a

Please sign in to comment.