Skip to content

feat: add signoz_list_hosts tool for infrastructure monitoring - #67

Open
artgas1 wants to merge 1 commit into
SigNoz:mainfrom
artgas1:feat/infrastructure-monitoring-hosts
Open

feat: add signoz_list_hosts tool for infrastructure monitoring#67
artgas1 wants to merge 1 commit into
SigNoz:mainfrom
artgas1:feat/infrastructure-monitoring-hosts

Conversation

@artgas1

@artgas1 artgas1 commented Mar 12, 2026

Copy link
Copy Markdown

Summary

Adds a new signoz_list_hosts tool that exposes SigNoz's Infrastructure Monitoring hosts data via MCP. This enables AI assistants to check server health, CPU/memory usage, and load averages directly.

New Tool

signoz_list_hosts — List infrastructure hosts with resource utilization metrics.

Parameters

Parameter Type Default Description
timeRange string 1h Time range (e.g., '30m', '1h', '6h', '24h')
orderBy string cpu Sort column: cpu, memory, wait, load15
order string desc Sort direction: asc, desc
limit string 100 Max hosts to return
offset string 0 Pagination offset

Example Response

{
  "hosts": [
    {
      "hostName": "production-vps",
      "active": true,
      "os": "linux",
      "cpu": 0.33,
      "memory": 0.36,
      "wait": 0.004,
      "load15": 2.05
    }
  ],
  "total": 5,
  "sentAnyHostMetricsData": true
}

Implementation

  • Client: ListHosts()POST /api/v1/hosts/list
  • Types: HostListRequest, HostListResponse, HostRecord in new pkg/types/infra.go
  • Handler: Parses time range, sorting, pagination; simplifies response by extracting OS from metadata
  • Server: Registered via RegisterInfraHandlers()

Use Case

This was motivated by a real incident where a VPS became overloaded but we couldn't query host metrics through MCP. The existing signoz_execute_builder_query requires complex query construction for host metrics, while this tool provides a simple, purpose-built interface.

Adds a tool to list infrastructure hosts with CPU, memory, I/O wait and
load metrics via /api/v1/hosts/list — the endpoint behind SigNoz's
Infrastructure Monitoring > Hosts page.

Rebased onto current main (2026-08-04) and adapted to upstream conventions
introduced since March: slog instead of zap, doRequest helper, GetClient
returning an error, registration via h.addTool, coded error helpers,
read-only annotations + searchContext, entries in the pinned annotation
inventory and manifest.json. Handler lives in its own infra.go, matching
the per-domain file layout.

Two earlier commits from the old branch are intentionally dropped: the
list_alerts fix was addressed upstream in SigNoz#147, and signoz_list_triggered_alerts
now duplicates upstream's signoz_list_alerts, which returns firing instances.
@artgas1
artgas1 force-pushed the feat/infrastructure-monitoring-hosts branch from 1cd9aa6 to 629d207 Compare August 4, 2026 18:04
@artgas1

artgas1 commented Aug 4, 2026

Copy link
Copy Markdown
Author

Rebased onto current main and adapted to the conventions introduced since March: slog instead of zap, the doRequest helper, GetClient returning an error, registration through h.addTool, coded error helpers, read-only annotations plus searchContext, and entries in the pinned annotation inventory and manifest.json. The handler now lives in its own infra.go, matching the per-domain layout.

go build ./... and go test ./internal/... ./pkg/... are green, including the guardrail tests.

Happy to adjust anything else if the tool is of interest.

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.

1 participant