Enabling CloudWatch Integration for EC2Config version 4.2.1442 - amazon-web-services

I have tried sending custom metrics to Cloud Watch.
For Ec2Config version till 4.1, I had to enable the cloud watch logs integration. It looked like the following :
Now, I am trying to do it for the instances whose Ec2Config service version is 4.2.1442, but the Cloud Watch Integration Checkbox is not visible. Infact, the CloudWatch Logs section is not being shown. Because of this, I am unable to send custom metrics to CLoudWatch.
How do I enable CloudWatch Logs integration now? Please suggest.

I am using an updated version of EC2Config (4.2.x), and this is the reason why I am unable to find the CloudWatch Logs Integration checkbox.
According to AWS Documentation :
http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/send_logs_to_cwl.html
Step 2 clearly notes the following :
NOTE :
If you don't see the Enable CloudWatch Logs integration option, then you are using an updated version of the EC2Config service that no longer supports enabling CloudWatch integration. You must use Systems Manager Run Command to enable CloudWatch integration.
As suggested, I followed the following link :
http://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/remote-commands-cloudwatch.html
By following that, I was able to solve it. My instance had no IAM Role attached, so I attached it using the AWS CLI. Then, I ran the Run Command from the AWS EC2 console which automatically pushed custom performance counters to CloudWatch.

Related

AWS Elastic Beanstalk Application Console Logs Publish to Cloudwatch

I have deployed a .net 6 application in AWS Elastic Beanstalk (Windows server). Application has been configured to write application level logs to the console. At the moment, these logs are not published to a CloudWatch by default.
Is there a way that, these console logs can be publised to a Cloudwatch log group? For ex, When using Lambdas, they automatically send console logs to a Cloudwatch stream by default. Something similar would be ideal.
Thanks
Follow this
To stream instance logs to CloudWatch Logs
Open the Elastic Beanstalk console, and in the Regions list, select your AWS Region.
In the navigation pane, choose Environments, and then choose the name of your environment from the list.
In the navigation pane, choose Configuration.
In the Software configuration category, choose Edit.
Under Instance log streaming to CloudWatch Logs:
Enable Log streaming.
Set Retention to the number of days to save the logs.
Select the Lifecycle setting that determines whether the logs are saved after the environment is terminated.
Choose Apply.
After you enable log streaming, you can return to the Software configuration category or page and find the Log Groups link. Click this link to see your logs in the CloudWatch console.
Note :- before enabling, you should have proper permissions for cloudwatch agent.
Update ( based on comments )
.net on Linux supports application, for windows a user need to implement custom solution
/var/log/eb-engine.log,/var/log/eb-hooks.log,/var/log/web.stdout.log,/var/log/nginx/access.log,/var/log/nginx/error.log
This is an alternate way, https://aws.plainenglish.io/how-to-setup-aws-elasticbeanstalk-to-stream-your-custom-application-logs-to-cloudwatch-d5c877eaa242

AWS CloudWatch sending logs but not custom metrics to CloudWatch

first time asker.
So I've been trying to implement AWS Cloud Watch to monitor Disk Usage on an EC2 instance running EC2 Linux. I'm interesting in doing this just using the CW Agent and I've installed it according to the how-to found here. The install runs fine and I've made sure I've created an IAM Role for the instance as is described here. Unfortunately whenever I run the amazon-cloudwatch-agent.service it only sends log files and not the custom used_percent measurement specified. I receive this error when I tail the logs.
2021-06-18T15:41:37Z E! WriteToCloudWatch failure, err: RequestError: send request failed
caused by: Post "https://monitoring.us-west-2.amazonaws.com/": dial tcp 172.17.1.25:443: i/o timeout
I've done my best googlefu but gotten nowhere thus far. If you've got any advice it would be appreciated.
Thank you
Belated answer to my own question. I had to create a security group that would accept traffic from that same security group!
Having the same issue, it definitely wasn't a network restriction as I was still able to telnet to the monitoring endpoint.
From AWS docs: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-iam-roles-for-cloudwatch-agent.html
One role or user enables CloudWatch agent to be installed on a server
and send metrics to CloudWatch. The other role or user is needed to
store your CloudWatch agent configuration in Systems Manager Parameter
Store. Parameter Store enables multiple servers to use one CloudWatch
agent configuration.
If you're using the default cloudwatchagent configuration wizard, you may require extra policy CloudWatchAgentAdminRole in your role for the agent to connect to the monitoring service.

Log print statements from script running on ec2 server?

I have a python script that runs from an ec2 server. What is the easiest way for me to see print statements from that script? I tried viewing the system log but I don't see anything there and I can't find anything in cloudwatch. Thanks!
Standard output from arbitrary applications running on EC2 don't appear in CloudWatch Logs.
You can install the CloudWatch Logs Agent, configure it to collect logs from given locations, and then configure your app to log to one of those locations.
It is possible to send log of application running on EC2 to Cloudwatch directly for that you need to do following step.
Create IAM Role with relevant permission and attach to Linux instance.
Install the CloudWatch agent in the instances.
Prepare the configuration file in the instance.
Start the CloudWatch agent service in the instance.
Monitor the logs using CloudWatch web console.
For your reference:-
http://medium.com/tensult/to-send-linux-logs-to-aws-cloudwatch-17b3ea5f4863

Why eks cluster doesn't have corresponding logs in CloudWatch

Control plane logging for EKS + CloudWatch is relatively new. I see this in my EKS account:
but when I click the link at the bottom to go to CloudWatch there are no logs for this cluster, it's not listed here:
I would suggest you to disable it in the Amazon console for now, and enable again with the AWS CLI, and then monitor the status of your log configuration update with the procedure described in official documentation here.
This should give you in theory some meaningful information about the status of EKS logging integration with CloudWatch.

AWS ECS custom CloudWatch metrics

I'm looking for a way to establish custom metrics over StatsD protocol for Amazon Elastic Container Service. I've found a documentation on how to establish Amazon CloudWatch Agent on EC2. It works well. However I'm failing to find a correct configuration for Dockerfile. Quite probably some set of custom IAM permissions will also be required there.
Is it possible to have Docker containers working from AWS ECS with custom metrics using StatsD reporting to AWS CloudWatch?
Rather than building your own container, you can use the one provided by Amazon. This article explains how, including a link to an example daemon service task configuration.