list_loki_label_names
Retrieve all available label names from Loki log data within a specified time range to identify and filter log entries effectively.
Instructions
Lists all available label names (keys) found in logs within a specified Loki datasource and time range
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| datasourceUid | Yes | The UID of the datasource to query | |
| endRfc3339 | No | The end time of the query in RFC3339 format | |
| startRfc3339 | No | The start time of the query in RFC3339 format |
Implementation Reference
- src/clients/loki-client.ts:80-96 (helper)LokiClient method that performs the actual API call to retrieve label names from Loki
async getLabelNames(start?: string, end?: string): Promise<string[]> { try { const params: any = {}; if (start) params.start = start; if (end) params.end = end; const response = await this.client.get('/loki/api/v1/labels', { params }); if (response.data.status !== 'success') { throw new Error(`Failed to get label names: ${response.data.error || 'Unknown error'}`); } return response.data.data || []; } catch (error) { this.handleError(error); } }