コード例 #1
0
 /// <summary>
 /// Executes the logs query.
 /// </summary>
 /// <param name="workspaceId">The workspace id to include in the query (<c>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</c>).</param>
 /// <param name="query">The Kusto query to execute.</param>
 /// <param name="timeRange">The timespan over which to query data. Logs will be filtered to include entries produced starting at <c>Now - timeSpan</c>. </param>
 /// <param name="options">The <see cref="LogsQueryOptions"/> to configure the query.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> to use.</param>
 /// <returns>The <see cref="LogsQueryResult"/> with the query results.</returns>
 public virtual async Task <Response <LogsQueryResult> > QueryWorkspaceAsync(string workspaceId, string query, QueryTimeRange timeRange, LogsQueryOptions options = null, CancellationToken cancellationToken = default)
 {
     using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(LogsQueryClient)}.{nameof(QueryWorkspace)}");
     scope.Start();
     try
     {
         return(await ExecuteAsync(workspaceId, query, timeRange, options, true, cancellationToken).ConfigureAwait(false));
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
コード例 #2
0
 /// <summary>
 /// Executes the logs query.
 /// </summary>
 /// <param name="workspaceId">The workspace id to include in the query (<c>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</c>).</param>
 /// <param name="query">The Kusto query to execute.</param>
 /// <param name="timeRange">The timespan over which to query data. Logs will be filtered to include entries produced starting at <c>Now - timeSpan</c>. </param>
 /// <param name="options">The <see cref="LogsQueryOptions"/> to configure the query.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> to use.</param>
 /// <returns>The <see cref="LogsQueryResult"/> containing the query results.</returns>
 public virtual Response <LogsQueryResult> Query(string workspaceId, string query, QueryTimeRange timeRange, LogsQueryOptions options = null, CancellationToken cancellationToken = default)
 {
     using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(LogsQueryClient)}.{nameof(Query)}");
     scope.Start();
     try
     {
         return(ExecuteAsync(workspaceId, query, timeRange, options, false, cancellationToken).EnsureCompleted());
     }
     catch (Exception e)
     {
         scope.Failed(e);
         throw;
     }
 }
コード例 #3
0
        /// <summary>
        /// Executes the logs query. Deserializes the result into a strongly typed model class or a primitive type if the query returns a single column.
        ///
        /// Example of querying a model:
        /// <example snippet="Snippet:QueryLogsAsModelCall">
        /// <code language="csharp">
        /// Response&lt;IReadOnlyList&lt;MyLogEntryModel&gt;&gt; response = await client.QueryWorkspaceAsync&lt;MyLogEntryModel&gt;(
        ///     workspaceId,
        ///     &quot;AzureActivity | summarize Count = count() by ResourceGroup | top 10 by Count&quot;,
        ///     new QueryTimeRange(TimeSpan.FromDays(1)));
        /// </code>
        /// </example>
        ///
        /// Example of querying a primitive:
        /// <example snippet="Snippet:QueryLogsAsPrimitiveCall">
        /// <code language="csharp">
        /// Response&lt;IReadOnlyList&lt;string&gt;&gt; response = await client.QueryWorkspaceAsync&lt;string&gt;(
        ///     workspaceId,
        ///     &quot;AzureActivity | summarize Count = count() by ResourceGroup | top 10 by Count | project ResourceGroup&quot;,
        ///     new QueryTimeRange(TimeSpan.FromDays(1)));
        /// </code>
        /// </example>
        /// </summary>
        /// <param name="workspaceId">The workspace id to include in the query (<c>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</c>).</param>
        /// <param name="query">The Kusto query to execute.</param>
        /// <param name="timeRange">The timespan over which to query data. Logs will be filtered to include entries produced starting at <c>Now - timeSpan</c>. </param>
        /// <param name="options">The <see cref="LogsQueryOptions"/> to configure the query.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> to use.</param>
        /// <returns>Query results mapped to a type <typeparamref name="T"/>.</returns>
        public virtual async Task <Response <IReadOnlyList <T> > > QueryWorkspaceAsync <T>(string workspaceId, string query, QueryTimeRange timeRange, LogsQueryOptions options = null, CancellationToken cancellationToken = default)
        {
            Response <LogsQueryResult> response = await QueryWorkspaceAsync(workspaceId, query, timeRange, options, cancellationToken).ConfigureAwait(false);

            return(Response.FromValue(RowBinder.Shared.BindResults <T>(response.Value.AllTables), response.GetRawResponse()));
        }
コード例 #4
0
        /// <summary>
        /// Executes the logs query. Deserializes the result into a strongly typed model class or a primitive type if the query returns a single column.
        ///
        /// Example of querying a model:
        /// <example snippet="Snippet:QueryLogsAsModelCall">
        /// <code language="csharp">
        /// Response&lt;IReadOnlyList&lt;MyLogEntryModel&gt;&gt; response = await client.QueryAsync&lt;MyLogEntryModel&gt;(
        ///     workspaceId,
        ///     &quot;AzureActivity | summarize Count = count() by ResourceGroup | top 10 by Count&quot;,
        ///     new QueryTimeRange(TimeSpan.FromDays(1)));
        /// </code>
        /// </example>
        ///
        /// Example of querying a primitive:
        /// <example snippet="Snippet:QueryLogsAsPrimitiveCall">
        /// <code language="csharp">
        /// Response&lt;IReadOnlyList&lt;string&gt;&gt; response = await client.QueryAsync&lt;string&gt;(
        ///     workspaceId,
        ///     &quot;AzureActivity | summarize Count = count() by ResourceGroup | top 10 by Count | project ResourceGroup&quot;,
        ///     new QueryTimeRange(TimeSpan.FromDays(1)));
        /// </code>
        /// </example>
        /// </summary>
        /// <param name="workspaceId">The workspace id to include in the query (<c>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</c>).</param>
        /// <param name="query">The Kusto query to execute.</param>
        /// <param name="timeRange">The timespan over which to query data. Logs will be filtered to include entries produced starting at <c>Now - timeSpan</c>. </param>
        /// <param name="options">The <see cref="LogsQueryOptions"/> to configure the query.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> to use.</param>
        /// <returns>Query results mapped to a type <typeparamref name="T"/>.</returns>
        public virtual Response <IReadOnlyList <T> > Query <T>(string workspaceId, string query, QueryTimeRange timeRange, LogsQueryOptions options = null, CancellationToken cancellationToken = default)
        {
            Response <LogsQueryResult> response = Query(workspaceId, query, timeRange, options, cancellationToken);

            return(Response.FromValue(RowBinder.Shared.BindResults <T>(response.Value.AllTables), response.GetRawResponse()));
        }