Troubleshooting
Fix InfluxDB invalid boolean from a NAS write
Short answer
The 400 invalid boolean response is a body-parse failure: the write body opens with a tag set instead of a measurement, and single quotes stop the shell expanding the variables. Send a complete line-protocol point such as disk_temperature,server=BackupNAS,disk=sda value=34, quote the body in double quotes, and expect 204 No Content to confirm the write.

On this page
InfluxDB's 400 invalid boolean answer is a body-parsing failure, not a network fault. The response headers prove the request arrived: they name build OSS and version v2.6.1, so the server at 192.168.38.189:8086 received the write and tried to parse it. The body fails twice over: server=BackupNAS,disk=$var value=$disk_temp opens with a tag set and never names a measurement, and the single quotes around it stopped the shell from expanding $var and $disk_temp. Send a complete point, disk_temperature,server=BackupNAS,disk=sda value=34, and put the body in double quotes so the shell substitutes the variables before curl sends it. The corrected request returns 204 No Content.
Read the HTTP response before touching the network #
Every write ends in one of three responses, and each points at a different layer:
- A timeout or connection refused means no HTTP response came back at all. Addressing, route and firewall rules for TCP 8086 are the suspects, not the data; the same separation of network fault from write fault drives fixing Node-RED InfluxDB write errors after a network outage.
- A 400 Bad Request carrying the header
X-Platform-Error-Code: invalidmeans InfluxDB got the request and rejected the body. Fix the line protocol and leave the network alone. - 204 No Content means the server accepted the point; verify it in the bucket.
The failed write answered 400 and echoed the body back verbatim: unable to parse 'server=BackupNAS,disk=$var value=$disk_temp': invalid boolean. That echo is the whole diagnosis. The same bare-curl isolation untangles a Telegraf 500 from InfluxDB 2.x when an agent rather than a script is the writer. A 401 response is the different fault of a missing or wrong token, covered in Fix Telegraf authorization not found on InfluxDB 2.
Shape the point in line-protocol order #
Line protocol reads one point in a fixed order: measurement name first, then optional comma-separated tags, then a space, then the field set, then an optional timestamp. server=BackupNAS,disk=$var value=$disk_temp opens with a tag set where the measurement belongs. The parser therefore takes value=$disk_temp as the field, cannot read it as a number or a quoted string, falls through to the boolean type and reports invalid boolean.
The same reading as a valid point:
disk_temperature,server=BackupNAS,disk=sda value=34
Here disk_temperature is the measurement, server and disk are the tags that identify machine and drive, and value is the numeric field. Leave the temperature unquoted so it stores as a number; quotes would store it as a string. Drop the timestamp and the server assigns one at write time, which is exactly what this job wants. If a name ever contains a space, comma or equals sign, escape it; BackupNAS and sda need no escapes.
Let the shell expand the variables #
In a POSIX-style shell, single quotes pass the text to curl byte for byte, dollar signs included. The echoed error proves those literals are what left the NAS. Double quotes make the shell substitute $var and $disk_temp first. The working request keeps the token in a variable instead of the command line:
curl -i -XPOST "http://192.168.38.189:8086/api/v2/write?org=home&bucket=synology-test" \
--header "Authorization: Token $INFLUX_TOKEN" \
--data-binary "disk_temperature,server=BackupNAS,disk=$var value=$disk_temp"
Check that the variable names match what the script assigns, and print the assembled line once while testing it. One safety rule: keep the token in $INFLUX_TOKEN, never paste the Authorization header into a forum, chat or log, and replace the token if it has already been posted.
Send all ten disks as one newline-separated batch #
Build one point per disk and join complete lines with newline characters; --data-binary sends the whole set in one request. Each line keeps the same measurement and its own disk tag, sda on the first drive and sdb on the second, plus its own numeric temperature.
The size is easy to check: the point disk_temperature,server=BackupNAS,disk=sda value=34 is 51 ASCII bytes, so ten lines with nine newline separators make 10 × 51 + 9 = 519 bytes. A full sweep of the ten-drive array fits in one small HTTP body.
Confirm the point landed in the bucket #
Query the synology-test bucket in the InfluxDB UI or through the Grafana data source. Each drive should appear under measurement disk_temperature with tags server=BackupNAS and its disk designation, and a numeric value field. Compare the stored numbers against the temperatures the NAS itself reports. When all ten drives show up with the right tag and a plausible value, the write is fixed; nothing in the script needs attention again until the token or the bucket changes.
Questions asked
Why does a numeric reading produce an invalid boolean error?
The parser tests the token after the field equals sign against the types it accepts. A bare unexpanded token, such as the literal text the single quotes preserved, is neither a quoted string nor a number it can read, so the parser rejects it while trying the boolean type and reports invalid boolean. Expand the variables, send a plain number, and the error disappears.
How do I keep the InfluxDB token out of the command and the logs?
Set the token in an environment variable the script owns and reference that variable inside the Authorization header, so the raw token never appears in the command line, shell history or process listing. If the token has already been posted in a forum or chat, treat it as compromised and issue a replacement in the InfluxDB UI.
Should the disk temperature be a tag or a field?
A field. Tags exist for the dimensions you filter and group by, here the server name and the disk designation, while the temperature changes with every reading and belongs in a field value. If a chart should show a named column instead of a generic value key, rename the field key to temperature and use that name in every line and every query.
The write returned 204 but the chart stays empty. What is wrong?
Most often the query is not looking where the write landed. Check that the Grafana data source points at the same organization and bucket the write used, org home and the synology-test bucket here, and widen the time range, because a dashboard that defaults to the last few minutes hides anything older. Run the script once more and refresh before suspecting data loss.

