This document describes how to create custom services and services for some resources like GKE and Cloud Run.
In Cloud Monitoring, a service is a construct that you can associate with SLOs and alerting policies. Several of the resources for which you might create Monitoring services are also referred to as services, but with different meanings, like GKE services or Cloud Run services.
Monitoring can recognize GKE- and Cloud Run-based services as candidates for monitoring. To create services for them, you indicate which candidates you want to be treated as Monitoring services; Monitoring creates the necessary infrastructure for you.
You can also define arbitrary custom services.
Identify or create a service
To identify candidate services, or to create custom services, go to the Define service pane:
-
In the Google Cloud console, go to the SLOs page:
If you use the search bar to find this page, then select the result whose subheading is Monitoring.
On the Services Overview page, do one of the following:
Click add Define service.
In the Current status pane, click the Define service link:
From the Define service pane, you can do the following:
- Create services from a list of candidate services.
- Define custom services.
The following sections describe these options.
Create services
Cloud Monitoring can identify potential services of the following types:
- Cloud Service Mesh services
- Istio on Google Kubernetes Engine services
- App Engine services
- GKE namespaces
- GKE services
- GKE workloads
- Cloud Run service
Because there might be many of these potential services, Monitoring doesn't assume you want them all to be treated as services with SLOs. To indicate which of the potential services Monitoring should treat as services, you use either the Google Cloud console or the API.
Use the Google Cloud console to create services
To create a service by using the Google Cloud console, do the following:
On the Services Overview page, click Define service.
Select Service Candidates.
There might be a large number of candidate services in the list. You can filter the list as follows:
Click filter_list Filter table. A list of filter options is displayed.
Select one of the options on the filter list. The selected option appears in the filter bar.
Click next to the option in the filter bar and start typing. Values that match are provided on a list. Select a value from the list.
Click a candidate service from the list of potential services.
When you click an entry, the following fields are filled in for you:
The display name is set to the name the entry in the list. You can change this value.
A block of JSON code for the configuration of the new service is generated from the candidate. Do not change this value.
Click Submit. When your service is created, a Success notice is displayed.
Use the API to create a service
You can also create services using the SLO API, which is part of the Cloud Monitoring API.
To create a service programmatically, post a configuration object like one of
the following to the services.create
method:
GKE namespace
Use the GkeNamespace
structure, for example:
{ "displayName": "test-kube-namespace", "gkeNamespace": { "location": "us-central1-c", "clusterName": "cluster-1", "namespaceName": "test-kube-namespace" } }
GKE service
Use the GkeService
structure, for example:
{ "displayName": "test-kube-service", "gkeService": { "location": "us-central1-c", "clusterName": "cluster-1", "namespaceName": "kube-system", "serviceName": "test-kube-service" } }
GKE workload
Use the GkeWorkload
structure, for example:
{ "displayName": "frontend-a", "gkeWorkload": { "location": "us-central1-b", "clusterName": "cluster-2", "namespaceName": "default", "topLevelControllerType": "Deployment", "topLevelControllerName": "frontend-a" } }
Cloud Run
Use the CloudRun
structure, for example:
{ "displayName": "test-cloudrun-service", "cloudRun": { "serviceName": "test-cloudrun-service", "location": "us-central1" } }
Cloud Service Mesh
Use the MeshIstio
structure, for example:
{ "displayName": "test-mesh-istio-service", "meshIstio": { "meshUid": "mesh-identifier" "serviceName": "test-mesh-istio-service", "serviceNamespace": "default" } }
Istio on GKE
Use the clusterIstio
structure, for example:
{ "displayName": "test-cluster-istio-service", "clusterIstio": { "serviceName": "test-cloud-service", "clusterName": "cluster-2", "serviceNamespace": "default", "location": "us-central1" } }
App Engine
Use the AppEngine
structure, for example:
{ "displayName": "test-mesh-istio-service", "appEngine": { ""moduleId": "id-of-the-service" } }
For more information about managing services programmatically, see the following documents:
Create a custom service
When no other service type meets your needs, create a custom service. With a custom service, you can arbitrarily group SLOs together in a way that is meaningful for your environment or create SLOs on business metrics that don't correspond to an existing microservice.
Use the Google Cloud console to create a custom service
To define a custom service by using the Google Cloud console, do the following:
Click Define service on the Services Overview page to bring up the Define service pane.
Select Custom Service.
Enter a display name for your custom service.
Click Submit. When your service is created, a Success notice is displayed.
Use the API to create a custom service
To define a custom service by using the SLO API,
post a Custom
configuration object like the following
to the services.create
method:
{ "displayName": "hello-world-service", "custom": {} }
For more information about managing services programmatically, see Working with the API.
What's next
After you identify or create a new service, you can do the following:
- Create an SLO for your new service. You must define at least one SLO for your new service for the service to be useful. For more information, see Creating an SLO.
- Go to the dashboard for your new service. For a new service, the dashboard is empty, but you can define SLOs from the dashboard. For more information, see Using microservice dashboards.