fix(emqx_bridge_api): fix aggregate_metrics
This commit is contained in:
parent
90ca08a34e
commit
015027d44a
|
@ -401,12 +401,12 @@ collect_status(Bridges) ->
|
||||||
[maps:with([node, status], B) || B <- Bridges].
|
[maps:with([node, status], B) || B <- Bridges].
|
||||||
|
|
||||||
aggregate_status(AllStatus) ->
|
aggregate_status(AllStatus) ->
|
||||||
AllConnected = lists:all(fun (#{status := connected}) -> true;
|
Head = fun ([A | _]) -> A end,
|
||||||
(_) -> false
|
HeadVal = maps:get(status, Head(AllStatus), connecting),
|
||||||
end, AllStatus),
|
AllRes = lists:all(fun (#{status := Val}) -> Val == HeadVal end, AllStatus),
|
||||||
case AllConnected of
|
case AllRes of
|
||||||
true -> connected;
|
true -> HeadVal;
|
||||||
false -> disconnected
|
false -> inconsistent
|
||||||
end.
|
end.
|
||||||
|
|
||||||
collect_metrics(Bridges) ->
|
collect_metrics(Bridges) ->
|
||||||
|
@ -423,13 +423,12 @@ aggregate_metrics(AllMetrics) ->
|
||||||
format_resp(#{id := Id, raw_config := RawConf,
|
format_resp(#{id := Id, raw_config := RawConf,
|
||||||
resource_data := #{status := Status, metrics := Metrics}}) ->
|
resource_data := #{status := Status, metrics := Metrics}}) ->
|
||||||
{Type, BridgeName} = emqx_bridge:parse_bridge_id(Id),
|
{Type, BridgeName} = emqx_bridge:parse_bridge_id(Id),
|
||||||
IsConnected = fun(connected) -> connected; (_) -> disconnected end,
|
|
||||||
RawConf#{
|
RawConf#{
|
||||||
id => Id,
|
id => Id,
|
||||||
type => Type,
|
type => Type,
|
||||||
name => maps:get(<<"name">>, RawConf, BridgeName),
|
name => maps:get(<<"name">>, RawConf, BridgeName),
|
||||||
node => node(),
|
node => node(),
|
||||||
status => IsConnected(Status),
|
status => Status,
|
||||||
metrics => format_metrics(Metrics)
|
metrics => format_metrics(Metrics)
|
||||||
}.
|
}.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue