fix(influxdb): refine influxdb bridge example
This commit is contained in:
parent
eb21a37145
commit
a481e8e2ee
|
@ -53,30 +53,53 @@ conn_bridge_examples(Method) ->
|
||||||
|
|
||||||
values(Protocol, get) ->
|
values(Protocol, get) ->
|
||||||
maps:merge(values(Protocol, post), ?METRICS_EXAMPLE);
|
maps:merge(values(Protocol, post), ?METRICS_EXAMPLE);
|
||||||
values(Protocol, post) ->
|
values("influxdb_api_v2", post) ->
|
||||||
case Protocol of
|
SupportUint = <<"uint_value=${payload.uint_key}u,">>,
|
||||||
"influxdb_api_v2" ->
|
TypeOpts = #{
|
||||||
SupportUint = <<"uint_value=${payload.uint_key}u,">>;
|
bucket => <<"example_bucket">>,
|
||||||
_ ->
|
org => <<"examlpe_org">>,
|
||||||
SupportUint = <<>>
|
token => <<"example_token">>,
|
||||||
end,
|
server => <<"127.0.0.1:8086">>
|
||||||
#{
|
},
|
||||||
|
values(common, "influxdb_api_v2", SupportUint, TypeOpts);
|
||||||
|
values("influxdb_api_v1", post) ->
|
||||||
|
SupportUint = <<>>,
|
||||||
|
TypeOpts = #{
|
||||||
|
database => <<"example_database">>,
|
||||||
|
username => <<"example_username">>,
|
||||||
|
password => <<"examlpe_password">>,
|
||||||
|
server => <<"127.0.0.1:8086">>
|
||||||
|
},
|
||||||
|
values(common, "influxdb_api_v1", SupportUint, TypeOpts);
|
||||||
|
values("influxdb_udp", post) ->
|
||||||
|
SupportUint = <<>>,
|
||||||
|
TypeOpts = #{
|
||||||
|
server => <<"127.0.0.1:8089">>
|
||||||
|
},
|
||||||
|
values(common, "influxdb_udp", SupportUint, TypeOpts);
|
||||||
|
values(Protocol, put) ->
|
||||||
|
values(Protocol, post).
|
||||||
|
|
||||||
|
values(common, Protocol, SupportUint, TypeOpts) ->
|
||||||
|
CommonConfigs = #{
|
||||||
type => list_to_atom(Protocol),
|
type => list_to_atom(Protocol),
|
||||||
name => <<"demo">>,
|
name => <<"demo">>,
|
||||||
connector => list_to_binary(Protocol ++ ":connector"),
|
|
||||||
enable => true,
|
enable => true,
|
||||||
direction => egress,
|
|
||||||
local_topic => <<"local/topic/#">>,
|
local_topic => <<"local/topic/#">>,
|
||||||
write_syntax =>
|
write_syntax =>
|
||||||
<<"${topic},clientid=${clientid}", " ", "payload=${payload},",
|
<<"${topic},clientid=${clientid}", " ", "payload=${payload},",
|
||||||
"${clientid}_int_value=${payload.int_key}i,", SupportUint/binary,
|
"${clientid}_int_value=${payload.int_key}i,", SupportUint/binary,
|
||||||
"bool=${payload.bool}">>,
|
"bool=${payload.bool}">>,
|
||||||
enable_batch => false,
|
precision => ms,
|
||||||
batch_size => 5,
|
resource_opts => #{
|
||||||
batch_time => <<"1m">>
|
enable_batch => false,
|
||||||
};
|
batch_size => 5,
|
||||||
values(Protocol, put) ->
|
batch_time => <<"1m">>
|
||||||
values(Protocol, post).
|
},
|
||||||
|
server => <<"127.0.0.1:8086">>,
|
||||||
|
ssl => #{enable => false}
|
||||||
|
},
|
||||||
|
maps:merge(TypeOpts, CommonConfigs).
|
||||||
|
|
||||||
%% -------------------------------------------------------------------------------------------------
|
%% -------------------------------------------------------------------------------------------------
|
||||||
%% Hocon Schema Definitions
|
%% Hocon Schema Definitions
|
||||||
|
@ -124,7 +147,7 @@ method_fileds(put, ConnectorType) ->
|
||||||
influxdb_bridge_common_fields() ->
|
influxdb_bridge_common_fields() ->
|
||||||
emqx_bridge_schema:common_bridge_fields() ++
|
emqx_bridge_schema:common_bridge_fields() ++
|
||||||
[
|
[
|
||||||
{local_topic, mk(binary(), #{required => true, desc => ?DESC("local_topic")})},
|
{local_topic, mk(binary(), #{desc => ?DESC("local_topic")})},
|
||||||
{write_syntax, fun write_syntax/1}
|
{write_syntax, fun write_syntax/1}
|
||||||
] ++
|
] ++
|
||||||
emqx_resource_schema:fields("resource_opts").
|
emqx_resource_schema:fields("resource_opts").
|
||||||
|
|
Loading…
Reference in New Issue