Hey!
I am scratching my head over this one.
I have the following output code:
[[outputs.file]]
data_format = "json"
#json_transformation = '{"power_in_w": fields.power, "timestamp": timestamp, "user_id": "${USER_ID}"}'
files = ["stdout"]
[[outputs.file]]
data_format = "json"
json_transformation = '{"power_in_w": fields.power, "timestamp": timestamp, "user_id": "${USER_ID}", "test": name}'
files = ["stdout"]
[[outputs.http]]
url = "${CPOWER_API}"
method = "POST"
headers = {Content-Type = "application/json; charset=utf-8"}
data_format = "json"
json_transformation = '{"power_in_w": fields.power, "timestamp": timestamp, "user_id": "${USER_ID}", "test": name}'
Now I would expect stdout and http to have the same content, but on stdout I get:
{"power_in_w":-3097,"test":"energy_ems","timestamp":1733977581,"user_id":"1ed2a99b-51ce-4491-a09c-261f803112e6"}
while on http (e.g. with webhook.site) I get:
{
"user_id": "1ed2a99b-51ce-4491-a09c-261f803112e6"
}
Now I tested this a little bit and what I noticed is, that I only get a value in my http output, when the JSONata is getting direct values instead of fields, so for example “power_in_w”: 123 reaches the endpoint:
{
"power_in_w": 123,
"user_id": "1ed2a99b-51ce-4491-a09c-261f803112e6"
}
So I thought I formatted my JSONata wrong, but I don’t think so because why would it then print on stdout?
I also tried to call $number() and $string() around fields.power to see whether anything comes through, but to no avail. I have no clue what’s wrong here. Why would it create a different string based on what output plugin I use? This makes no sense.
So where do I go from here? Is this a bug?