joelsdc created an issue (kamailio/kamailio#4508)
## Description
When configuring
[xhttp_prom_tags](https://www.kamailio.org/docs/modules/stable/modules/xhttp_prom.html#xhttp_prom.p.xhttp_prom_tags)
with:
```
modparam("xhttp_prom", "xhttp_prom_uptime_stat", 1)
modparam("xhttp_prom", "xhttp_prom_stats", "all")
modparam("xhttp_prom", "xhttp_prom_pkg_stats", 1)
modparam("xhttp_prom", "xhttp_prom_tags", "hostname=kamailio-test");
```
The exported metric label has two issues:
### 1. The tag value is not quoted.
Expected: {hostname="kamailio-test"}
Got: {hostname=kamailio-test})
Example:
```
kamailio_pkgmem_used{pid="659543", rank="0", desc="main process - attendant",
hostname=kamailio-test} 1608112 1764746152403
```
This casuses Prometheus to error:
```
Error scraping target: expected label value, got "k" ("INVALID") while parsing:
"kamailio_pkgmem_used{pid=\"5208\", rank=\"0\", desc=\"main process -
attendant\", hostname=k"
```
### 2. The tag value has `-` replaced with `_`.
Expected: `kamailio-test` as tag value in all metrics.
Got: `kamailio_test` only for the **Kamailio internal statistics** metrics.f
Example:
```
kamailio_core_rcv_replies_18x{hostname=kamailio_test} 0 1764746152403
```
## Troubleshooting
## Reproduction
Load xhttp_prom.
Configure:
```
modparam("xhttp_prom", "xhttp_prom_uptime_stat", 1)
modparam("xhttp_prom", "xhttp_prom_stats", "all")
modparam("xhttp_prom", "xhttp_prom_pkg_stats", 1)
modparam("xhttp_prom", "xhttp_prom_tags", "hostname=kamailio-test");
```
And the minimal config in http event_route:
```
event_route[xhttp:request] {
# Prometheus metrics endpoint
if (prom_check_uri()) {
prom_dispatch();
exit;
}
xhttp_reply("404", "Not found", "text/html", "<html><body>Wrong URL
$hu</body></html>");
return;
}
```
Start Kamailio.
Fetch `/metrics` (e.g., `curl -s http://<kamailio-ip>:<port>/metrics`).
Observe the labels on the exported metrics.
### Debugging Data
<!--
If you got a core dump, use gdb to extract troubleshooting data - full
backtrace,
local variables and the list of the code at the issue location.
gdb /path/to/kamailio /path/to/corefile
bt full
info locals
list
If you are familiar with gdb, feel free to attach more of what you consider to
be relevant.
-->
```
(n/a - config/formatting issue; no crash)
```
### Log Messages
<!--
Check the syslog file and if there are relevant log messages printed by
Kamailio, add them next, or attach to issue, or provide a link to download them
(e.g., to a pastebin site).
-->
```
(n/a - no relevant errors logged)
```
### SIP Traffic
<!--
If the issue is exposed by processing specific SIP messages, grab them with
ngrep or save in a pcap file, then add them next, or attach to issue, or
provide a link to download them (e.g., to a pastebin site).
-->
```
(n/a)
```
## Possible Solutions
I tried setting:
`modparam("xhttp_prom", "xhttp_prom_tags", "hostname=\"kamailio-test\"");`
And using escaped double quotes in the tag value seemed to workaround the
quoting issue. I wan't able to get around the replacement of `-` for `_`.
I also don't know what other (if any) replacements/sanitizing is done.
## Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
version: kamailio 6.0.4 (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, MEM_JOIN_FREE, 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_BLOCKLIST, HAVE_RESOLV_RES,
TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_SEND_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 14.2.0
```
* **Operating System**:
<!--
Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu
16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...;
Kernel details (output of `lsb_release -a` and `uname -a`)
-->
```
Linux kamailio-test 6.12.48+deb13-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian
6.12.48-1 (2025-09-20) x86_64 GNU/Linux
Distributor ID: Debian
Description: Debian GNU/Linux 13 (trixie)
Release: 13
Codename: trixie
```
--
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/4508
You are receiving this because you are subscribed to this thread.
Message ID: <kamailio/kamailio/issues/[email protected]>_______________________________________________
Kamailio - Development Mailing List -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the
sender!