fix influxdb
This commit is contained in:
parent
ad795b1f76
commit
ec0cbca6d8
@ -54,15 +54,9 @@ get_precision(Timestamp) when is_integer(Timestamp) ->
|
|||||||
-spec write_data(Measurement :: binary(), Tags :: map(), FieldsList :: list(), Timestamp :: integer()) -> no_return().
|
-spec write_data(Measurement :: binary(), Tags :: map(), FieldsList :: list(), Timestamp :: integer()) -> no_return().
|
||||||
write_data(Measurement, Tags, FieldsList, Timestamp) when is_binary(Measurement), is_map(Tags), is_list(FieldsList), is_integer(Timestamp) ->
|
write_data(Measurement, Tags, FieldsList, Timestamp) when is_binary(Measurement), is_map(Tags), is_list(FieldsList), is_integer(Timestamp) ->
|
||||||
%% 按照设备的uuid进行分组
|
%% 按照设备的uuid进行分组
|
||||||
Points = lists:map(fun(Fields) ->
|
Points = lists:map(fun(Fields = #{<<"key">> := Key}) ->
|
||||||
NFields = case Fields of
|
Values = maps:remove(<<"key">>, Fields),
|
||||||
#{<<"key">> := Key, <<"value">> := Value, <<"unit">> := Unit, <<"name">> := Name, <<"label">> := Label} ->
|
NFields = #{Key => jiffy:encode(Values, [force_utf8])},
|
||||||
#{Key => jiffy:encode(#{<<"value">> => Value, <<"unit">> => Unit, <<"name">> => Name, <<"label">> => Label}, [force_utf8])};
|
|
||||||
#{<<"key">> := Key, <<"value">> := Value, <<"unit">> := Unit} ->
|
|
||||||
#{Key => jiffy:encode(#{<<"value">> => Value, <<"unit">> => Unit}, [force_utf8])};
|
|
||||||
#{<<"key">> := Key, <<"value">> := Value} ->
|
|
||||||
#{Key => #{<<"value">> => Value}}
|
|
||||||
end,
|
|
||||||
influx_point:new(Measurement, Tags, NFields, Timestamp)
|
influx_point:new(Measurement, Tags, NFields, Timestamp)
|
||||||
end, FieldsList),
|
end, FieldsList),
|
||||||
Precision = influx_client:get_precision(Timestamp),
|
Precision = influx_client:get_precision(Timestamp),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user