ServiceMonitoringServiceClient

ServiceMonitoringServiceClient

The Stackdriver Monitoring Service-Oriented Monitoring API has endpoints for managing and querying aspects of a workspace's services. These include the Service's monitored resources, its Service-Level Objectives, and a taxonomy of categorized Health Metrics.

Constructor

new ServiceMonitoringServiceClient(optionsopt)

Construct an instance of ServiceMonitoringServiceClient.

Parameters:
Name Type Attributes Description
options object <optional>

The configuration object. See the subsequent parameters for more details.

Properties
Name Type Attributes Description
credentials object <optional>

Credentials object.

Properties
Name Type Attributes Description
client_email string <optional>
private_key string <optional>
email string <optional>

Account email address. Required when using a .pem or .p12 keyFilename.

keyFilename string <optional>

Full path to the a .json, .pem, or .p12 key downloaded from the Google Developers Console. If you provide a path to a JSON file, the projectId option below is not necessary. NOTE: .pem and .p12 require you to specify options.email as well.

port number <optional>

The port on which to connect to the remote host.

projectId string <optional>

The project ID from the Google Developer's Console, e.g. 'grape-spaceship-123'. We will also check the environment variable GCLOUD_PROJECT for your project ID. If your app is running in an environment which supports Application Default Credentials, your project ID will be detected automatically.

promise function <optional>

Custom promise module to use instead of native Promises.

apiEndpoint string <optional>

The domain name of the API remote host.

Source:

Members

(static) apiEndpoint

The DNS address for this API service - same as servicePath(), exists for compatibility reasons.

Source:

(static) port

The port for this API service.

Source:

(static) scopes

The scopes needed to make gRPC calls for every method defined in this service.

Source:

(static) servicePath

The DNS address for this API service.

Source:

Methods

createService(request, optionsopt, callbackopt) → {Promise}

Create a Service.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Resource name of the parent workspace. Of the form projects/{project_id}.

service Object

The Service to create.

This object should have the same structure as Service

serviceId string <optional>

Optional. The Service id to use for this Service. If omitted, an id will be generated instead. Must match the pattern [a-z0-9-]+

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing Service.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.ServiceMonitoringServiceClient({
  // optional auth parameters.
});

const formattedParent = client.projectPath('[PROJECT]');
const service = {};
const request = {
  parent: formattedParent,
  service: service,
};
client.createService(request)
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

createServiceLevelObjective(request, optionsopt, callbackopt) → {Promise}

Create a ServiceLevelObjective for the given Service.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Resource name of the parent Service. Of the form projects/{project_id}/services/{service_id}.

serviceLevelObjective Object

The ServiceLevelObjective to create. The provided name will be respected if no ServiceLevelObjective exists with this name.

This object should have the same structure as ServiceLevelObjective

serviceLevelObjectiveId string <optional>

Optional. The ServiceLevelObjective id to use for this ServiceLevelObjective. If omitted, an id will be generated instead. Must match the pattern [a-z0-9-]+

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing ServiceLevelObjective.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.ServiceMonitoringServiceClient({
  // optional auth parameters.
});

const formattedParent = client.servicePath('[PROJECT]', '[SERVICE]');
const serviceLevelObjective = {};
const request = {
  parent: formattedParent,
  serviceLevelObjective: serviceLevelObjective,
};
client.createServiceLevelObjective(request)
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

deleteService(request, optionsopt, callbackopt) → {Promise}

Soft delete this Service.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Resource name of the Service to delete. Of the form projects/{project_id}/service/{service_id}.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.ServiceMonitoringServiceClient({
  // optional auth parameters.
});

const formattedName = client.servicePath('[PROJECT]', '[SERVICE]');
client.deleteService({name: formattedName}).catch(err => {
  console.error(err);
});

deleteServiceLevelObjective(request, optionsopt, callbackopt) → {Promise}

