fix: prevent unexcepted square brackets in influxdb line protocol

This commit is contained in:
JimMoen 2022-08-08 10:38:52 +08:00
parent 33a604dcaa
commit 06f246a896
1 changed files with 9 additions and 7 deletions

View File

@ -379,9 +379,10 @@ data_to_point(
end. end.
maps_config_to_data(K, {IntType, V}, {Data, Res}) when IntType == int orelse IntType == uint -> maps_config_to_data(K, {IntType, V}, {Data, Res}) when IntType == int orelse IntType == uint ->
TransOptions = #{return => rawlist, var_trans => fun data_filter/1}, KTransOptions = #{return => full_binary},
NK = emqx_plugin_libs_rule:proc_tmpl(K, Data, TransOptions), VTransOptions = #{return => rawlist, var_trans => fun data_filter/1},
NV = emqx_plugin_libs_rule:proc_tmpl(V, Data, TransOptions), NK = emqx_plugin_libs_rule:proc_tmpl(K, Data, KTransOptions),
NV = emqx_plugin_libs_rule:proc_tmpl(V, Data, VTransOptions),
case {NK, NV} of case {NK, NV} of
{[undefined], _} -> {[undefined], _} ->
{Data, Res}; {Data, Res};
@ -391,16 +392,17 @@ maps_config_to_data(K, {IntType, V}, {Data, Res}) when IntType == int orelse Int
{Data, Res#{NK => {IntType, IntV}}} {Data, Res#{NK => {IntType, IntV}}}
end; end;
maps_config_to_data(K, V, {Data, Res}) -> maps_config_to_data(K, V, {Data, Res}) ->
TransOptions = #{return => rawlist, var_trans => fun data_filter/1}, KTransOptions = #{return => full_binary},
NK = emqx_plugin_libs_rule:proc_tmpl(K, Data, TransOptions), VTransOptions = #{return => rawlist, var_trans => fun data_filter/1},
NV = emqx_plugin_libs_rule:proc_tmpl(V, Data, TransOptions), NK = emqx_plugin_libs_rule:proc_tmpl(K, Data, KTransOptions),
NV = emqx_plugin_libs_rule:proc_tmpl(V, Data, VTransOptions),
case {NK, NV} of case {NK, NV} of
{[undefined], _} -> {[undefined], _} ->
{Data, Res}; {Data, Res};
{_, [undefined]} -> {_, [undefined]} ->
{Data, Res}; {Data, Res};
_ -> _ ->
{Data, Res#{bin(NK) => NV}} {Data, Res#{NK => NV}}
end. end.
data_filter(undefined) -> undefined; data_filter(undefined) -> undefined;