/// <summary> /// Executes a query to Kusto for Fields Caps. /// </summary> /// <param name="indexName">Index name.</param> /// <returns>An object with the field caps.</returns> public async Task <FieldCapabilityResponse> GetFieldCapsAsync(string indexName) { var response = new FieldCapabilityResponse(); try { Logger.LogDebug("Getting schema for table '{@indexName}'", indexName); var(databaseName, tableName) = KustoDatabaseTableNames.FromElasticIndexName(indexName, Kusto.DefaultDatabaseName); string kustoCommand = $".show {KustoQLOperators.Databases} {KustoQLOperators.Schema} | {KustoQLOperators.Where} TableName=='{tableName}' {KustoQLOperators.And} DatabaseName=='{databaseName}' {KustoQLOperators.And} ColumnName!='' | {KustoQLOperators.Project} ColumnName, ColumnType"; using IDataReader kustoResults = await Kusto.ExecuteControlCommandAsync(kustoCommand, RequestContext); MapFieldCaps(kustoResults, response); if (response.Fields.Count > 0) { return(response); } Logger.LogDebug("Getting schema for function '{@indexName}'", indexName); string functionQuery = $"{tableName} | {KustoQLOperators.GetSchema} | project ColumnName, ColumnType=DataType"; var functionQueryData = new QueryData(functionQuery, tableName, null, null); var(timeTaken, reader) = await Kusto.ExecuteQueryAsync(functionQueryData, RequestContext); MapFieldCaps(reader, response); } catch (Exception ex) { Logger.LogError(ex, "Error while executing GetFieldCaps."); throw; } return(response); }
private void FinalizeKusto() { if (Config.IsKustoConfigured() && !Kusto.Complete()) { Log.Warning($"there may have been errors during kusto import. {Config.CacheLocation} has *not* been deleted."); } else if (Config.IsKustoConfigured()) { Log.Min($"https://dataexplorer.azure.com/clusters/{Kusto.Endpoint.ClusterName}/databases/{Kusto.Endpoint.DatabaseName}"); } }
public void FinalizeKusto() { if (Config.IsKustoConfigured() && !Kusto.Complete()) { Log.Warning($"there may have been errors during kusto import. {Config.CacheLocation} has *not* been deleted."); } else if (Config.IsKustoConfigured()) { Log.Last($"{DataExplorer}/clusters/{Kusto.Endpoint.ClusterName}/databases/{Kusto.Endpoint.DatabaseName}", ConsoleColor.Cyan); } }
public void QueueForIngest(FileObject fileObject) { Log.Debug("enter"); if (Config.IsKustoConfigured()) { TaskManager.QueueTaskAction(() => Kusto.AddFile(fileObject)); } if (Config.IsLogAnalyticsConfigured()) { TaskManager.QueueTaskAction(() => LogAnalytics.AddFile(fileObject)); } }
/// <summary> /// Executes a query to Kusto for Index List. /// Searches for all tables and all functions that match the index name pattern. /// </summary> /// <param name="indexName">Index name pattern, e.g. "*", "orders*", "orders".</param> /// <returns>A list of Indexes matching the given name pattern.</returns> public async Task <IndexListResponseElement> GetIndexListAsync(string indexName) { var response = new IndexListResponseElement(); try { Logger.LogDebug("Listing tables matching '{@indexName}'", indexName); var(databaseName, tableName) = KustoDatabaseTableNames.FromElasticIndexName(indexName, Kusto.DefaultDatabaseName); string readTablesCommand = $".show {KustoQLOperators.Databases} {KustoQLOperators.Schema} | {KustoQLOperators.Where} TableName != '' | {KustoQLOperators.Distinct} TableName, DatabaseName | {KustoQLOperators.Search} TableName: '{tableName}' | {KustoQLOperators.Search} DatabaseName: '{databaseName}' | {KustoQLOperators.Project} strcat(DatabaseName, \"{KustoDatabaseTableNames.Separator}\", TableName)"; using IDataReader kustoTables = await Kusto.ExecuteControlCommandAsync(readTablesCommand, RequestContext); if (kustoTables != null) { MapIndexList(kustoTables, response); } Logger.LogDebug("Listing functions matching '{@indexName}'", indexName); var defaultDb = Kusto.DefaultDatabaseName; string readFunctionsCommand = $".show {KustoQLOperators.Functions} | {KustoQLOperators.Where} Parameters == '()' | {KustoQLOperators.Distinct} Name | {KustoQLOperators.Search} Name: '{tableName}' | {KustoQLOperators.Project} strcat(\"{defaultDb}\", \"{KustoDatabaseTableNames.Separator}\", Name)"; using IDataReader kustoFunctions = await Kusto.ExecuteControlCommandAsync(readFunctionsCommand, RequestContext); if (kustoFunctions != null) { MapIndexList(kustoFunctions, response); } } catch (Exception ex) { Logger.LogError(ex, "Error while executing GetIndexList."); throw; } return(response); }