diff --git a/community/telegraf/APKBUILD b/community/telegraf/APKBUILD
index 582676519f7080b46c1b841244f3b4d04561925f..d0a3172fa04b65757e27a49a87378d0331ac6d2a 100644
--- a/community/telegraf/APKBUILD
+++ b/community/telegraf/APKBUILD
@@ -15,6 +15,7 @@ subpackages="$pkgname-openrc"
 options="net"
 source="telegraf-$pkgver.tar.gz::https://github.com/influxdata/telegraf/archive/v$pkgver.tar.gz
 	tests-plugins-reverse-dns-ignore-result.patch
+	fix-tests-go1.18.patch
 	telegraf.initd
 	telegraf.confd
 	"
@@ -46,6 +47,7 @@ package() {
 sha512sums="
 5afc4aa636364f7e33b121a6b68bd0ae3035be738e90e01ffebd0fcd727293bda1a09408d6bcb3f5d8ee8fe903cac880d8c4455c92b20c812b4d9689e168d8bb  telegraf-1.21.4.tar.gz
 effd94e968cd55e22493a7a7264b3970afc4139ddd4d9ffea7943612cf0cb93fec39a440c561957c165d788f6b184c246a044555d5c75dcf4b8564af45a72330  tests-plugins-reverse-dns-ignore-result.patch
+f7c6be4c5cdb4773609c9019840a8af089dab95e318f6d29c50d48a494d73b8c0b7a258ddf8ff6a4a9f83109a13d6974660b980e85cde5c94692881f9a8778fb  fix-tests-go1.18.patch
 abe483deb8e12fe140de2c36d17bbfbc97ed7a5de8c3d76162357f7ba6575b8236b7197b92a26ed6d54f95c1ccbfc12ca62d6cc0371bf49d10a1ea5622a51ed1  telegraf.initd
 d1a9aa57f8b5179f2d8396518b9db757fe1c40337b515c1f750cf577683ff15f3174bc757afa70d880a1fef809c873e6aa0da1b903a5a97934c14965712d47a4  telegraf.confd
 "
diff --git a/community/telegraf/fix-tests-go1.18.patch b/community/telegraf/fix-tests-go1.18.patch
new file mode 100644
index 0000000000000000000000000000000000000000..07b1f83514a831b281f608e762bba57351a17d29
--- /dev/null
+++ b/community/telegraf/fix-tests-go1.18.patch
@@ -0,0 +1,141 @@
+lightly modified to apply to 1.21.4 tag
+Patch-Source: https://github.com/influxdata/telegraf/pull/10847
+From a550d3c8b60d64d396a653fc88a981943c5a2fde Mon Sep 17 00:00:00 2001
+From: William Wilson <william.wilson@canonical.com>
+Date: Thu, 17 Mar 2022 17:33:47 -0500
+Subject: [PATCH] fix: Remove redundant newlines that Go 1.18 treats as errors
+
+---
+ internal/usage.go                            |  3 +--
+ internal/usage_windows.go                    |  3 +--
+ plugins/inputs/prometheus/prometheus_test.go | 15 +++++++--------
+ plugins/inputs/solr/testdata3_test.go        |  3 +--
+ plugins/inputs/solr/testdata7_test.go        |  3 +--
+ plugins/inputs/solr/testdata_test.go         |  9 +++------
+ 6 files changed, 14 insertions(+), 22 deletions(-)
+
+diff --git a/internal/usage.go b/internal/usage.go
+index a650a4854b3..3e6e4fb14fc 100644
+--- a/internal/usage.go
++++ b/internal/usage.go
+@@ -63,5 +63,4 @@ Examples:
+   telegraf --config telegraf.conf --input-filter cpu:mem --output-filter influxdb
+ 
+   # run telegraf with pprof
+-  telegraf --config telegraf.conf --pprof-addr localhost:6060
+-`
++  telegraf --config telegraf.conf --pprof-addr localhost:6060`
+--- a/internal/usage_windows.go
++++ b/internal/usage_windows.go
+@@ -72,5 +72,4 @@
+   telegraf --service install --config "C:\Program Files\Telegraf\telegraf.conf"
+ 
+   # install telegraf service with custom name
+-  telegraf --service install --service-name=my-telegraf --service-display-name="My Telegraf"
+-`
++  telegraf --service install --service-name=my-telegraf --service-display-name="My Telegraf"`
+diff --git a/plugins/inputs/prometheus/prometheus_test.go b/plugins/inputs/prometheus/prometheus_test.go
+index f56cfef8f59..0e1049051ce 100644
+--- a/plugins/inputs/prometheus/prometheus_test.go
++++ b/plugins/inputs/prometheus/prometheus_test.go
+@@ -31,8 +31,8 @@ go_gc_duration_seconds_count 7
+ go_goroutines 15
+ # HELP test_metric An untyped metric with a timestamp
+ # TYPE test_metric untyped
+-test_metric{label="value"} 1.0 1490802350000
+-`
++test_metric{label="value"} 1.0 1490802350000`
++
+ const sampleSummaryTextFormat = `# HELP go_gc_duration_seconds A summary of the GC invocation durations.
+ # TYPE go_gc_duration_seconds summary
+ go_gc_duration_seconds{quantile="0"} 0.00010425500000000001
+@@ -41,13 +41,12 @@ go_gc_duration_seconds{quantile="0.5"} 0.00015749400000000002
+ go_gc_duration_seconds{quantile="0.75"} 0.000331463
+ go_gc_duration_seconds{quantile="1"} 0.000667154
+ go_gc_duration_seconds_sum 0.0018183950000000002
+-go_gc_duration_seconds_count 7
+-`
++go_gc_duration_seconds_count 7`
++
+ const sampleGaugeTextFormat = `
+ # HELP go_goroutines Number of goroutines that currently exist.
+ # TYPE go_goroutines gauge
+-go_goroutines 15 1490802350000
+-`
++go_goroutines 15 1490802350000`
+ 
+ func TestPrometheusGeneratesMetrics(t *testing.T) {
+ 	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+@@ -161,8 +160,8 @@ func TestSummaryMayContainNaN(t *testing.T) {
+ go_gc_duration_seconds{quantile="0"} NaN
+ go_gc_duration_seconds{quantile="1"} NaN
+ go_gc_duration_seconds_sum 42.0
+-go_gc_duration_seconds_count 42
+-`
++go_gc_duration_seconds_count 42`
++
+ 	ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ 		_, err := fmt.Fprintln(w, data)
+ 		require.NoError(t, err)
+diff --git a/plugins/inputs/solr/testdata3_test.go b/plugins/inputs/solr/testdata3_test.go
+index cc5a4960d48..308333534bf 100644
+--- a/plugins/inputs/solr/testdata3_test.go
++++ b/plugins/inputs/solr/testdata3_test.go
+@@ -727,8 +727,7 @@ const mBeansSolr3MainResponse = `{
+       }
+     }
+   ]
+-}
+-`
++}`
+ 
+ var solr3CoreExpected = map[string]interface{}{
+ 	"num_docs":     int64(117166),
+diff --git a/plugins/inputs/solr/testdata7_test.go b/plugins/inputs/solr/testdata7_test.go
+index b58b3f131bd..b8beb894859 100644
+--- a/plugins/inputs/solr/testdata7_test.go
++++ b/plugins/inputs/solr/testdata7_test.go
+@@ -41,8 +41,7 @@ const mBeansSolr7Response = `
+          }
+       }
+    ]
+-}
+-`
++}`
+ 
+ var solr7CacheExpected = map[string]interface{}{
+ 	"evictions":            int64(141485),
+diff --git a/plugins/inputs/solr/testdata_test.go b/plugins/inputs/solr/testdata_test.go
+index 30ae0127ac2..19fa1b16370 100644
+--- a/plugins/inputs/solr/testdata_test.go
++++ b/plugins/inputs/solr/testdata_test.go
+@@ -62,8 +62,7 @@ const statusResponse = `
+     "QTime": 13,
+     "status": 0
+   }
+-}
+-`
++}`
+ 
+ const mBeansMainResponse = `{
+   "solr-mbeans": [
+@@ -905,8 +904,7 @@ const mBeansMainResponse = `{
+     "QTime": 8,
+     "status": 0
+   }
+-}
+-`
++}`
+ 
+ const mBeansCore1Response = `{
+   "solr-mbeans": [
+@@ -1748,8 +1746,7 @@ const mBeansCore1Response = `{
+     "QTime": 5,
+     "status": 0
+   }
+-}
+-`
++}`
+ 
+ var solrAdminMainCoreStatusExpected = map[string]interface{}{
+ 	"num_docs":      int64(168943425),