gpt4 book ai didi

amazon-web-services - 以小时为单位显示 CloudWatch 指标

转载 作者:行者123 更新时间:2023-12-03 18:31:08 25 4
gpt4 key购买 nike

我有一个以秒为单位的自定义云监视指标。 (代表缓存的年龄)

像往常一样,值大约为 125,000,我想将它们转换为小时 - 为了更好的可读性。

那可能吗?

最佳答案

随着 Metrics Math 的加入,这种情况发生了变化。 .您可以手动(从控制台)和从 CloudFormation 仪表板模板对数据进行各种转换。

从控制台:请参阅上面的链接,其中说:

To add a math expression to a graph

  1. Open the CloudWatch console at https://console.aws.amazon.com/cloudwatch/.

  2. Create or edit a graph or line widget.

  3. Choose Graphed metrics.

  4. Choose Add a math expression. A new line appears for the expression.

  5. For the Details column, type the math expression. The tables in the following section list the functions you can use in the expression.

    To use a metric or the result of another expression as part of the formula for this expression, use the value shown in the Id column. For example, m1+m2 or e1-MIN(e1).



来自 a CloudFormation Template

您可以添加作为 Metrics Math 表达式的新指标,从而转换现有指标。您可以对指标和标量进行加、减、乘等运算。在您的情况下,您可能只想使用除法,如本例所示:

假设您有以下存储桶请求延迟 metrics模板中的对象:
"metrics":[
["AWS/S3","TotalRequestLatency","BucketName","MyBucketName"]
]

延迟默认值以毫秒为单位。让我们在几秒钟内绘制它,只是为了好玩。 1s = 1,000ms所以我们将添加以下内容:
"metrics":[
["AWS/S3","TotalRequestLatency","BucketName","MyBucketName",{"id": "timeInMillis"}],
[{"expression":"timeInMillis / 1000", "label":"LatencyInSeconds","id":"timeInSeconds"}]
]

请注意 expression可以访问 ID的其他指标。当事情变得更复杂时,有用的命名会很有用,但关键是将您放入表达式中的变量与 ID 匹配。您分配给相应的指标。

这给我们留下了一个带有 的图表两个指标:一毫秒,其他秒。如果我们想丢失毫秒,我们可以,但我们需要保留度量值来计算数学表达式,因此我们使用以下解决方法:
"metrics":[
["AWS/S3","TotalRequestLatency","BucketName","MyBucketName",{"id": "timeInMillis","visible":false}],
[{"expression":"timeInMillis / 1000", "label":"LatencyInSeconds","id":"timeInSeconds"}]
]

使度量不可见将其从图表中移除,同时仍然允许我们根据它计算我们的表达式。

关于amazon-web-services - 以小时为单位显示 CloudWatch 指标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14726224/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com