问题描述
我正在尝试通过发送参数来获取CloudWatchLogs filterLogEvents。 有时它可以正常工作并向我发送确切的日志,但是对于不同的lambda函数,它将返回带有下一个标记的空事件。
参数= {
'logGroupName':metricFilter.logGroupName, 'filterPattern':metricFilter.filterPattern吗? metricFilter.filterPattern:“”, 'startTime':时间戳-偏移量, 'endTime':时间戳 };
我正在通过发送带有下一个标记的参数来重试,但是它仍然会收到空事件。有人知道吗?
{
"events": [],"searchedLogStreams": [],"nextToken": "long text"
}
解决方法
当我尝试使用aws sdk捕获aws cloud watch日志时,我遇到了同样的问题。
当我使用logStreamNamePrefix(在我的情况下是设备的uuid)时,我终于解决了这个问题。
因此,我在下面创建了该函数,当我第一次运行它时,它没有使用nextToken,而随后的几次,我在请求中都使用了令牌,并再次使用令牌调用它以继续搜索。
<ListView RowHeight="300" SeparatorVisibility="None" BackgroundColor="White">
<ListView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>mono</x:String>
<x:String>monodroid</x:String>
<x:String>monotouch</x:String>
</x:Array>
</ListView.ItemsSource>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout>
<Frame Margin="40" BackgroundColor="Yellow" HeightRequest="220">
<StackLayout>
<Editor Text="test" HeightRequest="150"></Editor>
<StackLayout Orientation="Horizontal">
<Button x:Name="CreateOrChangeButton" Text="Create/Change" TextColor="Black" HorizontalOptions="FillAndExpand"></Button>
<Button x:Name="DeleteButton" Text="Delete" TextColor="Black" BackgroundColor="Brown" HorizontalOptions="FillAndExpand"></Button>
</StackLayout>
</StackLayout>
</Frame>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
此功能是我在Angular项目中完成的,但即使使用JavaScript vanila进行了一些调整,该功能也可以使用。