public abstract class QueryServiceClient
Reference documentation and code samples for the Google Cloud Monitoring v3 API class QueryServiceClient.
QueryService client wrapper, for convenient use.
Derived Types
Namespace
Google.Cloud.Monitoring.V3Assembly
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 | |
---|---|
Type | Description |
string |
DefaultScopes
public static IReadOnlyList<string> DefaultScopes { get; }
The default QueryService scopes.
Property Value | |
---|---|
Type | Description |
IReadOnlyListstring |
The default QueryService scopes are:
GrpcClient
public virtual QueryService.QueryServiceClient GrpcClient { get; }
The underlying gRPC QueryService client
Property Value | |
---|---|
Type | Description |
QueryServiceQueryServiceClient |
ServiceMetadata
public static ServiceMetadata ServiceMetadata { get; }
The service metadata associated with this client type.
Property Value | |
---|---|
Type | Description |
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 | |
---|---|
Type | Description |
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 | |
---|---|
Name | Description |
cancellationToken |
CancellationToken The CancellationToken to use while creating the client. |
Returns | |
---|---|
Type | Description |
TaskQueryServiceClient |
The task representing the created QueryServiceClient. |
QueryTimeSeries(QueryTimeSeriesRequest, CallSettings)
[Obsolete]
public virtual PagedEnumerable<QueryTimeSeriesResponse, TimeSeriesData> QueryTimeSeries(QueryTimeSeriesRequest request, CallSettings callSettings = null)
Queries time series by using Monitoring Query Language (MQL). We recommend using PromQL instead of MQL. For more information about the status of MQL, see the MQL deprecation notice.
Parameters | |
---|---|
Name | Description |
request |
QueryTimeSeriesRequest The request object containing all of the parameters for the API call. |
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
PagedEnumerableQueryTimeSeriesResponseTimeSeriesData |
A pageable sequence of TimeSeriesData resources. |
// Create client
QueryServiceClient queryServiceClient = QueryServiceClient.Create();
// Initialize request argument(s)
#pragma warning disable CS0612
QueryTimeSeriesRequest request = new QueryTimeSeriesRequest { };
#pragma warning restore CS0612
// Make the request
#pragma warning disable CS0612
PagedEnumerable<QueryTimeSeriesResponse, TimeSeriesData> response = queryServiceClient.QueryTimeSeries(request);
#pragma warning restore CS0612
// 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
#pragma warning disable CS0612
foreach (QueryTimeSeriesResponse page in response.AsRawResponses())
#pragma warning restore CS0612
{
// 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)
[Obsolete]
public virtual PagedAsyncEnumerable<QueryTimeSeriesResponse, TimeSeriesData> QueryTimeSeriesAsync(QueryTimeSeriesRequest request, CallSettings callSettings = null)
Queries time series by using Monitoring Query Language (MQL). We recommend using PromQL instead of MQL. For more information about the status of MQL, see the MQL deprecation notice.
Parameters | |
---|---|
Name | Description |
request |
QueryTimeSeriesRequest The request object containing all of the parameters for the API call. |
callSettings |
CallSettings If not null, applies overrides to this RPC call. |
Returns | |
---|---|
Type | Description |
PagedAsyncEnumerableQueryTimeSeriesResponseTimeSeriesData |
A pageable asynchronous sequence of TimeSeriesData resources. |
// Create client
QueryServiceClient queryServiceClient = await QueryServiceClient.CreateAsync();
// Initialize request argument(s)
#pragma warning disable CS0612
QueryTimeSeriesRequest request = new QueryTimeSeriesRequest { };
#pragma warning restore CS0612
// Make the request
#pragma warning disable CS0612
PagedAsyncEnumerable<QueryTimeSeriesResponse, TimeSeriesData> response = queryServiceClient.QueryTimeSeriesAsync(request);
#pragma warning restore CS0612
// 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
#pragma warning disable CS0612
await response.AsRawResponses().ForEachAsync((QueryTimeSeriesResponse page) =>
#pragma warning restore CS0612
{
// 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 | |
---|---|
Type | Description |
Task |
A task representing the asynchronous shutdown operation. |
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.