get_targets
Retrieve scrape target information from Prometheus monitoring to identify active endpoints and their status for metric collection.
Instructions
Get information about all scrape targets
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/prometheus_mcp_server/server.py:474-483 (registration)Registration of the 'get_targets' tool using FastMCP's @mcp.tool decorator. Defines the tool's description, title, icon, and operational hints.description="Get information about all scrape targets", annotations={ "title": "Get Scrape Targets", "icon": "🎯", "readOnlyHint": True, "destructiveHint": False, "idempotentHint": True, "openWorldHint": True } )
- The handler function for the 'get_targets' tool. Makes a request to Prometheus API '/api/v1/targets' and returns a dictionary containing 'activeTargets' and 'droppedTargets' lists.async def get_targets() -> Dict[str, List[Dict[str, Any]]]: """Get information about all Prometheus scrape targets. Returns: Dictionary with active and dropped targets information """ logger.info("Retrieving scrape targets information") data = make_prometheus_request("targets") result = { "activeTargets": data["activeTargets"], "droppedTargets": data["droppedTargets"] } logger.info("Scrape targets retrieved", active_targets=len(data["activeTargets"]), dropped_targets=len(data["droppedTargets"])) return result