list_loki_label_values
Retrieve all unique values for a specific label within a Loki datasource and time range to analyze log data patterns and filter queries effectively.
Instructions
Retrieves all unique values associated with a specific labelName within a 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 | |
| labelName | Yes | The name of the label to retrieve values for | |
| startRfc3339 | No | The start time of the query in RFC3339 format |
Implementation Reference
- src/clients/loki-client.ts:98-114 (helper)LokiClient.getLabelValues method that queries the Loki API endpoint /loki/api/v1/label/{label}/values to retrieve unique values for the specified label.
async getLabelValues(label: string, 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/label/${label}/values`, { params }); if (response.data.status !== 'success') { throw new Error(`Failed to get label values: ${response.data.error || 'Unknown error'}`); } return response.data.data || []; } catch (error) { this.handleError(error); } }