SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
feat(llm-pricing): search + source filter (4/5) (#11808)
Gaurav Tewari9317a2633765
diff --git a/frontend/src/container/LLMObservability/Settings/ModelPricing/ModelCostTabPanel/ModelCostTabPanel.module.scss b/frontend/src/container/LLMObservability/Settings/ModelPricing/ModelCostTabPanel/ModelCostTabPanel.module.scssindex fda427d699..369ea10f92 100644--- a/frontend/src/container/LLMObservability/Settings/ModelPricing/ModelCostTabPanel/ModelCostTabPanel.module.scss+++ b/frontend/src/container/LLMObservability/Settings/ModelPricing/ModelCostTabPanel/ModelCostTabPanel.module.scss@@ -5,10 +5,24 @@justify-content: space-between;}+.filtersBarLeft {+ display: flex;+ gap: var(--spacing-6);+ align-items: center;+}++.filtersBarSearch {+ width: 280px;+}++.filtersBarSource {+ width: 160px;+}+.pageError {padding: var(--spacing-6) var(--spacing-8);border-radius: var(--radius-2);- background: color-mix(in srgb, var(--bg-cherry-400) 8%, transparent);- color: var(--text-cherry-400);+ background: color-mix(in srgb, var(--accent-cherry) 8%, transparent);+ color: var(--accent-cherry);font-size: var(--periscope-font-size-base);}diff --git a/frontend/src/container/LLMObservability/Settings/ModelPricing/ModelCostTabPanel/ModelCostTabPanel.tsx b/frontend/src/container/LLMObservability/Settings/ModelPricing/ModelCostTabPanel/ModelCostTabPanel.tsxindex 519a721d32..51ebae9003 100644--- a/frontend/src/container/LLMObservability/Settings/ModelPricing/ModelCostTabPanel/ModelCostTabPanel.tsx+++ b/frontend/src/container/LLMObservability/Settings/ModelPricing/ModelCostTabPanel/ModelCostTabPanel.tsx@@ -1,14 +1,28 @@import { useMemo } from 'react';import { Button } from '@signozhq/ui/button';+import { Input } from '@signozhq/ui/input';+import { SelectSimple } from '@signozhq/ui/select';import { Typography } from '@signozhq/ui/typography';-import { Plus } from '@signozhq/icons';+import { Plus, Search, X } from '@signozhq/icons';import { useListLLMPricingRules } from 'api/generated/services/llmpricingrules';import { type ListLLMPricingRulesParams } from 'api/generated/services/sigNoz.schemas';import { useTableParams } from 'components/TanStackTableView';import useComponentPermission from 'hooks/useComponentPermission';+import useDebounce from 'hooks/useDebounce';+import { parseAsString, parseAsStringEnum, useQueryState } from 'nuqs';import { useAppContext } from 'providers/App/App';-import { LIMIT_KEY, PAGE_KEY, PAGE_SIZE } from '../constants';+import {+ LIMIT_KEY,+ PAGE_KEY,+ PAGE_SIZE,+ SEARCH_DEBOUNCE_MS,+ SEARCH_KEY,+ SOURCE_FILTER_OPTIONS,+ SOURCE_FILTER_TO_IS_OVERRIDE,+ SOURCE_KEY,+ type SourceFilter,+} from '../constants';import type { PricingRule } from '../types';import DeleteConfirmDialog from './components/DeleteConfirmDialog';import ModelCostDrawer, {@@ -18,24 +32,60 @@ import ModelCostsTable from './components/ModelCostsTable';import { useModelCostDelete } from './hooks/useModelCostDelete';import styles from './ModelCostTabPanel.module.scss';-// "Model costs" tab: the priced-model listing, the add/edit drawer, and-// pagination. Page and page size live in the URL (shareable/reload-safe) and are-// owned by TanStackTable via enableQueryParams — this tab reads them back through-// the same useTableParams hook so the two stay in lockstep.+// "Model costs" tab: the priced-model listing, search + source filter, the add/+// edit drawer, and pagination. Page and page size live in the URL (shareable/+// reload-safe) and are owned by TanStackTable via enableQueryParams — this tab+// reads them back through the same useTableParams hook so the two stay in lockstep.function ModelCostTabPanel(): JSX.Element {- const { page, limit } = useTableParams(+ const { page, limit, setPage } = useTableParams({ page: PAGE_KEY, limit: LIMIT_KEY },{ page: 1, limit: PAGE_SIZE },);- // Search + source filters are intentionally omitted for now — the list API- // doesn't honour them yet. They'll be reintroduced here once it does.+ const [search, setSearch] = useQueryState(+ SEARCH_KEY,+ parseAsString.withDefault(''),+ );+ const debouncedSearch = useDebounce(search, SEARCH_DEBOUNCE_MS);++ const [source, setSource] = useQueryState(+ SOURCE_KEY,+ parseAsStringEnum<SourceFilter>(+ SOURCE_FILTER_OPTIONS.map((option) => option.value),+ ).withDefault('all'),+ );++ const handleSearchChange = (+ event: React.ChangeEvent<HTMLInputElement>,+ ): void => {+ void setSearch(event.target.value || null);+ setPage(1);+ };++ const clearSearch = (): void => {+ void setSearch(null);+ setPage(1);+ };++ const handleSourceChange = (value: string | string[]): void => {+ void setSource(value as SourceFilter);+ setPage(1);+ };++ const isOverride = SOURCE_FILTER_TO_IS_OVERRIDE[source];+const listParams: ListLLMPricingRulesParams = {offset: (page - 1) * limit,limit,+ ...(debouncedSearch ? { q: debouncedSearch } : {}),+ ...(isOverride !== undefined ? { isOverride } : {}),};- const { data, isLoading, isError } = useListLLMPricingRules(listParams);+ const { data, isLoading, isError } = useListLLMPricingRules(listParams, {+ query: {+ enabled: search === debouncedSearch,+ },+ });const { user } = useAppContext();const [canManagePricing] = useComponentPermission(@@ -52,6 +102,36 @@ function ModelCostTabPanel(): JSX.Element {return (<><div className={styles.filtersBar}>+ <div className={styles.filtersBarLeft}>+ <Input+ className={styles.filtersBarSearch}+ placeholder="Search by model or provider"+ value={search}+ onChange={handleSearchChange}+ prefix={<Search size={14} />}+ suffix={+ search ? (+ <Button+ variant="ghost"+ color="secondary"+ size="icon"+ prefix={<X size={14} />}+ onClick={clearSearch}+ aria-label="Clear search"+ testId="model-cost-search-clear"+ />+ ) : undefined+ }+ testId="model-cost-search"+ />+ <SelectSimple+ className={styles.filtersBarSource}+ items={SOURCE_FILTER_OPTIONS}+ value={source}+ onChange={handleSourceChange}+ testId="source-filter"+ />+ </div>{canManagePricing && (<Buttonvariant="solid"diff --git a/frontend/src/container/LLMObservability/Settings/ModelPricing/ModelCostTabPanel/components/ModelCostsTable/ModelCostsTable.module.scss b/frontend/src/container/LLMObservability/Settings/ModelPricing/ModelCostTabPanel/components/ModelCostsTable/ModelCostsTable.module.scssindex 3e29c73043..42b40a1ed5 100644--- a/frontend/src/container/LLMObservability/Settings/ModelPricing/ModelCostTabPanel/components/ModelCostsTable/ModelCostsTable.module.scss+++ b/frontend/src/container/LLMObservability/Settings/ModelPricing/ModelCostTabPanel/components/ModelCostsTable/ModelCostsTable.module.scss@@ -15,6 +15,6 @@justify-content: center;margin-top: var(--spacing-8);min-height: 400px;- color: var(--text-vanilla-400);+ color: var(--l3-foreground);font-size: var(--periscope-font-size-base);}diff --git a/frontend/src/container/LLMObservability/Settings/ModelPricing/constants.ts b/frontend/src/container/LLMObservability/Settings/ModelPricing/constants.tsindex 9b1bc05024..2511692db5 100644--- a/frontend/src/container/LLMObservability/Settings/ModelPricing/constants.ts+++ b/frontend/src/container/LLMObservability/Settings/ModelPricing/constants.ts@@ -6,6 +6,25 @@ export const PAGE_SIZE = 20;export const PAGE_KEY = 'page';export const LIMIT_KEY = 'limit';+export const SEARCH_KEY = 'search';+export const SEARCH_DEBOUNCE_MS = 300;+export const SOURCE_KEY = 'source';++export type SourceFilter = 'all' | 'override' | 'auto';+export const SOURCE_FILTER_OPTIONS: { value: SourceFilter; label: string }[] = [+ { value: 'all', label: 'All sources' },+ { value: 'override', label: 'User override' },+ { value: 'auto', label: 'Auto' },+];++export const SOURCE_FILTER_TO_IS_OVERRIDE: Record<+ SourceFilter,+ boolean | undefined+> = {+ all: undefined,+ override: true,+ auto: false,+};// Match the page size so the skeleton reserves the same number of rows the// loaded page renders — otherwise the table height jumps on load.