influxdata/telegraf

Request Metrics.go convertField to add addional array types

Open

#13.041 geöffnet am 5. Apr. 2023

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)Go (4.161 Forks)batch import
feature requesthelp wantedsize/l

Repository-Metriken

Stars
 (9.892 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 2T 12h) (136 gemergte PRs in 30 T)

Beschreibung

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

Contributor Guide