Commit Graph
6 Commits
Author SHA1 Message Date
michelligabrieleandGitHub 35eb303098 fix(prometheus): sanitize label values to prevent metric scrape failures (#20600)
* fix(prometheus): sanitize label values to prevent metric scrape failures

Unicode characters like U+2028 (Line Separator) in Prometheus label values
break the text exposition format, causing scrapers (e.g. Datadog) to fail
parsing the entire /metrics endpoint. One bad label value causes ALL metrics
to be lost, not just the affected metric.

Add _sanitize_prometheus_label_value() and apply it in prometheus_label_factory()
and all direct .labels() call sites.

* fix(prometheus): handle non-string label values in sanitization

Coerce non-string values (int, bool, float) to str before applying
sanitization, preventing AttributeError on .replace() calls.

* fix(prometheus): run sanitization on coerced non-string values

Non-string values should be coerced to str and then sanitized (not
returned early), so their string representations also get cleaned.

* fix(prometheus): widen type hint to Optional[Any] for label value sanitization
2026-02-09 15:48:59 -08:00
Sameer KankuteandGitHub c834d7d1fe Merge branch 'main' into litellm_oss_staging_01_27_2026 2026-01-27 17:11:15 +05:30
6a54dcfa93 feat: Add model_id label to Prometheus metrics (#18048) (#19678)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-01-26 20:32:08 -08:00
344ea3d9f2 feat: add clientip and user agent in metrics (#19717)
* feat: add clientip and user agent in metrics

* fix: lint errors

* Add model id and other req labels

---------

Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com>
2026-01-25 23:07:19 -08:00
Sameer Kankute 5f80e8d5e8 Fix for Prometheus Metric Cardinality Issue with /responses Endpoint 2026-01-20 15:28:09 +05:30
boopesh07 36299dbc73 Added user_email labels to the prometheus monitoring. 2025-09-12 15:38:23 -07:00