Delete the given ServiceLevelObjective.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Resource name of the ServiceLevelObjective to delete. Of the form projects/{project_id}/services/{service_id}/serviceLevelObjectives/{slo_name}.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.ServiceMonitoringServiceClient({
  // optional auth parameters.
});

const formattedName = client.serviceLevelObjectivePath('[PROJECT]', '[SERVICE]', '[SERVICE_LEVEL_OBJECTIVE]');
client.deleteServiceLevelObjective({name: formattedName}).catch(err => {
  console.error(err);
});

getProjectId(callback)

Return the project ID used by this class.

Parameters:
Name Type Description
callback function

the callback to be called with the current project Id.

Source:

getService(request, optionsopt, callbackopt) → {Promise}

Get the named Service.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Description
name string

Resource name of the Service. Of the form projects/{project_id}/services/{service_id}.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing Service.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.ServiceMonitoringServiceClient({
  // optional auth parameters.
});

const formattedName = client.servicePath('[PROJECT]', '[SERVICE]');
client.getService({name: formattedName})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

getServiceLevelObjective(request, optionsopt, callbackopt) → {Promise}

Get a ServiceLevelObjective by name.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
name string

Resource name of the ServiceLevelObjective to get. Of the form projects/{project_id}/services/{service_id}/serviceLevelObjectives/{slo_name}.

view number <optional>

View of the ServiceLevelObjective to return. If DEFAULT, return the ServiceLevelObjective as originally defined. If EXPLICIT and the ServiceLevelObjective is defined in terms of a BasicSli, replace the BasicSli with a RequestBasedSli spelling out how the SLI is computed.

The number should be among the values of View

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing ServiceLevelObjective.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.ServiceMonitoringServiceClient({
  // optional auth parameters.
});

const formattedName = client.serviceLevelObjectivePath('[PROJECT]', '[SERVICE]', '[SERVICE_LEVEL_OBJECTIVE]');
client.getServiceLevelObjective({name: formattedName})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

listServiceLevelObjectives(request, optionsopt, callbackopt) → {Promise}

List the ServiceLevelObjectives for the given Service.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Resource name of the parent Service. Of the form projects/{project_id}/services/{service_id}.

filter string <optional>

A filter specifying what ServiceLevelObjectives to return.

pageSize number <optional>

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

view number <optional>

View of the ServiceLevelObjectives to return. If DEFAULT, return each ServiceLevelObjective as originally defined. If EXPLICIT and the ServiceLevelObjective is defined in terms of a BasicSli, replace the BasicSli with a RequestBasedSli spelling out how the SLI is computed.

The number should be among the values of View

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is Array of ServiceLevelObjective.

When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListServiceLevelObjectivesResponse.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.ServiceMonitoringServiceClient({
  // optional auth parameters.
});

// Iterate over all elements.
const formattedParent = client.servicePath('[PROJECT]', '[SERVICE]');

client.listServiceLevelObjectives({parent: formattedParent})
  .then(responses => {
    const resources = responses[0];
    for (const resource of resources) {
      // doThingsWith(resource)
    }
  })
  .catch(err => {
    console.error(err);
  });

// Or obtain the paged response.
const formattedParent = client.servicePath('[PROJECT]', '[SERVICE]');


