Skip to content

Commit

Permalink
convert IPs in metrics in something readable
Browse files Browse the repository at this point in the history
  • Loading branch information
RoadRunnr committed Dec 9, 2019
1 parent 192369e commit 0f84207
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/ergw_prometheus.erl
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ gtp(Direction, #gtp_port{name = Name, type = 'gtp-c'},
gtp(Direction, #gtp_port{name = Name, type = 'gtp-u'}, IP,
#gtp{version = Version, type = MsgType}) ->
prometheus_counter:inc(gtp_path_messages_processed_total,
[Name, IP, Direction, Version, MsgType]),
[Name, inet:ntoa(IP), Direction, Version, MsgType]),
prometheus_counter:inc(gtp_u_socket_messages_processed_total,
[Name, Direction, Version, MsgType]).

gtp_c_msg_counter(PathMetric, SocketMetric,
#gtp_port{name = Name, type = 'gtp-c'}, IP,
#gtp{version = Version, type = MsgType}) ->
prometheus_counter:inc(PathMetric, [Name, IP, Version, MsgType]),
prometheus_counter:inc(PathMetric, [Name, inet:ntoa(IP), Version, MsgType]),
prometheus_counter:inc(SocketMetric, [Name, Version, MsgType]).

%% gtp/5
Expand Down Expand Up @@ -154,7 +154,8 @@ gtp_request_duration(#gtp_port{name = Name}, Version, MsgType, Duration) ->

gtp_path_rtt(#gtp_port{name = Name}, RemoteIP, #gtp{version = Version, type = MsgType}, RTT) ->
prometheus_histogram:observe(
gtp_path_rtt_milliseconds, [Name, RemoteIP, Version, MsgType], RTT).
gtp_path_rtt_milliseconds, [Name, inet:ntoa(RemoteIP), Version, MsgType], RTT).

gtp_path_contexts(#gtp_port{name = Name}, RemoteIP, Version, Counter) ->
prometheus_gauge:set(gtp_path_contexts_total, [Name, RemoteIP, Version], Counter).
prometheus_gauge:set(
gtp_path_contexts_total, [Name, inet:ntoa(RemoteIP), Version], Counter).
8 changes: 4 additions & 4 deletions test/pgw_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1808,8 +1808,8 @@ interop_sgsn_to_sgw() ->
[{doc, "Check 3GPP T 23.401, Annex D, SGSN to SGW handover"}].
interop_sgsn_to_sgw(Config) ->
ClientIP = proplists:get_value(client_ip, Config),
CtxMetricV1 = ['irx-socket', ClientIP, v1],
CtxMetricV2 = ['irx-socket', ClientIP, v2],
CtxMetricV1 = ['irx-socket', inet:ntoa(ClientIP), v1],
CtxMetricV2 = ['irx-socket', inet:ntoa(ClientIP), v2],

{GtpC1, _, _} = ergw_ggsn_test_lib:create_pdp_context(Config),
?match_metric(prometheus_gauge, gtp_path_contexts_total, CtxMetricV1, 1),
Expand Down Expand Up @@ -1857,8 +1857,8 @@ interop_sgw_to_sgsn() ->
[{doc, "Check 3GPP T 23.401, Annex D, SGW to SGSN handover"}].
interop_sgw_to_sgsn(Config) ->
ClientIP = proplists:get_value(client_ip, Config),
CtxMetricV1 = ['irx-socket', ClientIP, v1],
CtxMetricV2 = ['irx-socket', ClientIP, v2],
CtxMetricV1 = ['irx-socket', inet:ntoa(ClientIP), v1],
CtxMetricV2 = ['irx-socket', inet:ntoa(ClientIP), v2],

{GtpC1, _, _} = create_session(Config),
?match_metric(prometheus_gauge, gtp_path_contexts_total, CtxMetricV2, 1),
Expand Down

0 comments on commit 0f84207

Please sign in to comment.