【问题标题】:Monitor Amazon EC2 API requests in Grafana在 Grafana 中监控 Amazon EC2 API 请求
【发布时间】:2021-02-02 15:59:06
【问题描述】:

我无法使用 Grafana 在 EC2 实例中提取 Amazon Cloudwatch 指标。设置如下:

带有 Grafana 的 EC2 实例:

  • 安全组:(ssh,tpc,22,0.0.0.0/0;custom tcp,tpc,3000,0.0.0.0/0;)
  • 使用 Grafana 附加到 EC2 实例中的角色的策略:
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "AllowReadingMetricsFromCloudWatch",
            "Effect": "Allow",
            "Action": [
                "cloudwatch:DescribeAlarmsForMetric",
                "cloudwatch:DescribeAlarmHistory",
                "cloudwatch:DescribeAlarms",
                "cloudwatch:ListMetrics",
                "cloudwatch:GetMetricStatistics",
                "cloudwatch:GetMetricData"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowReadingLogsFromCloudWatch",
            "Effect": "Allow",
            "Action": [
                "logs:DescribeLogGroups",
                "logs:GetLogGroupFields",
                "logs:StartQuery",
                "logs:StopQuery",
                "logs:GetQueryResults",
                "logs:GetLogEvents"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowReadingTagsInstancesRegionsFromEC2",
            "Effect": "Allow",
            "Action": [
                "ec2:DescribeTags",
                "ec2:DescribeInstances",
                "ec2:DescribeRegions"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AllowReadingResourcesForTags",
            "Effect": "Allow",
            "Action": "tag:GetResources",
            "Resource": "*"
        }
    ]
}

没有检索任何数据的Grafana查询截图:

【问题讨论】:

    标签: amazon-web-services amazon-ec2 grafana amazon-cloudwatch


    【解决方案1】:

    https://docs.aws.amazon.com/AWSEC2/latest/APIReference/monitor.html

    这是一项可选功能。要为您的 AWS 账户启用此功能,请联系 AWS Support。

    1. 您确定已为您的 AWS 账户启用此功能吗?
    2. 你确定InstanceId 是正确的维度并且只有一个 尺寸是必需的吗?

    最好的选择是转到 AWS CloudWatch 控制台并在那里生成图表。然后,您可以将生成的 CloudWatch 查询与 Grafana 生成的 CloudWatch 查询进行比较。

    【讨论】:

    • 嗨,Jan,不确定是因为选择加入功能还是因为实例是 Elasticbeanstalk,但这让我感到困惑,因为我可以看到 EC2 实例和 Elasticbeanstalk,我想我可以按照我的回答中的说明使用该命名空间,这是错误的
    【解决方案2】:

    我终于可以通过将命名空间更改为 AWS/ElasticBeanstalk 并将具有 EnvironmentName 的维度更改为我想要定位的维度来提取一些数据。在我必须转到 Elasticbeanstalk 的配置仪表板并在输入选择中的 CloudWatch 自定义指标中添加适当的指标之前

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-12-21
      • 1970-01-01
      • 2020-07-10
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      相关资源
      最近更新 更多