我正在尝试使用C#SDK使用过滤器列出Google Cloud Logging中的日志:
var LogClient = LoggingServiceV2Client.Create();
ListLogEntriesRequest request = new ListLogEntriesRequest
{
Filter = "labels.SOME_LABEL: someValue and timestamp >= 2019-05-22T00:00:00Z"
};
request.ResourceNames.Add("projects/PROJECT_NAME");
var res = LogClient.ListLogEntries(request);
foreach (var r in res)
{
Console.WriteLine(r);
}
我收到以下错误:
StatusCode=InvalidArgument, Detail="Unparseable filter: syntax error at line 1, column 83, token ':'"
是否可以在过滤器中使用分号作为值或子字符串运算符?
答案 0 :(得分:0)
事实证明您需要引用这些值:
var LogClient = LoggingServiceV2Client.Create();
ListLogEntriesRequest request = new ListLogEntriesRequest
{
Filter = "labels.SOME_LABEL: \"someValue\" and timestamp >= \"2019-05-22T00:00:00Z\""
};
request.ResourceNames.Add("projects/PROJECT_NAME");
var res = LogClient.ListLogEntries(request);
foreach (var r in res)
{
Console.WriteLine(r);
}