Skip to content

Commit

Permalink
Merge pull request #720 from kongfei605/aliyun_up
Browse files Browse the repository at this point in the history
add device tag for ecs metrics
  • Loading branch information
kongfei605 committed Nov 20, 2023
2 parents d14b415 + 4e64893 commit 988965c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
10 changes: 6 additions & 4 deletions conf/input.aliyun/cloud.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
# interval_times=4
# delay="10m"
# period="60s"
#
# ratelimit=25
# catch_ttl="1h"
# timeout="5s"
#
# # namespace 参考 https://help.aliyun.com/document_detail/163515.htm?spm=a2c4g.11186623.0.0.44d65c58mhgNw3
# namespaces=["acs_ecs_dashboard"]
# [[instances.metric_filters]]
# # metric name 参考 https://help.aliyun.com/document_detail/163515.htm?spm=a2c4g.11186623.0.0.401d15c73Z0dZh
# # 参考页面中的Metric Id 填入下面的metricName ,页面中包含中文的Metric Name对应接口中的Description
# metric_names=["cpu_cores","vm.TcpCount"]
# namespace=""
# ratelimit=25
# catch_ttl="1h"
# timeout="5s"
# metric_names=["cpu_cores","vm.TcpCount"]
3 changes: 3 additions & 0 deletions inputs/aliyun/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ func (ins *Instance) makeLabels(point internalTypes.Point, labels ...map[string]
if len(point.NodeID) != 0 {
result["node_id"] = point.NodeID
}
if len(point.Device) != 0 {
result["device"] = point.Device
}
return result
}

Expand Down
1 change: 1 addition & 0 deletions inputs/aliyun/internal/manager/cms.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func (m *Manager) dataPointConverter(metricName, ns, datapoints string) ([]types
r.InstanceID = point.InstanceID
r.Namespace = ns
r.Timestamp = point.Timestamp
r.Device = point.Device

if point.Val != nil {
r.MetricName = fmt.Sprintf("%s_%s", stringx.SnakeCase(metricName), "value")
Expand Down
2 changes: 2 additions & 0 deletions inputs/aliyun/internal/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ type (
Dimensions string `json:"-"`
Namespace string `json:"-"`
MetricName string `json:"-"`

Device string `json:"device"`
}
)

Expand Down

0 comments on commit 988965c

Please sign in to comment.