Outputs.file has different output than outputs.http with same data (json transformation)

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?

I am now abandoning telegraf as apparently I cannot get an answer to this. Disappointed to have invested so much time into this piece of software!

Hi!

Could you share which inputs you are using to test and an example?

Regards

Hello @camposb,
I’m sorry we missed your first. Sometimes questions just get buried and it can be helpful to come back after a day and comment. Please don’t wait so long again! Before commenting. That’s so frustrating though.

You’re correct you didn’t format your JSON data wrong if it’s printing to stdout as you’d expect.

Can you please explain this further?

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:

What do you mean by direct values instead of fields?

Can you also please share some example input data? So I can debug?
And full logs with debug=true?

Thank you!