简体   繁体   English

我可以将AWS LightSail与AWS CloudWatch一起使用吗?

[英]Can I use AWS LightSail with AWS CloudWatch?

I've recently started testing out LightSail , but I would like to keep my logging centralized in CloudWatch , but cannot seem to find anything that would enable this. 我最近开始测试LightSail ,但我想将我的日志记录集中在CloudWatch中 ,但似乎找不到任何可以实现此功能的内容。 Interestingly LightSail instances do not appear in the EC2 Dashboard. 有趣的是,LightSail实例没有出现在EC2仪表板中。 I thought they were just EC2 instances beneath the surface. 我以为它们只是表面下的EC2实例。

I thought they were just EC2 instances beneath the surface. 我以为它们只是表面下的EC2实例。

Yes... but. 对,但是。

Conceptually speaking, you are the customer of Lightsail, and Lightsail is the customer of EC2. 从概念上讲,您是Lightsail的客户,而Lightsail是EC2的客户。

It's as though there were an intermediary between you and AWS. 就好像你和AWS之间有一个中间人。 The Lightsail resources are in EC2, but they're not in your EC2. Lightsail资源 EC2中,但它们不在您的 EC2中。 They appear to be owned by an AWS account other than your AWS account, so you can't see them directly. 它们似乎归您的 AWS账户以外 AWS账户所有,因此您无法直接看到它们。

Parallels for this: 相似之处:

RDS is a "customer" of EC2/EBS. RDS是EC2 / EBS的“客户”。 RDS instances are EC2 machines with EBS volumes. RDS实例是具有EBS卷的EC2机器。 Where are they in the console? 他们在控制台的哪个位置? They aren't there. 他们不在那里。 The underlying resources aren't owned by your account. 基础资源不属于您的帐户。

In EC2, EBS snapshots are stored in S3. 在EC2中,EBS快照存储在S3中。 Which bucket? 哪个桶? Not one that you can see. 不是你能看到的。 EBS is a "customer" of S3. EBS是S3的“客户”。 It has its own buckets. 它有自己的水桶。

S3 objects can be migrated to the Glacier storage class. S3对象可以迁移到Glacier存储类。 Which Glacier vault? 哪个冰川保险库? Again, not one that you can see. 再一次,不是你能看到的。 S3 is a "customer" of Glacier. S3是Glacier的“客户”。 It has its own vaults. 它有自己的保险库。

Every API Gateway endpoint is automatically front-ended by CloudFront. CloudFront会自动为每个API网关端点提供前端。 Which distribution? 哪个发行? You get the idea... API Gateway is a "customer" of CloudFront. 您明白了...... API Gateway是CloudFront的“客户”。

I am not implying in any way that Lightsail is actually a separate entity from AWS in any meaningful sense... I don't know how it's actually organized... but operationally , that is how it works. 我并不是以任何方式暗示Lightsail实际上是一个与AWS无关的独立实体......我不知道它实际上是如何组织的......但从操作上来说 ,这就是它的工作原理。 You can't see these resources. 你看不到这些资源。

It's possible to get it working. 它可以让它工作。 The problem is that Lightsail instances are EC2 instances under the hood, but without access to all of the EC2 configuration. 问题是Lightsail实例是引擎盖下的EC2实例,但无法访问所有EC2配置。 The CloudWatch agent documentation explains how to set up IAM roles for EC2 instances to assume, but Lightsail boxes only use a single role which can't be changed and can't be edited. CloudWatch代理文档说明了如何为EC2实例设置IAM角色,但Lightsail框仅使用无法更改且无法编辑的单个角色。 As a result, you need to follow instructions for setting it up as an on-premise server. 因此,您需要按照说明将其设置为内部部署服务器。

The problem you will then hit is as David J Eddy saw in his answer: 然后你会遇到的问题就像David J Eddy在他的回答中看到的那样:

