To monitor Windows Service running inside EC2 server

0

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
asked 2 months ago294 views
1 Answer
0

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
answered 2 months ago
  • Hi Hari Priya Reddy Maddi, thanks for the response. Will it able to resolve the issue I am experiencing?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions