Skip to content

Add gateway.jsonl parsing for MCP server usage metrics#9778

Merged
pelikhan merged 4 commits intomainfrom
copilot/update-download-logs-function
Jan 12, 2026
Merged

Add gateway.jsonl parsing for MCP server usage metrics#9778
pelikhan merged 4 commits intomainfrom
copilot/update-download-logs-function

Conversation

Copy link
Contributor

Copilot AI commented Jan 12, 2026

The MCP gateway container logs server and tool usage to gateway.jsonl in JSONL format, but the logs and audit commands couldn't parse this data to show usage metrics.

Changes

New gateway log parser (pkg/cli/gateway_logs.go)

  • Parses JSONL format with entries like:
    {"timestamp":"2024-01-12T10:00:00Z","event":"tool_call","server_name":"github","tool_name":"get_repository","duration":150.5,"status":"success"}
  • Aggregates per-server metrics: request counts, tool calls, durations, errors
  • Aggregates per-tool metrics: call counts, avg/max/min durations, input/output sizes
  • Combines metrics across multiple workflow runs

Display integration

  • gh aw logs: Shows aggregated gateway metrics after main output
  • gh aw audit: Shows gateway metrics after audit report
  • Verbose mode includes detailed tool breakdowns per server
  • Gracefully skips runs without gateway.jsonl (normal for non-gateway workflows)

Example output

MCP Gateway Metrics

Total Requests: 6
Total Tool Calls: 6
Total Errors: 1
Servers: 2

Server Usage:
┌────────────────────────────┬──────────┬────────────┬───────────┬────────┐
│ Server                     │ Requests │ Tool Calls │ Avg Time  │ Errors │
├────────────────────────────┼──────────┼────────────┼───────────┼────────┤
│ github                     │        4 │          4 │    158ms  │      1 │
│ playwright                 │        2 │          2 │    400ms  │      0 │
└────────────────────────────┴──────────┴────────────┴───────────┴────────┘

Testing

  • 13 test functions covering valid logs, errors, multiple servers, invalid JSON, aggregation
  • All tests passing, linting clean
Original prompt

Make sure the download logs function in .go is able to parse the gateway.jsonl file.

When it finds it, it should gather basic usage metrics of the servers and tools, from the JSONL messages.

Display a table with the results in logs and audit.

See recent runs of smoke-Claude for gateway.log file


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 12, 2026 22:43
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Update download logs function to parse gateway.jsonl Add gateway.jsonl parsing for MCP server usage metrics Jan 12, 2026
Copilot AI requested a review from pelikhan January 12, 2026 23:01
@pelikhan pelikhan marked this pull request as ready for review January 12, 2026 23:19
@pelikhan pelikhan merged commit a7e6158 into main Jan 12, 2026
@pelikhan pelikhan deleted the copilot/update-download-logs-function branch January 12, 2026 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants