Repository: influxdata/telegraf (2026-03-31T03:48:59Z)

Issue:
[inputs.turbostat] Unable to parse column "usec": strconv.ParseFloat error
### Relevant telegraf.conf

```toml
[[inputs.turbostat]]
    interval = "60s"
    use_sudo = true
    fieldexclude = ["usec"] # Current workaround for parse error
    fieldinclude = ["package_power_watt"]
```

### Logs from Telegraf

```text
E! [inputs.turbostat] Error in plugin: unable to parse column "usec": strconv.ParseFloat: parsing "usec": invalid syntax
```

### System info

Telegraf version: 1.37.1 ; OS: Debian 13;  CPU: Affects both AMD and Intel servers; Turbostat version: 2024.07.26

### Docker

_No response_

### Steps to reproduce

  Steps to Reproduce

  1. Configure telegraf with [[inputs.turbostat]] plugin on Debian 13
  2. Run telegraf with the turbostat input enabled
  3. Observe the error in telegraf logs

### Expected behavior

  The turbostat plugin should successfully parse all columns from the turbostat output without errors.

### Actual behavior

Telegraf logs an error about parsing the "usec" column:

  E! [inputs.turbostat] Error in plugin: unable to parse column "usec": strconv.ParseFloat: parsing "usec": invalid syntax

  Note: Despite the error, metrics specified in fieldinclude (e.g., package_power_watt) are still successfully collected. The error appears to be cosmetic but fills logs with unnecessary error messages.

### Additional info

Attempted workaround: fieldexclude = ["usec"] does not help - the error persists.


Discussion:
@valiknvk can you please send the output of `turbostat --quiet --show all` here?
> [@valiknvk](https://github.com/valiknvk) can you please send the output of `turbostat --quiet --show all` here?

```
usec	Time_Of_Day_Seconds	Core	CPU	APIC	X2APIC	Avg_MHz	Busy%	Bzy_MHz	TSC_MHz	IPC	IRQ	SMI	POLL	C1	C2	POLL%	C1%	C2%	CorWatt	PkgWatt
 1818	1769331918.132414	-	-	-	-	2408	61.12	3940	3108	1.09	526175	0	1002	106930	137211	0.02	4.62	34.45	80.30	90.14
   96	1769331918.130692	0	0	0	0	1414	36.08	3920	3100	0.87	19305	0	57	3543	7816	0.03	4.78	59.24	6.84	89.81
   52	1769331918.130758	0	12	1	1	3304	83.85	3940	3100	1.05	20464	0	21	1182	2350	0.01	1.71	14.47
   86	1769331918.130859	1	1	2	2	1651	42.10	3921	3100	0.92	18396	0	62	3782	7665	0.03	3.80	54.17	7.19
   60	1769331918.130939	1	13	3	3	3491	88.65	3938	3100	1.11	17006	0	15	1081	1439	0.01	1.11	10.25
   65	1769331918.131018	2	2	4	4	2060	52.39	3931	3100	1.01	24454	0	51	13318	6105	0.03	7.08	40.67	7.29
   47	1769331918.131081	2	14	5	5	2769	70.44	3931	3100	1.11	21748	0	26	1477	3640	0.02	2.11	27.50
  101	1769331918.131199	4	3	8	8	1555	39.64	3923	3100	1.08	14441	0	46	3142	6541	0.03	2.79	57.66	7.47
   51	1769331918.131268	4	15	9	9	3483	88.37	3941	3100	1.28	6488	0	10	3219	1521	0.00	2.02	9.65
   65	1769331918.131348	5	4	10	10	1913	48.77	3923	3100	0.99	34971	0	44	8246	10618	0.02	8.60	42.79	7.22
   40	1769331918.131403	5	16	11	11	3171	80.60	3934	3100	1.07	19921	0	20	932	2583	0.01	1.30	18.13
   67	1769331918.131483	6	5	12	12	2175	55.36	3930	3100	1.03	26516	0	51	7791	8152	0.03	7.06	37.72	7.77
   51	1769331918.131551	6	17	13	13	3160	80.27	3937	3100	1.11	21929	0	25	3207	3213	0.02	2.58	17.21
  101	1769331918.131675	8	6	16	16	1950	49.68	3926	3100	1.14	23358	0	42	4477	8236	0.03	4.76	45.67	6.97
   49	1769331918.131743	8	18	17	17	3168	80.52	3934	3100	1.34	27988	0	24	1055	2293	0.01	1.48	18.03
   67	1769331918.131822	9	7	18	18	2168	55.26	3924	3100	1.07	23930	0	36	4339	7033	0.02	4.34	40.50	6.50
   51	1769331918.131890	9	19	19	19	3059	77.84	3930	3100	1.05	22227	0	26	1297	2848	0.02	1.40	20.80
   47	1769331918.131952	10	8	20	20	2180	55.55	3925	3100	0.99	18836	0	36	1828	5470	0.02	2.50	42.02	7.01
   41	1769331918.132008	10	20	21	21	3390	86.08	3938	3100	1.33	20020	0	14	587	1612	0.01	0.96	12.98
   76	1769331918.132096	12	9	24	24	1921	49.03	3919	3100	1.02	24994	0	62	6450	7450	0.03	7.35	43.73	5.29
   39	1769331918.132145	12	21	25	25	1948	49.69	3921	3100	0.91	28375	0	55	9250	8021	0.03	9.57	40.87
   80	1769331918.132235	13	10	26	26	1473	37.64	3913	3100	0.85	27286	0	96	8787	9965	0.04	10.99	51.52	4.40
   38	1769331918.132290	13	22	27	27	1724	44.06	3913	3100	0.97	21512	0	76	7540	8935	0.04	10.02	46.04
   61	1769331918.132360	14	11	28	28	1353	34.54	3916	3100	0.83	21090	0	80	8090	10935	0.04	8.65	56.97	6.10
   39	1769331918.132414	14	23	29	29	3160	80.38	3931	3100	1.30	20920	0	27	2310	2770	0.01	3.56	16.11
```
Hi, I've been looking into this and traced the root cause.

**Proposed approach:** In the turbostat parser (plugins/inputs/turbostat/), add error handling around strconv.ParseFloat for column values — if parsing fails, log a debug warning and skip the column rather than erroring. The 'usec' column header string hits the parser before fieldexclude filtering can take effect, so the fix must be at the parsing level. Need to also add a test case with non-numeric column data.

I'll open a draft PR shortly. Happy to adjust based on your preference.



Patch:
diff --git a/plugins/inputs/turbostat/turbostat.go b/plugins/inputs/turbostat/turbostat.go
index 48671e602ead5..e3553792a346d 100644
--- a/plugins/inputs/turbostat/turbostat.go
+++ b/plugins/inputs/turbostat/turbostat.go
@@ -10,6 +10,7 @@ import (
 	"fmt"
 	"io"
 	"regexp"
+	"slices"
 	"strconv"
 	"strings"
 	"time"
@@ -122,17 +123,16 @@ func (t *Turbostat) Start(acc telegraf.Accumulator) error {
 			acc.AddError(scanner.Err())
 			return
 		}
-		header := scanner.Text()
-		columns := make([]column, 0, 50)
-		for _, s := range strings.Fields(header) {
+		headerFields := strings.Fields(scanner.Text())
+		columns := make([]column, 0, len(headerFields))
+		for _, s := range headerFields {
 			columns = append(columns, createColumn(s))
 		}
 		for scanner.Scan() {
-			line := scanner.Text()
-			if line == header {
+			values := strings.Fields(scanner.Text())
+			if slices.Equal(values, headerFields) {
 				continue
 			}
-			values := strings.Fields(line)
 			acc.AddError(processValues(acc, columns, values))
 		}
 		acc.AddError(scanner.Err())


Test patch:
diff --git a/plugins/inputs/turbostat/testcases/usec-whitespace-header/expected.out b/plugins/inputs/turbostat/testcases/usec-whitespace-header/expected.out
new file mode 100644
index 0000000000000..b0b6bc9661a27
--- /dev/null
+++ b/plugins/inputs/turbostat/testcases/usec-whitespace-header/expected.out
@@ -0,0 +1,4 @@
+turbostat,core=-,cpu=- average_frequency_mhz=41,busy_frequency_mhz=3431,busy_percent=1.2,tsc_frequency_mhz=3793,usec=500
+turbostat,core=0,cpu=0 average_frequency_mhz=34,busy_frequency_mhz=3083,busy_percent=1.09,tsc_frequency_mhz=3793,usec=30
+turbostat,core=-,cpu=- average_frequency_mhz=50,busy_frequency_mhz=3500,busy_percent=1.5,tsc_frequency_mhz=3793,usec=600
+turbostat,core=0,cpu=0 average_frequency_mhz=44,busy_frequency_mhz=3100,busy_percent=1.19,tsc_frequency_mhz=3793,usec=40
diff --git a/plugins/inputs/turbostat/testcases/usec-whitespace-header/input.txt b/plugins/inputs/turbostat/testcases/usec-whitespace-header/input.txt
new file mode 100644
index 0000000000000..b3f9b1567dd1e
--- /dev/null
+++ b/plugins/inputs/turbostat/testcases/usec-whitespace-header/input.txt
@@ -0,0 +1,6 @@
+usec	Time_Of_Day_Seconds	Core	CPU	Avg_MHz	Busy%	Bzy_MHz	TSC_MHz
+  500	1745932475.967756	-	-	41	1.20	3431	3793
+   30	1745932475.966844	0	0	34	1.09	3083	3793
+usec	 Time_Of_Day_Seconds	 Core	 CPU	 Avg_MHz	 Busy%	 Bzy_MHz	 TSC_MHz
+  600	1745932476.967756	-	-	50	1.50	3500	3793
+   40	1745932476.966844	0	0	44	1.19	3100	3793
diff --git a/plugins/inputs/turbostat/testcases/usec-whitespace-header/telegraf.conf b/plugins/inputs/turbostat/testcases/usec-whitespace-header/telegraf.conf
new file mode 100644
index 0000000000000..b4d44dac62f39
--- /dev/null
+++ b/plugins/inputs/turbostat/testcases/usec-whitespace-header/telegraf.conf
@@ -0,0 +1,1 @@
+[[inputs.turbostat]]