influxdata/telegraf

Request Metrics.go convertField to add addional array types

Open

#13,041 opened on 2023年4月5日

GitHub で見る
 (1 comment) (0 reactions) (0 assignees)Go (4,161 forks)batch import
feature requesthelp wantedsize/l

Repository metrics

Stars
 (9,892 stars)
PR merge metrics
 (平均マージ 2d 12h) (30d で 136 merged PRs)

説明

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

コントリビューターガイド