数据采集 采集源配置 AWS CloudWatch 指标采集
AWS CloudWatch 指标采集
简介
采集 aws cloudwatch 指标上报到 DataFlux 中
前置条件
- 已安装 DataKitDataKit 安装文档)
- aws 认证
Amazon认证
此插件使用凭据链与 CloudWatch API 端点进行身份验证。按照以下顺序进行身份验证:
1.通过STS给定的凭据的 role_arn 属性
2.显示出 access_key ,secret_key 和 token 属性
3.共享配置文件 profile 属性
4.环境变量
5.共享凭据
6.EC2实例摘要
配置
进入 DataKit 安装目录下的 conf.d/aws
目录,复制 cloudwatch.conf.sample
并命名为 cloudwatch.conf
。示例如下:
[[inputs.cloudwatch]]
## Amazon Region
region = "us-east-1"
## Amazon Credentials
## Credentials are loaded in the following order
## 1) Assumed credentials via STS if role_arn is specified
## 2) explicit credentials from 'access_key' and 'secret_key'
## 3) shared profile from 'profile'
## 4) environment variables
## 5) shared credentials file
## 6) EC2 Instance Profile
# access_key = ""
# secret_key = ""
# token = ""
# role_arn = ""
# profile = ""
# shared_credential_file = ""
## Endpoint to make request against, the correct endpoint is automatically
## determined and this option should only be set if you wish to override the
## default.
## ex: endpoint_url = "http://localhost:8000"
# endpoint_url = ""
# The minimum period for Cloudwatch metrics is 1 minute (60s). However not all
# metrics are made available to the 1 minute period. Some are collected at
# 3 minute, 5 minute, or larger intervals. See https://aws.amazon.com/cloudwatch/faqs/#monitoring.
# Note that if a period is configured that is smaller than the minimum for a
# particular metric, that metric will not be returned by the Cloudwatch API
# and will not be collected by Telegraf.
#
## Requested CloudWatch aggregation Period (required - must be a multiple of 60s)
period = "5m"
## Collection Delay (required - must account for metrics availability via CloudWatch API)
delay = "5m"
## Recommended: use metric 'interval' that is a multiple of 'period' to avoid
## gaps or overlap in pulled data
interval = "5m"
## Configure the TTL for the internal cache of metrics.
# cache_ttl = "1h"
## Metric Statistic Namespace (required)
namespace = "AWS/ELB"
## Maximum requests per second. Note that the global default AWS rate limit is
## 50 reqs/sec, so if you define multiple namespaces, these should add up to a
## maximum of 50.
## See http://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_limits.html
# ratelimit = 25
## Timeout for http requests made by the cloudwatch client.
# timeout = "5s"
## Namespace-wide statistic filters. These allow fewer queries to be made to
## cloudwatch.
# statistic_include = [ "average", "sum", "minimum", "maximum", sample_count" ]
# statistic_exclude = []
## Metrics to Pull
## Defaults to all Metrics in Namespace if nothing is provided
## Refreshes Namespace available metrics every 1h
#[[inputs.cloudwatch.metrics]]
# names = ["Latency", "RequestCount"]
#
# ## Statistic filters for Metric. These allow for retrieving specific
# ## statistics for an individual metric.
# # statistic_include = [ "average", "sum", "minimum", "maximum", sample_count" ]
# # statistic_exclude = []
#
# ## Dimension filters for Metric. All dimensions defined for the metric names
# ## must be specified in order to retrieve the metric statistics.
# [[inputs.cloudwatch.metrics.dimensions]]
# name = "LoadBalancerName"
# value = "p-example"
配置好后,重启 DataKit 即可生效
注意
- region 必须是有效的 AWS 区域
- period 必须是有效的 CloudWatch 期间
- namespace 必须是有效的 CloudWatch 命名空间
- names 必须是有效的云监视公制人名
- dimensions 必须是有效的云监视维数名称/值
限制
- CloudWatch 度量标准无法通过 CloudWatch API立即获得。若要对此延迟进行更改,你应该调整你的收藏 delay (根据您的监视订阅级别)。
- CloudWatch API 的使用会引起成本-见GetMetriData定价。
采集指标
指标 cloudwatch_{namespace}
- {metric}_sum (metric Sum value)
- {metric}_average (metric Average value)
- {metric}_minimum (metric Minimum value)
- {metric}_maximum (metric Maximum value)
- {metric}_sample_count (metric SampleCount value)
标签
- region (CloudWatch Region)
- {dimension-name} (Cloudwatch Dimension value - one for each metric dimension)