---
title: "Datasource discovery"
description: "The datasource discovery endpoints of the HTTP API."
---

> Documentation Index
> Fetch the complete documentation index at: https://slashobserve.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Datasource discovery

## GET /datasources/{uid}/schema

Read the tables, or the columns of one table, of a ClickHouse, Elasticsearch or OpenSearch datasource, or the services and span names of Tempo.

It runs the same code, validation and limits as the agent's `get_schema` tool. Without `table` it lists the tables; with `table` it lists that table's columns with their types, and `offset` pages on from a `next_offset`. A Tempo datasource has no tables: it answers the services, span names and attribute names it holds, and a request with `table` or `offset` is a 400. Prometheus and Loki datasources answer 400 `invalid_request`; their label names are read with the labels route. An unknown datasource is a 404 `not_found`. Any query parameter not listed below, or one given twice, is a 400.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `uid` (required) | path | `string` |   |
| `table` | query | `string` | The table whose columns to list. |
| `offset` | query | `integer` | How many items to skip, from a previous answer's `next_offset`. |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | One page of tables, or of columns, or the Tempo services and span names. | [`DatasourceTables`](/docs/reference/api/schemas/#datasourcetables) or [`DatasourceColumns`](/docs/reference/api/schemas/#datasourcecolumns) or [`DatasourceSpanSchema`](/docs/reference/api/schemas/#datasourcespanschema) |
| `400` | The request is malformed or fails validation. | [`Error`](/docs/reference/api/schemas/#error) |
| `401` | Authentication is missing or invalid. | [`Error`](/docs/reference/api/schemas/#error) |
| `404` | The resource does not exist, or the caller cannot see it; the two are never told apart. | [`Error`](/docs/reference/api/schemas/#error) |
| `422` | The query or its variables cannot run, or its result exceeds a limit. | [`Error`](/docs/reference/api/schemas/#error) |
| `429` | The caller already has the maximum number of query requests in flight, or the server's shared upstream call slots stayed busy for 5 seconds. | [`Error`](/docs/reference/api/schemas/#error) |
| `500` | The server failed to handle the request. | [`Error`](/docs/reference/api/schemas/#error) |
| `502` | The datasource is unavailable. | [`Error`](/docs/reference/api/schemas/#error) |
| `504` | The datasource did not answer within the query timeout. | [`Error`](/docs/reference/api/schemas/#error) |

## GET /datasources/{uid}/sample

Read a few rows of a ClickHouse table, or a few log lines or documents of a Loki, Elasticsearch or OpenSearch datasource.

It runs the same code, validation and limits as the agent's `sample_rows` tool. `table` is required on ClickHouse; on Loki it is an optional stream selector, and Elasticsearch and OpenSearch read their index pattern without it. Cell values are cut to 300 bytes, and `truncated` is true when columns, cells or rows were dropped to fit. Any query parameter not listed below, or one given twice, is a 400.

### Parameters

| Name | In | Type | Description |
| --- | --- | --- | --- |
| `uid` (required) | path | `string` |   |
| `table` | query | `string` |   |
| `limit` | query | `integer` | Maximum rows to return. Between 1 and 20. Default `5`. |

### Responses

| Status | Description | Body |
| --- | --- | --- |
| `200` | Up to `limit` rows with their column names. | [`DatasourceSample`](/docs/reference/api/schemas/#datasourcesample) |
| `400` | The request is malformed or fails validation. | [`Error`](/docs/reference/api/schemas/#error) |
| `401` | Authentication is missing or invalid. | [`Error`](/docs/reference/api/schemas/#error) |
| `404` | The resource does not exist, or the caller cannot see it; the two are never told apart. | [`Error`](/docs/reference/api/schemas/#error) |
| `422` | The query or its variables cannot run, or its result exceeds a limit. | [`Error`](/docs/reference/api/schemas/#error) |
| `429` | The caller already has the maximum number of query requests in flight, or the server's shared upstream call slots stayed busy for 5 seconds. | [`Error`](/docs/reference/api/schemas/#error) |
| `500` | The server failed to handle the request. | [`Error`](/docs/reference/api/schemas/#error) |
| `502` | The datasource is unavailable. | [`Error`](/docs/reference/api/schemas/#error) |
| `504` | The datasource did not answer within the query timeout. | [`Error`](/docs/reference/api/schemas/#error) |

Generated from [`api/openapi.yaml`](https://github.com/slashobserve/slashobserve/blob/c770e5e0/api/openapi.yaml) at `c770e5e0`. [Report a problem](https://github.com/slashobserve/slashobserve/issues/new).
