I'm trying to build a fluentd pipeline that pulls data from an API and puts it in PostgresQL:
<source>
@type http_pull
tag energydata
url http://10.0.0.30:8080/data
interval 10s
format json
</source>
# Record from source looks like this (I've sent it to stdout to verify):
# {
# "url":"http://10.0.0.30:8080/data",
# "status":200,
# "message":
# {
# "timestamp":"2022-12-01T09:28:43Z",
# "currentPowerConsumption":0.429
# }
# }
<match energydata>
@type sql
host 10.0.0.10
port 5432
database energy
adapter postgresql
username fluent
password somepasswd
<table>
table energymeterdata
column_mapping '$.message.timestamp:timestamp,$.message.currentPowerConsumption:currentPowerConsumption'
</table>
</match>
The resulting SQL row contains only NULL values. What is the right syntax for the record_accessor in the column_mapping?
I've tried different syntaxes and quote styles for the record_accessor use in the column mapping, but I can't find the right format.
Before knowing it should be possible with the record accessor (as claimed by one of the maintainers in a Github issue) I tried flattening the JSON structure, but I could not get that to work either. I prefer the approach mentioned in this post, because it is a cleaner solution. It seems this is a fairly basic scenario and I may be overlooking something.