如何在 Kusto SDK 上执行清除命令
How to execute purge command on Kusto SDK
我正在尝试 运行 使用 Kusto C# SDK 清除命令以进行测试
我正在执行 .show purges
据我所知,如果我可以执行此命令,那么我也可以执行其他清除命令
我使用了带有摄取前缀的连接字符串(如本回答https://github.com/Azure/azure-kusto-python/issues/165),但我无法使用清除命令
public AdxConnection()
{
// https://ingest-mycluster.myregion.kusto.windows.net
var connStringBuilder = new KustoConnectionStringBuilder(_connectionString)
.WithAadApplicationKeyAuthentication(_clientId, _clientSecret, _tenantId);
_adminProvider = KustoClientFactory.CreateCslAdminProvider(connStringBuilder);
}
public async Task Purge()
{
var purgeCommand = CslCommandGenerator.GenerateShowPurgeCommand(_database);
await _adminProvider.ExecuteControlCommandAsync(_database, purgeCommand);
}
这是 Kusto 的回复
Syntax error: Query could not be parsed: {
"error": {
"code": "BadRequest_SyntaxError",
"message": "Request is invalid and cannot be executed.",
"@type": "Kusto.Data.Exceptions.SyntaxException",
"@message": "Syntax error: Query could not be parsed: . Query: '.show database environment1 purge operations'",
"@context": {
"timestamp": "2020-02-21T11:04:52.4907001Z",
"serviceAlias": "INGEST-DATAMTE",
"machineName": "KDataMana000000",
"processName": "Kusto.WinSvc.DM.Svc",
"processId": 9420,
"threadId": 4368,
"appDomainName": "Kusto.WinSvc.DM.Svc.exe",
"clientRequestId": "KD2RunCommand;7ee3cb62-5c82-4a6d-9885-bc56a2339a15",
"activityId": "4058bf27-af5c-4bab-8d6f-c7c41473c89a",
"subActivityId": "3689c292-91a6-4595-8e60-663a4a59a370",
"activityType": "P.WCF.Service.ExecuteControlCommandInternal..IAdminClientServiceCommunicationContract",
"parentActivityId": "1a9d19bf-15fe-4c43-a154-9e47e3fa7a26",
"activityStack": "(Activity stack: CRID=KD2RunCommand;7ee3cb62-5c82-4a6d-9885-bc56a2339a15 ARID=4058bf27-af5c-4bab-8d6f-c7c41473c89a > DN.Admin.Client.ExecuteControlCommand/1a9d19bf-15fe-4c43-a154-9e47e3fa7a26 > P.WCF.Service.ExecuteControlCommandInternal..IAdminClientServiceCommunicationContract/3689c292-91a6-4595-8e60-663a4a59a370)"
},
"@permanent": true
}
}. Query: '.show database environment1 purge operations'
*编辑:
将 GenerateShowPurgeCommand
替换为 GenerateDmPurgesShowCommand
即可解决问题。但是,当 运行ning GenerateDmPurgeTableRecordsFirstPhase
我遇到另一个错误
InternalServiceError (520-UnknownError): {
"error": {
"code": "Internal service error",
"message": "Request aborted due to an internal service error.",
"@type": "Kusto.Common.Svc.Exceptions.AdminCommandInvalidOperationException",
"@message": "An admin command cannot be executed due to an invalid state: State='Operation PurgeTableRecords requires feature flag EnabledForPurge set on Engine'",
"@context": {
"timestamp": "2020-02-24T01:58:01.5764072Z",
"serviceAlias": "INGEST-DATAMTE",
"machineName": "KDataMana000000",
"processName": "Kusto.WinSvc.DM.Svc",
"processId": 5760,
"threadId": 6100,
"appDomainName": "Kusto.WinSvc.DM.Svc.exe",
"clientRequestId": "KD2RunCommand;64439168-29e4-420e-b04a-07dccf11c5a4",
"activityId": "855d59ba-3de2-44b4-9cac-62fbe5f7a5a3",
"subActivityId": "5872fb41-7483-49bd-922c-1ae6104771fc",
"activityType": "DM.MonitoredCommand",
"parentActivityId": "c31fbc9a-8ae5-4cbf-9070-db5e39b8d5fa",
"activityStack": "(Activity stack: CRID=KD2RunCommand;64439168-29e4-420e-b04a-07dccf11c5a4 ARID=855d59ba-3de2-44b4-9cac-62fbe5f7a5a3 > DN.Admin.Client.ExecuteControlCommand/bf23f2c3-d82b-4cf0-9f2b-0bfd32d55bc5 > P.WCF.Service.ExecuteControlCommandInternal..IAdminClientServiceCommunicationContract/c31fbc9a-8ae5-4cbf-9070-db5e39b8d5fa > DM.MonitoredCommand/5872fb41-7483-49bd-922c-1ae6104771fc)"
},
"@permanent": false
}
}
我是否需要联系 Kusto 团队将 EnabledForPurge
设置为 true,或者我可以自己使用命令来完成?这不是我在文档中找到的内容。
操作 .show database environment1 purge operations
是一个应该在 "engine" 集群上执行的命令,在您的情况下意味着 DATAMTE(而不是摄取 DATAMTE)。
对于您的情况,您可能会发现 "DM" (INGEST-DATAME) 上的以下命令更有用:https://docs.microsoft.com/en-us/azure/kusto/concepts/data-purge#track-purge-operation-status
此命令通过在请求的时间段内指定操作 ID 来显示清除操作状态
更新问题的更新答案:您需要联系 Kusto 将您的集群列入白名单以进行清除。
我正在尝试 运行 使用 Kusto C# SDK 清除命令以进行测试
我正在执行 .show purges
据我所知,如果我可以执行此命令,那么我也可以执行其他清除命令
我使用了带有摄取前缀的连接字符串(如本回答https://github.com/Azure/azure-kusto-python/issues/165),但我无法使用清除命令
public AdxConnection()
{
// https://ingest-mycluster.myregion.kusto.windows.net
var connStringBuilder = new KustoConnectionStringBuilder(_connectionString)
.WithAadApplicationKeyAuthentication(_clientId, _clientSecret, _tenantId);
_adminProvider = KustoClientFactory.CreateCslAdminProvider(connStringBuilder);
}
public async Task Purge()
{
var purgeCommand = CslCommandGenerator.GenerateShowPurgeCommand(_database);
await _adminProvider.ExecuteControlCommandAsync(_database, purgeCommand);
}
这是 Kusto 的回复
Syntax error: Query could not be parsed: {
"error": {
"code": "BadRequest_SyntaxError",
"message": "Request is invalid and cannot be executed.",
"@type": "Kusto.Data.Exceptions.SyntaxException",
"@message": "Syntax error: Query could not be parsed: . Query: '.show database environment1 purge operations'",
"@context": {
"timestamp": "2020-02-21T11:04:52.4907001Z",
"serviceAlias": "INGEST-DATAMTE",
"machineName": "KDataMana000000",
"processName": "Kusto.WinSvc.DM.Svc",
"processId": 9420,
"threadId": 4368,
"appDomainName": "Kusto.WinSvc.DM.Svc.exe",
"clientRequestId": "KD2RunCommand;7ee3cb62-5c82-4a6d-9885-bc56a2339a15",
"activityId": "4058bf27-af5c-4bab-8d6f-c7c41473c89a",
"subActivityId": "3689c292-91a6-4595-8e60-663a4a59a370",
"activityType": "P.WCF.Service.ExecuteControlCommandInternal..IAdminClientServiceCommunicationContract",
"parentActivityId": "1a9d19bf-15fe-4c43-a154-9e47e3fa7a26",
"activityStack": "(Activity stack: CRID=KD2RunCommand;7ee3cb62-5c82-4a6d-9885-bc56a2339a15 ARID=4058bf27-af5c-4bab-8d6f-c7c41473c89a > DN.Admin.Client.ExecuteControlCommand/1a9d19bf-15fe-4c43-a154-9e47e3fa7a26 > P.WCF.Service.ExecuteControlCommandInternal..IAdminClientServiceCommunicationContract/3689c292-91a6-4595-8e60-663a4a59a370)"
},
"@permanent": true
}
}. Query: '.show database environment1 purge operations'
*编辑:
将 GenerateShowPurgeCommand
替换为 GenerateDmPurgesShowCommand
即可解决问题。但是,当 运行ning GenerateDmPurgeTableRecordsFirstPhase
我遇到另一个错误
InternalServiceError (520-UnknownError): {
"error": {
"code": "Internal service error",
"message": "Request aborted due to an internal service error.",
"@type": "Kusto.Common.Svc.Exceptions.AdminCommandInvalidOperationException",
"@message": "An admin command cannot be executed due to an invalid state: State='Operation PurgeTableRecords requires feature flag EnabledForPurge set on Engine'",
"@context": {
"timestamp": "2020-02-24T01:58:01.5764072Z",
"serviceAlias": "INGEST-DATAMTE",
"machineName": "KDataMana000000",
"processName": "Kusto.WinSvc.DM.Svc",
"processId": 5760,
"threadId": 6100,
"appDomainName": "Kusto.WinSvc.DM.Svc.exe",
"clientRequestId": "KD2RunCommand;64439168-29e4-420e-b04a-07dccf11c5a4",
"activityId": "855d59ba-3de2-44b4-9cac-62fbe5f7a5a3",
"subActivityId": "5872fb41-7483-49bd-922c-1ae6104771fc",
"activityType": "DM.MonitoredCommand",
"parentActivityId": "c31fbc9a-8ae5-4cbf-9070-db5e39b8d5fa",
"activityStack": "(Activity stack: CRID=KD2RunCommand;64439168-29e4-420e-b04a-07dccf11c5a4 ARID=855d59ba-3de2-44b4-9cac-62fbe5f7a5a3 > DN.Admin.Client.ExecuteControlCommand/bf23f2c3-d82b-4cf0-9f2b-0bfd32d55bc5 > P.WCF.Service.ExecuteControlCommandInternal..IAdminClientServiceCommunicationContract/c31fbc9a-8ae5-4cbf-9070-db5e39b8d5fa > DM.MonitoredCommand/5872fb41-7483-49bd-922c-1ae6104771fc)"
},
"@permanent": false
}
}
我是否需要联系 Kusto 团队将 EnabledForPurge
设置为 true,或者我可以自己使用命令来完成?这不是我在文档中找到的内容。
操作 .show database environment1 purge operations
是一个应该在 "engine" 集群上执行的命令,在您的情况下意味着 DATAMTE(而不是摄取 DATAMTE)。
对于您的情况,您可能会发现 "DM" (INGEST-DATAME) 上的以下命令更有用:https://docs.microsoft.com/en-us/azure/kusto/concepts/data-purge#track-purge-operation-status
此命令通过在请求的时间段内指定操作 ID 来显示清除操作状态
更新问题的更新答案:您需要联系 Kusto 将您的集群列入白名单以进行清除。