const options = {autoPaginate: false};
const callback = responses => {
  // The actual resources in a response.
  const resources = responses[0];
  // The next request if the response shows that there are more responses.
  const nextRequest = responses[1];
  // The actual response object, if necessary.
  // const rawResponse = responses[2];
  for (const resource of resources) {
    // doThingsWith(resource);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listServiceLevelObjectives(nextRequest, options).then(callback);
  }
}
client.listServiceLevelObjectives({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listServiceLevelObjectivesStream(request, optionsopt) → {Stream}

Equivalent to listServiceLevelObjectives, but returns a NodeJS Stream object.

This fetches the paged responses for listServiceLevelObjectives continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Resource name of the parent Service. Of the form projects/{project_id}/services/{service_id}.

filter string <optional>

A filter specifying what ServiceLevelObjectives to return.

pageSize number <optional>

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

view number <optional>

View of the ServiceLevelObjectives to return. If DEFAULT, return each ServiceLevelObjective as originally defined. If EXPLICIT and the ServiceLevelObjective is defined in terms of a BasicSli, replace the BasicSli with a RequestBasedSli spelling out how the SLI is computed.

The number should be among the values of View

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

Source:
See:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.ServiceMonitoringServiceClient({
  // optional auth parameters.
});

const formattedParent = client.servicePath('[PROJECT]', '[SERVICE]');
client.listServiceLevelObjectivesStream({parent: formattedParent})
  .on('data', element => {
    // doThingsWith(element)
  }).on('error', err => {
    console.log(err);
  });

listServices(request, optionsopt, callbackopt) → {Promise}

List Services for this workspace.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Resource name of the parent Workspace. Of the form projects/{project_id}.

filter string <optional>

A filter specifying what Services to return. The filter currently supports the following fields:

  - `identifier_case`
  - `app_engine.module_id`
  - `cloud_endpoints.service`
  - `cluster_istio.location`
  - `cluster_istio.cluster_name`
  - `cluster_istio.service_namespace`
  - `cluster_istio.service_name`

identifier_case refers to which option in the identifier oneof is populated. For example, the filter identifier_case = "CUSTOM" would match all services with a value for the custom field. Valid options are "CUSTOM", "APP_ENGINE", "CLOUD_ENDPOINTS", and "CLUSTER_ISTIO".

pageSize number <optional>

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is Array of Service.

When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListServicesResponse.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.ServiceMonitoringServiceClient({
  // optional auth parameters.
});

// Iterate over all elements.
const formattedParent = client.projectPath('[PROJECT]');

client.listServices({parent: formattedParent})
  .then(responses => {
    const resources = responses[0];
    for (const resource of resources) {
      // doThingsWith(resource)
    }
  })
  .catch(err => {
    console.error(err);
  });

// Or obtain the paged response.
const formattedParent = client.projectPath('[PROJECT]');


const options = {autoPaginate: false};
const callback = responses => {
  // The actual resources in a response.
  const resources = responses[0];
  // The next request if the response shows that there are more responses.
  const nextRequest = responses[1];
  // The actual response object, if necessary.
  // const rawResponse = responses[2];
  for (const resource of resources) {
    // doThingsWith(resource);
  }
  if (nextRequest) {
    // Fetch the next page.
    return client.listServices(nextRequest, options).then(callback);
  }
}
client.listServices({parent: formattedParent}, options)
  .then(callback)
  .catch(err => {
    console.error(err);
  });

listServicesStream(request, optionsopt) → {Stream}

Equivalent to listServices, but returns a NodeJS Stream object.

This fetches the paged responses for listServices continuously and invokes the callback registered for 'data' event for each element in the responses.

The returned object has 'end' method when no more elements are required.

autoPaginate option will be ignored.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
parent string

Resource name of the parent Workspace. Of the form projects/{project_id}.

filter string <optional>

A filter specifying what Services to return. The filter currently supports the following fields:

  - `identifier_case`
  - `app_engine.module_id`
  - `cloud_endpoints.service`
  - `cluster_istio.location`
  - `cluster_istio.cluster_name`
  - `cluster_istio.service_namespace`
  - `cluster_istio.service_name`

identifier_case refers to which option in the identifier oneof is populated. For example, the filter identifier_case = "CUSTOM" would match all services with a value for the custom field. Valid options are "CUSTOM", "APP_ENGINE", "CLOUD_ENDPOINTS", and "CLUSTER_ISTIO".

pageSize number <optional>

The maximum number of resources contained in the underlying API response. If page streaming is performed per-resource, this parameter does not affect the return value. If page streaming is performed per-page, this determines the maximum number of resources in a page.

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

Source:
See:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.ServiceMonitoringServiceClient({
  // optional auth parameters.
});

const formattedParent = client.projectPath('[PROJECT]');
client.listServicesStream({parent: formattedParent})
  .on('data', element => {
    // doThingsWith(element)
  }).on('error', err => {
    console.log(err);
  });

matchProjectFromProjectName(projectName) → {String}

Parse the projectName from a project resource.

Parameters:
Name Type Description
projectName String

A fully-qualified path representing a project resources.

Source:

matchProjectFromServiceLevelObjectiveName(serviceLevelObjectiveName) → {String}

Parse the serviceLevelObjectiveName from a service_level_objective resource.

Parameters:
Name Type Description
serviceLevelObjectiveName String

A fully-qualified path representing a service_level_objective resources.

Source:

matchProjectFromServiceName(serviceName) → {String}

Parse the serviceName from a service resource.

Parameters:
Name Type Description
serviceName String

A fully-qualified path representing a service resources.

Source:

matchServiceFromServiceLevelObjectiveName(serviceLevelObjectiveName) → {String}

Parse the serviceLevelObjectiveName from a service_level_objective resource.

Parameters:
Name Type Description
serviceLevelObjectiveName String

A fully-qualified path representing a service_level_objective resources.

Source:

matchServiceFromServiceName(serviceName) → {String}

Parse the serviceName from a service resource.

Parameters:
Name Type Description
serviceName String

A fully-qualified path representing a service resources.

Source:

matchServiceLevelObjectiveFromServiceLevelObjectiveName(serviceLevelObjectiveName) → {String}

Parse the serviceLevelObjectiveName from a service_level_objective resource.

Parameters:
Name Type Description
serviceLevelObjectiveName String

A fully-qualified path representing a service_level_objective resources.

Source:

projectPath(project) → {String}

Return a fully-qualified project resource name string.

Parameters:
Name Type Description
project String
Source:

serviceLevelObjectivePath(project, service, serviceLevelObjective) → {String}

Return a fully-qualified service_level_objective resource name string.

Parameters:
Name Type Description
project String
service String
serviceLevelObjective String
Source:

servicePath(project, service) → {String}

Return a fully-qualified service resource name string.

Parameters:
Name Type Description
project String
service String
Source:

updateService(request, optionsopt, callbackopt) → {Promise}

Update this Service.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
service Object

The Service to draw updates from. The given name specifies the resource to update.

This object should have the same structure as Service

updateMask Object <optional>

A set of field paths defining which fields to use for the update.

This object should have the same structure as FieldMask

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing Service.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.ServiceMonitoringServiceClient({
  // optional auth parameters.
});

const service = {};
client.updateService({service: service})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });

updateServiceLevelObjective(request, optionsopt, callbackopt) → {Promise}

Update the given ServiceLevelObjective.

Parameters:
Name Type Attributes Description
request Object

The request object that will be sent.

Properties
Name Type Attributes Description
serviceLevelObjective Object

The ServiceLevelObjective to draw updates from. The given name specifies the resource to update.

This object should have the same structure as ServiceLevelObjective

updateMask Object <optional>

A set of field paths defining which fields to use for the update.

This object should have the same structure as FieldMask

options Object <optional>

Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details.

callback function <optional>

The function which will be called with the result of the API call.

The second parameter to the callback is an object representing ServiceLevelObjective.

Source:
Example
const monitoring = require('@google-cloud/monitoring');

const client = new monitoring.v3.ServiceMonitoringServiceClient({
  // optional auth parameters.
});

const serviceLevelObjective = {};
client.updateServiceLevelObjective({serviceLevelObjective: serviceLevelObjective})
  .then(responses => {
    const response = responses[0];
    // doThingsWith(response)
  })
  .catch(err => {
    console.error(err);
  });