Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services AWS CloudWatch日志过滤器模式问题_Amazon Web Services_Amazon Cloudwatch_Amazon Cloudwatchlogs - Fatal编程技术网

Amazon web services AWS CloudWatch日志过滤器模式问题

Amazon web services AWS CloudWatch日志过滤器模式问题,amazon-web-services,amazon-cloudwatch,amazon-cloudwatchlogs,Amazon Web Services,Amazon Cloudwatch,Amazon Cloudwatchlogs,我有几个爬虫程序,可以对多个站点进行爬网,并将内容存储在数据库中。该程序的日志存储在CloudWatch日志中 如果爬虫成功地收回内容,它看起来与下面类似 httpget:200-https://www.thecheyennepost.com/news/national/r httpget:200-https://www.thecheyennepost.com/news/f-e-warren-hous 我要处理的问题是识别何时出现400个错误。以下是一个例子: httpget:429-https

我有几个爬虫程序,可以对多个站点进行爬网,并将内容存储在数据库中。该程序的日志存储在CloudWatch日志中

如果爬虫成功地收回内容,它看起来与下面类似

httpget:200-https://www.thecheyennepost.com/news/national/r

httpget:200-https://www.thecheyennepost.com/news/f-e-warren-hous

我要处理的问题是识别何时出现400个错误。以下是一个例子:

httpget:429-https://www.livingstonparishnews.com/search/?l=25&sort=

httpget:429-https://www.livingstonparishnews.com/search/?l=25&sort=rele

httpget:429-https://www.ktbs.com/search/?l=25&s=start_time&sd=desc&f=

我试着使用
status\u code=4*
,但没有任何效果

我只想能够过滤所有400个错误


如果您能提供任何帮助,我们将不胜感激。

是的!现在,您可以使用日志了解:)

首先。。。您需要有新的UI或以其他方式转到“日志洞察”“服务。。。贾贾

CloudWatch->CloudWatch日志->日志组->[您的服务日志]

使用新UI,您可以看到此按钮(或转到aws cli搜索引擎中的Logs Insights):

现在您可以看到:

  • 这是一个查询框,就像SQL
  • 您将搜索的时间范围
  • 现在就你而言。。您需要此查询(如果需要筛选其他内容,请告诉我)

    我看到你的日志,你的状态代码之间有空格,我认为这是最好的

    fields @message
    | sort @timestamp desc
    | filter @message like / 4{1}[0-9]{1}[0-9]{1} /
    
    就这些

    现在运行查询,您将只看到包含状态代码[4xx]的日志。 我希望这能解决你的问题

    注意:如果直接从搜索引擎转到Logs Insights,则需要选择使用查询扫描的服务日志。在查询框顶部的组合框上

    fields @message
    | sort @timestamp desc
    | filter @message like / 4{1}[0-9]{1}[0-9]{1} /