prom_targets
Retrieve Prometheus scrape target details by specifying their state (active, dropped, or any) to monitor and analyze system performance metrics effectively.
Instructions
Get scrape target information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| state | No |
Implementation Reference
- src/prometheus-client.ts:109-114 (handler)Core implementation of the prom_targets tool logic: queries Prometheus /api/v1/targets API endpoint with optional 'state' parameter.async targets(state?: 'active' | 'dropped' | 'any'): Promise<PrometheusResponse<TargetsResult>> { const params: Record<string, string> = {}; if (state) params.state = state; const response = await this.client.get<PrometheusResponse<TargetsResult>>('/api/v1/targets', { params }); return response.data; }
- src/tools.ts:121-128 (handler)Dispatch handler for prom_targets in handleToolCall: validates input args and delegates to PrometheusClient.targets().case 'prom_targets': { if (!isPromTargetsArgs(args)) { throw new Error('Invalid arguments for prom_targets'); } const { state } = args as PromTargetsArgs; result = await prometheusClient.targets(state); break; }
- src/tools.ts:54-64 (registration)Registration of 'prom_targets' tool in the exported tools array, defining name, description, and input schema.{ name: 'prom_targets', description: 'Get scrape target information', inputSchema: { type: 'object', properties: { state: { type: 'string', enum: ['active', 'dropped', 'any'] }, }, }, }, ];
- src/types.ts:28-30 (schema)TypeScript interface defining the expected input arguments for prom_targets tool.export interface PromTargetsArgs { state?: 'active' | 'dropped' | 'any'; }
- src/tools.ts:79-81 (schema)Runtime type guard/validator for PromTargetsArgs used in the tool handler.function isPromTargetsArgs(args: unknown): args is PromTargetsArgs { return typeof args === 'object' && args !== null; }