2018-10-20T16:04:37Z E! WriteToCloudWatch failure, err:  AccessDenied: User: arn:aws:sts::891535117650:assumed-role/AmazonLightsailInstanceRole/i-0788a602f758b836f is not authorized to perform: cloudwatch:PutMetricData status code: 403, request id: b443ecc6-d481-11e8-a551-6d030b8667be

This is due to a bug in the CloudWatch agent which ignores the argument to use on-premise mode ( -m onPremise ) if it detects it is running on an EC2 instance. 这是由于CloudWatch代理中的一个错误,如果它检测到它在EC2实例上运行,则忽略使用内部部署模式( -m onPremise )的参数。 The trick is to edit the common-config.toml file to force using a local AWS CLI profile for authentication. 诀窍是编辑common-config.toml文件以强制使用本地AWS CLI配置文件进行身份验证。 You will need to add the following lines to that file (which can be found at /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml on Debian - the installation location is OS dependent): 您需要将以/opt/aws/amazon-cloudwatch-agent/etc/common-config.toml添加到该文件中(可以在Debian上的/opt/aws/amazon-cloudwatch-agent/etc/common-config.toml找到 - 安装位置取决于操作系统):

[credentials]
shared_credential_profile = "AmazonCloudWatchAgent"

Restart the agent and it should start reporting metrics. 重新启动代理,它应该开始报告指标。 I've put together a full tutorial here 我在这里整理了一个完整的教程

Running the CloudWatch Agent on Lightsail does NOT work at this time. 运行在Lightsail的CloudWatch的代理不会在这个时候工作。 When the agent attempts to communicate with CloudWatch it receives a 403 from the STS service. 当代理尝试与CloudWatch通信时,它从STS服务接收403。 Selecting EC2 or OnPremise options during configuration wizards yields the same results. 在配置向导期间选择EC2OnPremise选项会产生相同的结果。

2018-10-20T16:04:37Z E! WriteToCloudWatch failure, err:  AccessDenied: User: arn:aws:sts::891535117650:assumed-role/AmazonLightsailInstanceRole/i-0788a602f758b836f is not authorized to perform: cloudwatch:PutMetricData status code: 403, request id: b443ecc6-d481-11e8-a551-6d030b8667be

Just to make sure, I installed the CloudWatch Agent on my Ubuntu 18.04 desktop and started the agent without error. 为了确保,我在我的Ubuntu 18.04桌面上安装了CloudWatch Agent并启动了代理而没有错误。

Plus, if it did work, why would people pay for EC2 at a higher prices point? 另外,如果确实有效,为什么人们会以更高的价格支付EC2? CloudWatch is a free value added service for using the full services. CloudWatch是一项free增值服务,可用于使用完整服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在AWS Lightsail上登录PHPMyAdmin? - How can I login to PHPMyAdmin on AWS Lightsail? 我可以使用AWS CloudWatch来获取状态URI吗? - Can I use AWS CloudWatch to hit a status URI? 我可以将字符串数据发送到 AWS Cloudwatch,然后在警报中使用吗? - Can I send string data to AWS Cloudwatch and then use in Alarms? 如何在 AWS Cloudwatch 自定义事件中使用 JSON 逻辑? - How can I use JSON logic in an AWS Cloudwatch custom event? 是否可以将 AWS CodePipeline 与 Lightsail 结合使用? - Is it possible to use AWS CodePipeline with Lightsail? 我可以在没有负载均衡器的情况下为 AWS lightail 设置 ssl 证书吗? - Can I setup an ssl certificate for AWS lightsail without the Load Balancer? 为什么我无法从亚马逊 AWS Lightsail 发送电子邮件? - Why I can not send email from amazon AWS Lightsail? 无法将Terraform Provisioner与AWS Lightail一起使用 - Fail to use terraform provisioner with aws lightsail 如何使用 AWS Boto3 获取 Cloudwatch 指标统计信息? - How can I use AWS Boto3 to get Cloudwatch metric statistics? 我可以使用现有的 Grafana Cloudwatch 数据源为不同的 AWS 账户构建仪表板吗? - Can I use an existing Grafana Cloudwatch datasource to build dashboards for a different AWS account?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM