influxdata/telegraf

Request Metrics.go convertField to add addional array types

Open

#13,041 创建于 2023年4月5日

在 GitHub 查看
 (1 评论) (0 反应) (0 负责人)Go (4,161 fork)batch import
feature requesthelp wantedsize/l

仓库指标

Star
 (9,892 star)
PR 合并指标
 (平均合并 2天 12小时) (30 天内合并 136 个 PR)

描述

Use Case

I have an OPC UA server that provides array data as []int32 []float64 and []string.

For me I changed/added metric.go (function convertField) as following:

+	case []int32:
+		return []int32(v)
+	case []string:
+		return []string(v)
+	case []float64:
+		return []float64(v)
 	case *int16:
 		if v != nil {
 			return int64(*v)

This works for output.File with type JSON. I do not know the side effects, but may be it helps others... or someone could check it for side effects...

metrics_int32_float32_string_array.patch

Expected behavior

I want to output also array-type OPC UA data to (JSON) files. (only one I tested, may be works also with other plugins)

Actual behavior

Without the mentioned patch it does not store the array values to the file. The function convertField returns nil for []int32 []float64 and []string so that the field is not written to output.

Additional info

No response

贡献者指南