To monitor Windows Service running inside EC2 server


Hi AWS, I am looking for a mechanism to monitor the status of a windows service running inside a EC2 Server (Windows). The reason why I am asking this is we have installed GitHub self-hosted runner which is also a windows service after all.

The issue is the server is accessible by multiple entities and there are situations where the runner service is either stopped or deleted by someone and the CI/CD pipeline gets stuck for hours (default 6 hours as per GitHub's documentation) which is not valuable as we are paying GitHub for 6 long hours without any positive outcome and also costs money.

Is there a way we could detect that using CloudWatch or some other AWS service as I looked into CloudTrail but there were no logs related to a specific service rather than it captures logs at the instance level.

Please suggest something if exists as it is a very big pain for us and the problem is it is happening recurrently which is very annoying and risky.

profile picture
질문됨 3달 전368회 조회
1개 답변

Hi, 1)Install SSM Agent: Ensure that the AWS Systems Manager (SSM) Agent is installed and running on your Windows EC2 instances. The SSM Agent is required for Systems Manager to communicate with your instances.

2)Create an IAM Role: 

Create an IAM role that grants the necessary permissions for Systems Manager to execute commands on your EC2 instances. This role should include the AmazonSSMFullAccess or more restricted permissions if desired.

3)Configure CloudWatch Events: 

Set up a CloudWatch Events rule to trigger based on a schedule or based on certain events, such as an instance state change. You can use this rule to trigger an AWS Lambda function or a Systems Manager Automation document.

  1. Create a Systems Manager Automation Document: Create a Systems Manager Automation document that defines the steps to check the status of the Windows service on your EC2 instances. This document can include PowerShell commands or scripts to query the status of the service.

5 )Execute Automation Document with CloudWatch Events: Configure the CloudWatch Events rule to execute the Systems Manager Automation document when triggered. This will automatically check the status of the Windows service on your EC2 instances according to your defined schedule or event.

Set up Notifications (Optional): 

Configure CloudWatch Alarms to monitor the output of the Automation document execution. If the service status check fails or indicates an issue, you can set up notifications to alert you via Amazon SNS, Amazon SES, or other notification mechanisms.

By following these steps, you can automatically monitor the status of the Windows service running on your EC2 instances and take proactive actions if any issues are detected, helping to prevent CI/CD pipeline disruptions and associated costs.

profile picture
답변함 3달 전
  • Hi Hari Priya Reddy Maddi, thanks for the response. Will it able to resolve the issue I am experiencing?

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

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

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

관련 콘텐츠