[sr-dev] [kamailio/kamailio] usrloc Stats are not compatible with Prometheus (xhttp_prom module) (#2644)

Sebastian Damm notifications at github.com
Mon Feb 22 17:32:57 CET 2021


### Description

We tried to use the `xhttp_prom`  module, but our Prometheus couldn't read it, because of metrics conflicting with Prometheus data model.

For us, the problem lies in the usrloc module. It exports the following metrics:

```
usrloc:location-contacts = 0
usrloc:location-expires = 0
usrloc:location-users = 0
usrloc:registered_users = 0
```

However, Prometheus allows only ascii characters and digits, as well as underscores and colons. 
See: https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels

The metrics names should not contain `-`, so they should get converted to `_`.

#### Reproduction

Setup Kamailio with `usrloc`, `xhttp` and `xhttp_prom` module and let Prometheus query it. It will stumble upon the first entry of `usrloc` module stats.

### Possible Solutions

Either the `usrloc` module could export its stats with the dash replaced by underscores, or the xhttp_prom module could sanitize the output. The first one would be a breaking change, I guess, making this a change for a major release.

### Additional Information

  * **Kamailio Version** - output of `kamailio -v`

```
root at ifens5:/# kamailio -v
version: kamailio 5.3.8 (x86_64/linux)
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown
compiled with gcc 7.5.0```

* **Operating System**:

```
Ubuntu 18.04
```


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2644
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20210222/d25a261b/attachment.htm>


More information about the sr-dev mailing list