list_log_labels
Discover available log stream labels in Loki for filtering and troubleshooting. Use this tool to identify labels that help narrow down log searches and investigate issues.
Instructions
List all log stream labels in Loki. Use this to discover what labels are available for filtering.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| start | No | Start time for label discovery | |
| end | No | End time for label discovery |
Implementation Reference
- src/tools/loki_tools.py:128-172 (handler)The implementation of the `list_log_labels` tool handler which calls the Loki client to retrieve log labels.
async def list_log_labels( client: LokiClient, start: Optional[str] = None, end: Optional[str] = None ) -> Dict[str, Any]: """ List all log stream labels. Args: client: Loki client start: Start time for label discovery end: End time for label discovery Returns: List of label names """ try: # Parse time range if provided start_ns = None end_ns = None if start or end: start_dt, end_dt = parse_time_range(start, end) start_ns = to_loki_time(start_dt) end_ns = to_loki_time(end_dt) result = await client.labels(start_ns, end_ns) if result.get("status") == "success": labels = result.get("data", []) return { "success": True, "count": len(labels), "labels": labels } else: return { "success": False, "error": "Failed to fetch labels" } except Exception as e: logger.error(f"Error listing log labels: {e}") return { "success": False, "error": str(e) }