In cloud watch log group i need to find logs that has status=400 .

0

Hi community,

I have tried with metric filter but i think i have made some mistake in there. what i need is i have a specific log group and I need to filter its logs and find which logs contain "status":"400" or "401".

thank you

layansp
질문됨 6달 전403회 조회
1개 답변
2
수락된 답변

You can search using log insights as follows: (Replace your text to search)

fields @timestamp, @message
| filter @message like /your text to search/
| sort @timestamp desc
| limit 20

EDIT

Try this too

fields @timestamp, @message
| filter strcontains(@message, "status=400")
| sort @timestamp desc
| limit 20
profile picture
전문가
답변함 6달 전
  • Hi Gary thank you for you quick response its really appreciated. i have run run it with adding my parameters but output is like this "Showing 0 of 0 records matched " it means no any records contain status=400. right.

  • Is your text status=400 in double quotes? Have you looked in the logs and tried searching for something you know thats there to test your search script? Have you also set the search time duration to say 1 day etc?

  • I have used this query.

    fields @timestamp, @message | filter @message like /status=400/ | sort @timestamp desc | limit 20

    i have select time duration as 1 hour , 1 week but it did not get any result , only gets this "Showing 0 of 0 records matched " after that i have replace the status code to 200 because known logs are there with status=200 then also did not get any result !

  • Try this instead

    fields @timestamp, @message
    | filter strcontains(@message, "status=400")
    | sort @timestamp desc
    | limit 20
    
  • Hi Gary its worked thank you for your support its appreciated. I have change it like this way because first i have identify there no 400 errors from this message "Showing 0 of 0 records matched ", there is 401 and 201 codes. again thank you so much.

    fields @timestamp | display @timestamp, errorMessage, status!="200" as ERROR

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