#StackBounty: #javascript #amazon-web-services #amazon-cloudwatch #amazon-cloudwatchlogs How to submit the simple log with AWS CloudWat…

Bounty: 50

After about 1 hour of searching, I didn’t find anything about ‘how to submit a simple log to AWS CloudWatch Logs’ from the frontend side. Almost all examples are for Node.js, but I need to submit the errors from the frontend, not form backend. I even did not found which package which I should use for the frontend.

To save, your time, I prepared the template of solution.

import { AWSCloudWatch } from "?????";

AWSCloudWatch.config({
  // minimal config
});

if (__IS_DEVELOPMENT_BUILDING_MODE__ || __IS_TESTING_BUILDING_MODE__) {
  console.error(errorMessage);
  return;
}

if (__IS_PRODUCTION_BUILDING_MODE__) {
  // Submit 'errorMessage' to AWS CloudWatch
  // It would be something like
  // AWSCloudWatch.submit(errorMessage)
}


Get this bounty!!!

#StackBounty: #amazon-web-services #amazon-cloudwatch #amazon-cloudwatchlogs #aws-cloudwatch-log-insights CloudWatch Insights Query – H…

Bounty: 50

I have a log file which contains playerId values, some players have multiple entries in the file. I want to get an exact distinct count of to unique players, regardless of if they have 1 or multiple entries in the log file.

Using the query below it scans 497 records and finds 346 unique rows (346 is the number I want)
Query:

fields @timestamp, @message
| sort @timestamp desc
| filter @message like /(playerId)/ 
| parse @message ""playerId": "*"" as playerId
| stats count(playerId) as CT by playerId

497 records 346 rows

If I change my query to use count_distinct instead, I get exactly what I want. Example below:

fields @timestamp, @message
| sort @timestamp desc
| filter @message like /(playerId)/ 
| parse @message ""playerId": "*"" as playerId
| stats count_distinct(playerId) as CT 

with count_distinct function

The problem with count_distinct however is that as the query expands to a larger timeframe/more records the number of entries get into the thousands, and tens of thousands. This presents an issue as the numbers become approximations, due to the nature of Insights count_distinct behaviour…

“Returns the number of unique values for the field. If the field has very high cardinality (contains many unique values), the value returned by count_distinct is just an approximation.”.

Docs: https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html

This is not acceptable, as I require exact numbers. Playing with the query a little, and sticking with count(), not count_distinct() I believe is the answer, however I’ve not been able to come to a single number… Examples which do not work… Any thoughts?

Ex 1:

fields @timestamp, @message
| sort @timestamp desc
| filter @message like /(playerId)/ 
| parse @message ""playerId": "*"" as playerId
| stats count(playerId) as CT by playerId
| stats count(*) 

We are having trouble understanding the query.

To be clear, I’m looking for an exact count to be returned in a single row showing the number.


Get this bounty!!!

#StackBounty: #amazon-web-services #aws-api-gateway #amazon-cloudwatchlogs AWS Gateway and CloudWatch logs

Bounty: 50

I seem to have an issue with seeing logs in AWS CloudWatch for my AWS Gateway.

I did the following:

  • created IAM role that allows for CloudWatch logs
  • created API and set IAM ARN in the API settings
  • Enabled CloudWatch Logs in the stage settings

Now I can see a Log Group that seem to correspond to my AWS Gateway and Log Streams but all of them are empty.

I think I’m missing something here.

Thanks,
Michal


Get this bounty!!!