Google Cloud Monitoring v3 API - Class QueryServiceClient (3.8.0)

public abstract class QueryServiceClient

Reference documentation and code samples for the Google Cloud Monitoring v3 API class QueryServiceClient.

QueryService client wrapper, for convenient use.

Inheritance

object > QueryServiceClient

Derived Types

Namespace

Google.Cloud.Monitoring.V3

Assembly

Google.Cloud.Monitoring.V3.dll

Remarks

The QueryService API is used to manage time series data in Cloud Monitoring. Time series data is a collection of data points that describes the time-varying values of a metric.

Properties

DefaultEndpoint

public static string DefaultEndpoint { get; }

The default endpoint for the QueryService service, which is a host of "monitoring.googleapis.com" and a port of 443.

Property Value
TypeDescription
string

DefaultScopes

public static IReadOnlyList<string> DefaultScopes { get; }

The default QueryService scopes.

Property Value
TypeDescription
IReadOnlyListstring
Remarks

GrpcClient

public virtual QueryService.QueryServiceClient GrpcClient { get; }

The underlying gRPC QueryService client

Property Value
TypeDescription
QueryServiceQueryServiceClient

ServiceMetadata

public static ServiceMetadata ServiceMetadata { get; }

The service metadata associated with this client type.

Property Value
TypeDescription
ServiceMetadata

Methods

Create()

public static QueryServiceClient Create()

Synchronously creates a QueryServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use QueryServiceClientBuilder.

Returns
TypeDescription
QueryServiceClient

The created QueryServiceClient.

CreateAsync(CancellationToken)

public static Task<QueryServiceClient> CreateAsync(CancellationToken cancellationToken = default)

Asynchronously creates a QueryServiceClient using the default credentials, endpoint and settings. To specify custom credentials or other settings, use QueryServiceClientBuilder.

Parameter
NameDescription
cancellationTokenCancellationToken

The CancellationToken to use while creating the client.

Returns
TypeDescription
TaskQueryServiceClient

The task representing the created QueryServiceClient.

QueryTimeSeries(QueryTimeSeriesRequest, CallSettings)

public virtual PagedEnumerable<QueryTimeSeriesResponse, TimeSeriesData> QueryTimeSeries(QueryTimeSeriesRequest request, CallSettings callSettings = null)

Queries time series using Monitoring Query Language.

Parameters
NameDescription
requestQueryTimeSeriesRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedEnumerableQueryTimeSeriesResponseTimeSeriesData

A pageable sequence of TimeSeriesData resources.

Example
// Create client
QueryServiceClient queryServiceClient = QueryServiceClient.Create();
// Initialize request argument(s)
QueryTimeSeriesRequest request = new QueryTimeSeriesRequest { Name = "", Query = "", };
// Make the request
PagedEnumerable<QueryTimeSeriesResponse, TimeSeriesData> response = queryServiceClient.QueryTimeSeries(request);

// Iterate over all response items, lazily performing RPCs as required
foreach (TimeSeriesData item in response)
{
    // Do something with each item
    Console.WriteLine(item);
}

// Or iterate over pages (of server-defined size), performing one RPC per page
foreach (QueryTimeSeriesResponse page in response.AsRawResponses())
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (TimeSeriesData item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
}

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<TimeSeriesData> singlePage = response.ReadPage(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (TimeSeriesData item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

QueryTimeSeriesAsync(QueryTimeSeriesRequest, CallSettings)

public virtual PagedAsyncEnumerable<QueryTimeSeriesResponse, TimeSeriesData> QueryTimeSeriesAsync(QueryTimeSeriesRequest request, CallSettings callSettings = null)

Queries time series using Monitoring Query Language.

Parameters
NameDescription
requestQueryTimeSeriesRequest

The request object containing all of the parameters for the API call.

callSettingsCallSettings

If not null, applies overrides to this RPC call.

Returns
TypeDescription
PagedAsyncEnumerableQueryTimeSeriesResponseTimeSeriesData

A pageable asynchronous sequence of TimeSeriesData resources.

Example
// Create client
QueryServiceClient queryServiceClient = await QueryServiceClient.CreateAsync();
// Initialize request argument(s)
QueryTimeSeriesRequest request = new QueryTimeSeriesRequest { Name = "", Query = "", };
// Make the request
PagedAsyncEnumerable<QueryTimeSeriesResponse, TimeSeriesData> response = queryServiceClient.QueryTimeSeriesAsync(request);

// Iterate over all response items, lazily performing RPCs as required
await response.ForEachAsync((TimeSeriesData item) =>
{
    // Do something with each item
    Console.WriteLine(item);
});

// Or iterate over pages (of server-defined size), performing one RPC per page
await response.AsRawResponses().ForEachAsync((QueryTimeSeriesResponse page) =>
{
    // Do something with each page of items
    Console.WriteLine("A page of results:");
    foreach (TimeSeriesData item in page)
    {
        // Do something with each item
        Console.WriteLine(item);
    }
});

// Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
int pageSize = 10;
Page<TimeSeriesData> singlePage = await response.ReadPageAsync(pageSize);
// Do something with the page of items
Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
foreach (TimeSeriesData item in singlePage)
{
    // Do something with each item
    Console.WriteLine(item);
}
// Store the pageToken, for when the next page is required.
string nextPageToken = singlePage.NextPageToken;

ShutdownDefaultChannelsAsync()

public static Task ShutdownDefaultChannelsAsync()

Shuts down any channels automatically created by Create() and CreateAsync(CancellationToken). Channels which weren't automatically created are not affected.

Returns
TypeDescription
Task

A task representing the asynchronous shutdown operation.

Remarks

After calling this method, further calls to Create() and CreateAsync(CancellationToken) will create new channels, which could in turn be shut down by another call to this method.