The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
[Feat] UI - Add `end_user` filter on UI (#12663)
Ishaan Jaff538339e1a88c
diff --git a/ui/litellm-dashboard/src/components/common_components/filter.tsx b/ui/litellm-dashboard/src/components/common_components/filter.tsxindex 8351ea791ad..20b11447b21 100644--- a/ui/litellm-dashboard/src/components/common_components/filter.tsx+++ b/ui/litellm-dashboard/src/components/common_components/filter.tsx@@ -87,6 +87,7 @@ const FilterComponent: React.FC<FilterComponentProps> = ({"Organization ID","Key Alias","User ID",+ "End User","Key Hash","Model"];diff --git a/ui/litellm-dashboard/src/components/networking.tsx b/ui/litellm-dashboard/src/components/networking.tsxindex ada75f9754e..421f87e4e5f 100644--- a/ui/litellm-dashboard/src/components/networking.tsx+++ b/ui/litellm-dashboard/src/components/networking.tsx@@ -2401,6 +2401,7 @@ export const uiSpendLogsCall = async (page?: number,page_size?: number,user_id?: string,+ end_user?: string,status_filter?: string,model?: string) => {@@ -2418,6 +2419,7 @@ export const uiSpendLogsCall = async (if (page) queryParams.append("page", page.toString());if (page_size) queryParams.append("page_size", page_size.toString());if (user_id) queryParams.append("user_id", user_id);+ if (end_user) queryParams.append("end_user", end_user);if (status_filter) queryParams.append("status_filter", status_filter);if (model) queryParams.append("model", model);// Append query parameters to URL if any existdiff --git a/ui/litellm-dashboard/src/components/view_logs/index.tsx b/ui/litellm-dashboard/src/components/view_logs/index.tsxindex 10ba2dc3465..7fe5d6b43fe 100644--- a/ui/litellm-dashboard/src/components/view_logs/index.tsx+++ b/ui/litellm-dashboard/src/components/view_logs/index.tsx@@ -3,7 +3,7 @@ import { useQuery } from "@tanstack/react-query";import { useState, useRef, useEffect, useCallback } from "react";import { useQueryClient } from "@tanstack/react-query";-import { uiSpendLogsCall, keyInfoV1Call, sessionSpendLogsCall, keyListCall } from "../networking";+import { uiSpendLogsCall, keyInfoV1Call, sessionSpendLogsCall, keyListCall, allEndUsersCall } from "../networking";import { DataTable } from "./table";import { columns, LogEntry } from "./columns";import { Row } from "@tanstack/react-table";@@ -442,7 +442,7 @@ export default function SpendLogsTable({searchFn: async (searchText: string) => {if (!accessToken) return [];const keyAliases = await fetchAllKeyAliases(accessToken);- const filtered = keyAliases.filter(alias =>+ const filtered = keyAliases.filter(alias =>alias.toLowerCase().includes(searchText.toLowerCase()));return filtered.map(alias => ({@@ -451,6 +451,20 @@ export default function SpendLogsTable({}));}},+ {+ name: 'End User',+ label: 'End User',+ isSearchable: true,+ searchFn: async (searchText: string) => {+ if (!accessToken) return [];+ const data = await allEndUsersCall(accessToken);+ const users = data?.end_users || [];+ const filtered = users.filter((u: string) =>+ u.toLowerCase().includes(searchText.toLowerCase())+ );+ return filtered.map((u: string) => ({ label: u, value: u }));+ }+ },{name: 'Key Hash',label: 'Key Hash',diff --git a/ui/litellm-dashboard/src/components/view_logs/log_filter_logic.tsx b/ui/litellm-dashboard/src/components/view_logs/log_filter_logic.tsxindex e61bfbf109b..73b9d944083 100644--- a/ui/litellm-dashboard/src/components/view_logs/log_filter_logic.tsx+++ b/ui/litellm-dashboard/src/components/view_logs/log_filter_logic.tsx@@ -14,6 +14,7 @@ export const FILTER_KEYS = {REQUEST_ID: "Request ID",MODEL: "Model",USER_ID: "User ID",+ END_USER: "End User",STATUS: "Status",KEY_ALIAS: "Key Alias",} as const;@@ -48,6 +49,7 @@ export function useLogFilterLogic({[FILTER_KEYS.REQUEST_ID]: "",[FILTER_KEYS.MODEL]: "",[FILTER_KEYS.USER_ID]: "",+ [FILTER_KEYS.END_USER]: "",[FILTER_KEYS.STATUS]: "",[FILTER_KEYS.KEY_ALIAS]: ""}), []);@@ -77,6 +79,7 @@ export function useLogFilterLogic({page,pageSize,filters[FILTER_KEYS.USER_ID] || undefined,+ filters[FILTER_KEYS.END_USER] || undefined,filters[FILTER_KEYS.STATUS] || undefined,filters[FILTER_KEYS.MODEL] || undefined);@@ -151,6 +154,12 @@ export function useLogFilterLogic({log => log.api_key === filters[FILTER_KEYS.KEY_HASH]);}++ if (filters[FILTER_KEYS.END_USER]) {+ filteredData = filteredData.filter(+ log => log.end_user === filters[FILTER_KEYS.END_USER]+ );+ }// Add key alias filteringif (filters[FILTER_KEYS.KEY_ALIAS]) {