Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added data source monitoring istio canonical service #8789

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/4623.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-datasource
`google_monitoring_istio_canonical_service`
```
54 changes: 54 additions & 0 deletions google/data_source_monitoring_istio_canonical_service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package google

import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

// No tests are added in this PR as currently there is no TF-supported method that can be used to
// enable either services (Cluster Istio, Mesh Istio and Istio Canonical Service) in GKE
func dataSourceMonitoringIstioCanonicalService() *schema.Resource {
csSchema := map[string]*schema.Schema{
"mesh_uid": {
Type: schema.TypeString,
Required: true,
Description: `Identifier for the Istio mesh in which this canonical service is defined.
Corresponds to the meshUid metric label in Istio metrics.`,
},
"canonical_service_namespace": {
Type: schema.TypeString,
Required: true,
Description: `The namespace of the canonical service underlying this service.
Corresponds to the destination_service_namespace metric label in Istio metrics.`,
},
"canonical_service": {
Type: schema.TypeString,
Required: true,
Description: `The name of the canonical service underlying this service..
Corresponds to the destination_service_name metric label in Istio metrics.`,
},
}
t := `istio_canonical_service.mesh_uid="{{mesh_uid}}" AND
istio_canonical_service.canonical_service="{{canonical_service}}" AND
istio_canonical_service.canonical_service_namespace="{{canonical_service_namespace}}"`
return dataSourceMonitoringServiceType(csSchema, t, dataSourceMonitoringIstioCanonicalServiceRead)
}

func dataSourceMonitoringIstioCanonicalServiceRead(res map[string]interface{}, d *schema.ResourceData, meta interface{}) error {
var istioCanonicalService map[string]interface{}
if v, ok := res["istio_canonical_service"]; ok {
istioCanonicalService = v.(map[string]interface{})
}
if len(istioCanonicalService) == 0 {
return nil
}
if err := d.Set("canonical_service", istioCanonicalService["canonical_service"]); err != nil {
return err
}
if err := d.Set("canonical_service_namespace", istioCanonicalService["canonical_service_namespace"]); err != nil {
return err
}
if err := d.Set("mesh_name", istioCanonicalService["mesh_name"]); err != nil {
return err
}
return nil
}
1 change: 1 addition & 0 deletions google/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ func Provider() *schema.Provider {
"google_folder_organization_policy": dataSourceGoogleFolderOrganizationPolicy(),
"google_monitoring_notification_channel": dataSourceMonitoringNotificationChannel(),
"google_monitoring_cluster_istio_service": dataSourceMonitoringServiceClusterIstio(),
"google_monitoring_istio_canonical_service": dataSourceMonitoringIstioCanonicalService(),
"google_monitoring_mesh_istio_service": dataSourceMonitoringServiceMeshIstio(),
"google_monitoring_app_engine_service": dataSourceMonitoringServiceAppEngine(),
"google_monitoring_uptime_check_ips": dataSourceGoogleMonitoringUptimeCheckIps(),
Expand Down
84 changes: 84 additions & 0 deletions website/docs/d/monitoring_istio_canonical_service.html.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
subcategory: "Cloud (Stackdriver) Monitoring"
layout: "google"
page_title: "Google: google_monitoring_istio_canonical_service"
sidebar_current: "docs-google-datasource-monitoring-istio-canonical-service"
description: |-
An Monitoring Service resource created automatically by GCP to monitor an
Istio Canonical service.
---

# google\_monitoring\_istio\_canonical\_service

A Monitoring Service is the root resource under which operational aspects of a
generic service are accessible. A service is some discrete, autonomous, and
network-accessible unit, designed to solve an individual concern

A monitoring Istio Canonical Service is automatically created by GCP to monitor
Istio Canonical Services.


To get more information about Service, see:

* [API documentation](https://cloud.google.com/monitoring/api/ref_v3/rest/v3/services)
* How-to Guides
* [Service Monitoring](https://cloud.google.com/monitoring/service-monitoring)
* [Monitoring API Documentation](https://cloud.google.com/monitoring/api/v3/)

## Example Usage - Monitoring Istio Canonical Service


```hcl
# Monitors the default MeshIstio service
data "google_monitoring_istio_canonical_service" "default" {
mesh_uid = "proj-573164786102"
canonical_service_namespace = "istio-system"
canonical_service = "prometheus"
}
```

## Argument Reference

The arguments of this data source act as filters for identifying a given -created service.

The given filters must match exactly one service whose data will be exported as attributes. The following arguments are supported:

The following fields must be specified:

* `mesh_uid` - (Required) Identifier for the mesh in which this Istio service is defined.
Corresponds to the meshUid metric label in Istio metrics.

* `canonical_service_namespace` - (Required) The namespace of the canonical service underlying this service.
Corresponds to the destination_canonical_service_namespace metric label in Istio metrics.

* `canonical_service` - (Required) The name of the canonical service underlying this service.
Corresponds to the destination_canonical_service_name metric label in label in Istio metrics.

- - -

Other optional fields include:

* `project` - (Optional) The ID of the project in which the resource belongs.
If it is not provided, the provider project is used.

## Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

* `name` -
The full REST resource name for this channel. The syntax is:
`projects/[PROJECT_ID]/services/[SERVICE_ID]`.

* `display_name` -
Name used for UI elements listing this (Monitoring) Service.

* `telemetry` -
Configuration for how to query telemetry on the Service. Structure is documented below.

The `telemetry` block includes:

* `resource_name` -
(Optional)
The full name of the resource that defines this service.
Formatted as described in
https://cloud.google.com/apis/design/resource_names.
4 changes: 4 additions & 0 deletions website/google.erb
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,10 @@
<a href="/docs/providers/google/d/monitoring_cluster_istio_service.html">google_monitoring_cluster_istio_service</a>
</li>

<li>
<a href="/docs/providers/google/d/monitoring_istio_canonical_service.html">google_monitoring_istio_canonical_service</a>
</li>

<li>
<a href="/docs/providers/google/d/monitoring_mesh_istio_service.html">google_monitoring_mesh_istio_service</a>
</li>
Expand Down