litellm - ✅(Solved) Fix [Feature]: Add organization into the metrics metadata the same as we have for teams [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#24251Fetched 2026-04-08 01:09:02
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
labeled ×2commented ×1cross-referenced ×1

Fix Action

Fixed

PR fix notes

PR #24440: Feat - Add organization into the metrics metadata for org_id & org_alias

Description (problem / solution / changelog)

Relevant issues

Resolves #24251

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • [ x] I have Added testing in the tests/test_litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Type

<!-- Select the type of Pull Request --> <!-- Keep only the necessary ones -->

🆕 New Feature

Changes

Add org_id and org_alias labels to per-request Prometheus metrics, gated behind a prometheus_emit_org_labels feature flag (default False).

  • New flag: litellm.prometheus_emit_org_labels
  • org_alias is sourced from the org table via the existing SQL combined view
  • Labels are injected at schema registration time via get_labels() — no breaking change for existing deployments
  • Applies to request/spend/latency/token metrics; budget metrics are excluded

Changed files

  • litellm/__init__.py (modified, +1/-0)
  • litellm/integrations/prometheus.py (modified, +6/-0)
  • litellm/proxy/_types.py (modified, +1/-0)
  • litellm/proxy/litellm_pre_call_utils.py (modified, +1/-0)
  • litellm/proxy/utils.py (modified, +1/-0)
  • litellm/types/integrations/prometheus.py (modified, +35/-1)
  • litellm/types/utils.py (modified, +1/-0)
  • tests/test_litellm/integrations/test_prometheus_client_ip_user_agent.py (modified, +2/-0)
  • tests/test_litellm/integrations/test_prometheus_user_team_metrics.py (modified, +67/-0)
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

The Feature

Current: route="/embeddings",status_code="200",team="TL-ALP:AIR_TEAM_AGENT_BUILDER",team_alias="Agent Builder",... Requested route="/embeddings",status_code="200",team="TL-ALP:AIR_TEAM_AGENT_BUILDER",team_alias="Agent Builder",organization="Kevins_friends",...

Motivation, pitch

Have both org and org alias

What part of LiteLLM is this about?

No response

LiteLLM is hiring a founding backend engineer, are you interested in joining us and shipping to all our users?

No

Twitter / LinkedIn details

No response

extent analysis

Fix Plan

To add the organization field to the existing log output, we need to modify the logging configuration.

  • Update the logging format to include the organization field.
  • Ensure that the organization value is available in the logging context.

Example Code

# Assuming a Python logging setup
import logging

# Define the logging format with the new organization field
logging_format = (
    'route="{route}",status_code="{status_code}",'
    'team="{team}",team_alias="{team_alias}",'
    'organization="{organization}"'
)

# Create a logger
logger = logging.getLogger(__name__)

# Log an example message with the new organization field
logger.info(
    logging_format.format(
        route="/embeddings",
        status_code="200",
        team="TL-ALP:AIR_TEAM_AGENT_BUILDER",
        team_alias="Agent Builder",
        organization="Kevins_friends"
    )
)

Verification

To verify that the fix worked, check the log output for the presence of the organization field.

  • Run the updated application and trigger the logging statement.
  • Check the log output for the expected format, including the organization field.

Extra Tips

  • Ensure that the organization value is correctly populated in the logging context to avoid empty or incorrect values.
  • Consider using a logging library or framework that supports dynamic logging formats and field injection.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

litellm - ✅(Solved) Fix [Feature]: Add organization into the metrics metadata the same as we have for teams [1 pull requests, 1 comments, 2 participants]