Good stuff!! We use something similar too, so only stats served when
requested on 127.0.0.1/stats while
keeping websockets as usual.

I’m not good with grafana but it would be nice if anyone shares some
dashboard or graph ideas  that make the metrics look nice ;)

Joel.

On Fri, Mar 16, 2018 at 04:28 Karsten Horsmann <khorsm...@gmail.com> wrote:

> Hello Joel and List,
>
> okay i found a "maybe good" way to bind it to localhost without break WSS.
>
> Btw - if the returning lines of data within  var(metrics_count)  are
> higher than 100, the max_while_loops protection cuts off the rest.
>
> Mar 16 12:11:05 sipedge1 /usr/sbin/kamailio[3531]: ERROR: <core>
> [core/action.c:1348]: do_action(): runaway while (1049, 30): more then 100
> loops
> Mar 16 12:11:05 sipedge1 /usr/sbin/kamailio[3531]: ERROR: <core>
> [core/action.c:1505]: do_action(): run action error at:
> /etc/kamailio/kamailio.cfg:1055
>
> They you could disable or raise the value (i raised up the value).
> https://www.kamailio.org/wiki/cookbooks/5.0.x/core#max_while_loops
>
>
>
> [...]
> event_route[xhttp:request] {
>         set_reply_close();
>         set_reply_no_connect();
>
> #!ifdef WITH_JSONSTATS
>         if ($Rp == MY_HTTP_PORT && dst_ip == "127.0.0.1") {
>                 # Metrics endpoint
>                 if ( src_ip == "127.0.0.1" && $hu =~ "^/stats" ) {
>
>                         jsonrpc_exec('{"jsonrpc": "2.0","method":
> "stats.get_statistics","params": ["all"],"id": 1}');
>                         $var(metrics_count) = 0;
>                         jansson_array_size("result", $jsonrpl(body),
> "$var(total_metrics)");
>
>                         while($var(metrics_count) < $var(total_metrics)) {
>                             jansson_get("result[$var(metrics_count)]",
> $jsonrpl(body), "$var(v)");
>                             $var(metric_key) =
> $(var(v){s.select,0,=}{s.trim}{s.replace,:,-});
>                             $var(metric_value) =
> $(var(v){s.select,1,=}{s.trim});
>                             jansson_set("integer", "$var(metric_key)",
> "$var(metric_value)", "$var(metrics_json)");
>                             $var(metrics_count) = $var(metrics_count) + 1;
>                         }
>
>                         xhttp_reply("200", "OK", "application/json",
> "$var(metrics_count)");
>                         exit;
>
>                 }
>         }
> #!endif
>
>
>         if ($Rp != MY_WS_PORT
> [...]
>
>
>
>
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users

Reply via email to