Monitor Linux services via CloudWatch

0

I have installed CWAgent and have everything monitored accept for specific service running on my RHEL 7.9 instances. How do I configure cloudwatch to monitor a specific service?

3 Answers
0

Hi,

If you have installed CWAgent, you can configure procstat section. Like that, you can target a specific process. https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-procstat-process-metrics.html

profile picture
Donov
answered a year ago
0

You can publish a custom metric to CloudWatch in the form of a "heart beat".

Have a small script running via cron on your server checking the process list to see whether my_service is running and if it is, make a put-metric-data call to CloudWatch.

The metric could be as simple as pushing the number "1" to your custom metric in CloudWatch.

Set up a CloudWatch alarm that triggers if the average for the metric falls below 1

Make the period of the alarm be >= the period that the cron runs e.g. cron runs every 5 minutes, make the alarm alarm if it sees the average is below 1 for two 5 minute periods.

Make sure you also handle the situation in which the metric is not published (e. g. cron fails to run or whole machine dies). you would want to setup an alert in case the metric is missing. (see here: AWS Cloudwatch Heartbeat Alarm)

Be aware that the custom metric will add an additional cost of 50c to your AWS bill (not a big deal for one metric - but the equation changes drastically if you want to push hundred/thousands of metrics - i.e. good to know it's not free as one would expect)

See here for how to publish a custom metric: http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/publishingMetrics.html

AWS
answered a year ago
0

To configure CloudWatch to monitor a specific service running on your RHEL 7.9 instances, you can follow these steps:

  1. Install CloudWatch Agent: Ensure that you have installed and configured the CloudWatch Agent on your RHEL 7.9 instances. Install Cloudwatch agent: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/install-CloudWatch-Agent-on-EC2-Instance.html

  2. Create a Custom Log Group: In the CloudWatch console, navigate to the Logs section and create a custom log group. This log group will be used to store the logs specific to your service. Log group creation: https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Working-with-log-groups-and-streams.html#Create-Log-Group

  3. Configure Log Files: Edit the CloudWatch Agent configuration file (typically located at /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json) and add a new log section under the logs parameter. Specify the log files or directories associated with your service.

  4. Restart CloudWatch Agent to apply the changes made to the configuration file and verify Logs in CloudWatch. Once the logs are successfully streaming into CloudWatch, you can set up metrics, alarms, and visualizations based on those logs to monitor the specific service's performance and health.

It's important to ensure that the CloudWatch Agent has the necessary permissions to access and read the log files of your service on the RHEL instance. IAM roles and permissions: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-iam-roles-for-cloudwatch-agent.html

AWS
answered 7 months ago

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