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
chore: add ai qb examples (#13282)
Nityananda Gohain665e70b17a6c
diff --git a/docs/api/openapi.yml b/docs/api/openapi.ymlindex 071f227fcc..5877224e68 100644--- a/docs/api/openapi.yml+++ b/docs/api/openapi.yml@@ -31970,6 +31970,132 @@ paths:content:application/json:examples:+ ai_traces_raw:+ summary: 'Raw: LLM, tool, and agent spans of one service''s AI traces+ with many tool calls'+ value:+ compositeQuery:+ queries:+ - spec:+ filter:+ expression: service.name = 'ai-agent' AND trace.tool_call_count+ > 10+ limit: 100+ name: A+ order:+ - direction: desc+ key:+ fieldContext: span+ name: timestamp+ signal: traces+ type: builder_ai_query+ end: 1640998800000+ requestType: raw+ schemaVersion: v1+ start: 1640995200000+ ai_traces_raw_select_fields:+ summary: 'Raw: the same spans with the span name and gen_ai model,+ tool, and token fields selected'+ value:+ compositeQuery:+ queries:+ - spec:+ filter:+ expression: service.name = 'ai-agent' AND trace.tool_call_count+ > 10+ limit: 100+ name: A+ order:+ - direction: desc+ key:+ fieldContext: span+ name: timestamp+ selectFields:+ - fieldContext: span+ name: name+ - fieldContext: attribute+ name: gen_ai.request.model+ - fieldContext: attribute+ name: gen_ai.tool.name+ - fieldContext: attribute+ name: gen_ai.usage.input_tokens+ - fieldContext: attribute+ name: gen_ai.usage.output_tokens+ signal: traces+ type: builder_ai_query+ end: 1640998800000+ requestType: raw+ schemaVersion: v1+ start: 1640995200000+ ai_traces_scalar:+ summary: 'Scalar: average per-trace AI cost by model'+ value:+ compositeQuery:+ queries:+ - spec:+ aggregations:+ - expression: avg(trace.estimated_total_cost)+ groupBy:+ - fieldContext: attribute+ name: gen_ai.request.model+ limit: 10+ name: A+ order:+ - direction: desc+ key:+ name: avg(trace.estimated_total_cost)+ signal: traces+ type: builder_ai_query+ end: 1640998800000+ requestType: scalar+ schemaVersion: v1+ start: 1640995200000+ ai_traces_time_series:+ summary: 'Time series: per-trace AI cost by model'+ value:+ compositeQuery:+ queries:+ - spec:+ aggregations:+ - expression: sum(trace.estimated_total_cost)+ groupBy:+ - fieldContext: attribute+ name: gen_ai.request.model+ limit: 10+ name: A+ order:+ - direction: desc+ key:+ name: sum(trace.estimated_total_cost)+ signal: traces+ stepInterval: 60s+ type: builder_ai_query+ end: 1640998800000+ requestType: time_series+ schemaVersion: v1+ start: 1640995200000+ ai_traces_trace:+ summary: 'Trace list: AI traces with many tool calls, most expensive+ first'+ value:+ compositeQuery:+ queries:+ - spec:+ filter:+ expression: trace.tool_call_count > 10 AND trace.distinct_tool_count+ < 3+ limit: 10+ name: A+ order:+ - direction: desc+ key:+ name: trace.estimated_total_cost+ signal: traces+ type: builder_ai_query+ end: 1640998800000+ requestType: trace+ schemaVersion: v1+ start: 1640995200000clickhouse_sql_logs_raw:summary: 'ClickHouse SQL: raw logs with resource filter'value:diff --git a/pkg/apiserver/signozapiserver/querier.go b/pkg/apiserver/signozapiserver/querier.goindex 0f5828cd91..c04f3f1f2e 100644--- a/pkg/apiserver/signozapiserver/querier.go+++ b/pkg/apiserver/signozapiserver/querier.go@@ -254,6 +254,150 @@ func (provider *provider) addQuerierRoutes(router *mux.Router) error {},},},+ {+ Name: "ai_traces_trace",+ Summary: "Trace list: AI traces with many tool calls, most expensive first",+ Value: map[string]any{+ "schemaVersion": "v1",+ "start": 1640995200000,+ "end": 1640998800000,+ "requestType": "trace",+ "compositeQuery": map[string]any{+ "queries": []any{+ map[string]any{+ "type": "builder_ai_query",+ "spec": map[string]any{+ "name": "A",+ "signal": "traces",+ "filter": map[string]any{"expression": "trace.tool_call_count > 10 AND trace.distinct_tool_count < 3"},+ "order": []any{+ map[string]any{"key": map[string]any{"name": "trace.estimated_total_cost"}, "direction": "desc"},+ },+ "limit": 10,+ },+ },+ },+ },+ },+ },+ {+ Name: "ai_traces_raw",+ Summary: "Raw: LLM, tool, and agent spans of one service's AI traces with many tool calls",+ Value: map[string]any{+ "schemaVersion": "v1",+ "start": 1640995200000,+ "end": 1640998800000,+ "requestType": "raw",+ "compositeQuery": map[string]any{+ "queries": []any{+ map[string]any{+ "type": "builder_ai_query",+ "spec": map[string]any{+ "name": "A",+ "signal": "traces",+ "filter": map[string]any{"expression": "service.name = 'ai-agent' AND trace.tool_call_count > 10"},+ "order": []any{+ map[string]any{"key": map[string]any{"name": "timestamp", "fieldContext": "span"}, "direction": "desc"},+ },+ "limit": 100,+ },+ },+ },+ },+ },+ },+ {+ Name: "ai_traces_raw_select_fields",+ Summary: "Raw: the same spans with the span name and gen_ai model, tool, and token fields selected",+ Value: map[string]any{+ "schemaVersion": "v1",+ "start": 1640995200000,+ "end": 1640998800000,+ "requestType": "raw",+ "compositeQuery": map[string]any{+ "queries": []any{+ map[string]any{+ "type": "builder_ai_query",+ "spec": map[string]any{+ "name": "A",+ "signal": "traces",+ "filter": map[string]any{"expression": "service.name = 'ai-agent' AND trace.tool_call_count > 10"},+ "selectFields": []any{+ map[string]any{"name": "name", "fieldContext": "span"},+ map[string]any{"name": "gen_ai.request.model", "fieldContext": "attribute"},+ map[string]any{"name": "gen_ai.tool.name", "fieldContext": "attribute"},+ map[string]any{"name": "gen_ai.usage.input_tokens", "fieldContext": "attribute"},+ map[string]any{"name": "gen_ai.usage.output_tokens", "fieldContext": "attribute"},+ },+ "order": []any{+ map[string]any{"key": map[string]any{"name": "timestamp", "fieldContext": "span"}, "direction": "desc"},+ },+ "limit": 100,+ },+ },+ },+ },+ },+ },+ {+ Name: "ai_traces_time_series",+ Summary: "Time series: per-trace AI cost by model",+ Value: map[string]any{+ "schemaVersion": "v1",+ "start": 1640995200000,+ "end": 1640998800000,+ "requestType": "time_series",+ "compositeQuery": map[string]any{+ "queries": []any{+ map[string]any{+ "type": "builder_ai_query",+ "spec": map[string]any{+ "name": "A",+ "signal": "traces",+ "aggregations": []any{+ map[string]any{"expression": "sum(trace.estimated_total_cost)"},+ },+ "stepInterval": "60s",+ "groupBy": []any{map[string]any{"name": "gen_ai.request.model", "fieldContext": "attribute"}},+ "order": []any{+ map[string]any{"key": map[string]any{"name": "sum(trace.estimated_total_cost)"}, "direction": "desc"},+ },+ "limit": 10,+ },+ },+ },+ },+ },+ },+ {+ Name: "ai_traces_scalar",+ Summary: "Scalar: average per-trace AI cost by model",+ Value: map[string]any{+ "schemaVersion": "v1",+ "start": 1640995200000,+ "end": 1640998800000,+ "requestType": "scalar",+ "compositeQuery": map[string]any{+ "queries": []any{+ map[string]any{+ "type": "builder_ai_query",+ "spec": map[string]any{+ "name": "A",+ "signal": "traces",+ "aggregations": []any{+ map[string]any{"expression": "avg(trace.estimated_total_cost)"},+ },+ "groupBy": []any{map[string]any{"name": "gen_ai.request.model", "fieldContext": "attribute"}},+ "order": []any{+ map[string]any{"key": map[string]any{"name": "avg(trace.estimated_total_cost)"}, "direction": "desc"},+ },+ "limit": 10,+ },+ },+ },+ },+ },+ },{Name: "logs_scalar",Summary: "Scalar: total error log count",