CloudWatch Agent alarms not displayed

0

Hey,

I have successfully configered CloudWatch Agent on a EC2 instance and can view the metrics in the "All metrics" section. When creating an alarm from these metrics, the alarm shows "insufficient data" and doesn´t display any metric.

The logs does´nt show anything suspicious.

The configuration:

{
        "agent": {
                "metrics_collection_interval": 60,
                "run_as_user": "root"
        },
        "logs": {
                "logs_collected": {
                        "files": {
                                "collect_list": [
                                        {
                                                "file_path": "/var/log/messages",
                                                "log_group_name": "cwagentlogs",
                                                "log_stream_name": "{instance_id}",
                                                "retention_in_days": 1
                                        }
                                ]
                        }
                }
        },
        "metrics": {
                "aggregation_dimensions": [
                        [
                                "InstanceId"
                        ]
                ],
                "append_dimensions": {
                        "AutoScalingGroupName": "${aws:AutoScalingGroupName}",
                        "ImageId": "${aws:ImageId}",
                        "InstanceId": "${aws:InstanceId}",
                        "InstanceType": "${aws:InstanceType}"
                },
                "metrics_collected": {
                        "cpu": {
                                "measurement": [
                                        "cpu_usage_idle",
                                        "cpu_usage_iowait",
                                        "cpu_usage_user",
                                        "cpu_usage_system"
                                ],
                                "metrics_collection_interval": 60,
                                "resources": [
                                        "*"
                                ],
                                "totalcpu": false
                        },
                        "disk": {
                                "measurement": [
                                        "used_percent",
                                        "inodes_free"
                                ],
                                "metrics_collection_interval": 60,
                                "resources": [
                                        "*"
                                ]
                        },
                        "diskio": {
                                "measurement": [
                                        "io_time",
                                        "write_bytes",
                                        "read_bytes",
                                        "writes",
                                        "reads"
                                ],
                                "metrics_collection_interval": 60,
                                "resources": [
                                        "*"
                                ]
                        },
                        "mem": {
                                "measurement": [
                                        "mem_used_percent"
                                ],
                                "metrics_collection_interval": 60
                        },
                        "netstat": {
                                "measurement": [
                                        "tcp_established",
                                        "tcp_time_wait"
                                ],
                                "metrics_collection_interval": 60
                        },
                        "swap": {
                                "measurement": [
                                        "swap_used_percent"
                                ],
                                "metrics_collection_interval": 60
                        }
                }
        }

Can anyone help me with this issue?

BR, Mark

질문됨 9달 전454회 조회
3개 답변
0
수락된 답변

Oh you're mentioning the namespace AWS/EC2 in your alarm configuration, but only metrics collected directly by the EC2 service will be reported with that namespace. The metrics collected by the CloudWatch agent will be reported with a different namespace. I believe the namespace should be CWAgent rather than AWS/EC2.

profile pictureAWS
Jsc
답변함 9달 전
profile pictureAWS
전문가
검토됨 9달 전
0

Hi, if you can view the metrics in the "All metrics" section, then the agent configuration is OK and it is not likely the place to look for an issue.

The most common issue that leads to an alarm staying in insufficient data when created on a metric that you can view in the console is if you specify an unit on the alarm and that unit doesn't match the metric's unit.

How did you create your alarms and can you share the definition of one of your alarms?

profile pictureAWS
Jsc
답변함 9달 전
  • Hey,

    I create them with a CloudFormation template:

    EC2MemoryUsage1: Type: 'AWS::CloudWatch::Alarm' DependsOn: SNSTopic Properties: AlarmName: !Sub '${CustomerName}-QAS-Submission-MemoryUsage' AlarmDescription: 'Alarm for Memory Usage > 90% on EC2 Instance' AlarmActions: - !Ref SNSTopic Namespace: 'AWS/EC2' MetricName: 'mem_used_percent' Dimensions: - Name: 'InstanceId' Value: !Ref QASSubmissionEC2InstanceId ComparisonOperator: 'GreaterThanThreshold' Threshold: 90 EvaluationPeriods: 1 Period: 21600 #6 hours Statistic: 'Average'

    I forgot to mention that I deploy the template in the CloudWatch Monitoring account and the data is grapped from a source account. I followed this page: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Cross-Account-Cross-Region.html When I create the alarm in the source account it works.

0

And sorry noticed after previous answer, if you create the alarm in a different account than the source account, you must also mention the account id.

Example:
    Metrics:
        - Id: m1
          ReturnData: true
          AccountId: "123456789012"
          MetricStat:
              Metric:
                  Namespace: CWAgent
                  MetricName: mem_used_percent
                  Dimensions: …
              Period: 21600
              Stat: Average

profile pictureAWS
Jsc
답변함 9달 전

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

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

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

관련 콘텐츠