Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: a brief placeholder document for log-query endpoint #1489

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions docs/user-guide/query-data/log-query.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
keywords: [log query, logs, search, experimental, HTTP endpoint]
description: Documentation for GreptimeDB's experimental log query endpoint, which provides a dedicated HTTP interface for searching and processing log data.
---

# Log Query (Experimental)

::: warning
The log query endpoint feature is currently experimental and may change in future releases.
:::

GreptimeDB provides a dedicated HTTP endpoint to query log data. This feature allows you to search and process log entries using a simple query interface. This is an add-on feature to existing GreptimeDB capabilities like SQL queries and Flow computations. You can still use your existing tools and workflows to query log data like before.

## Endpoint

```http
POST /v1/logs
```

## Headers
- [Authorization](/user-guide/protocols/http.md#authentication)
- `Content-Type`: `application/json`

## Request Format

The request body should be a JSON object (this is subject to change in patch version within the experimental phase). For the latest request format, please refer to the [implementation](https://github.com/GreptimeTeam/greptimedb/blob/main/src/log-query/src/log_query.rs):

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please explain all the keys of the JSON object

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are likely to be changed. This document is only a placeholder for the new experimental endpoint. I'll fill details when it turns stable

## Response

This endpoint has the same response format as the SQL query endpoint. Please refer to the [SQL query response](/user-guide/protocols/http/#response) for more details.

## Limitations

- Maximum result limit: 1000 entries
- Only supports tables with timestamp and string columns
waynexia marked this conversation as resolved.
Show resolved Hide resolved

## Example

The following example demonstrates how to query log data using the log query endpoint.

```shell
curl -X "POST" "http://localhost:4000/v1/logs" \
-H "Content-Type: application/json" \
-d $'
{
"table": {
"catalog_name": "greptime",
"schema_name": "public",
"table_name": "my_logs"
},
"time_filter": {
"start": "2025-01-23"
},
"limit": {
"fetch": 1
},
"columns": [
"message"
],
"filters": [
{
"column_name": "message",
"filters": [
{
"Contains": "production"
}
]
}
],
"context": "None",
"exprs": []
}
'
```

In this query, we are searching for log entries in the `greptime.public.my_logs` table that contain the word `production` in `message` field. We also specify the time filter to fetch logs in `2025-01-23`, and limit the result to 1 entry.

The response will be similar to the following:

```json
{
"output": [
{
"records": {
"schema": {
"column_schemas": [
{
"name": "message",
"data_type": "String"
}
]
},
"rows": [
[
"Everything is in production"
]
],
"total_rows": 1
}
}
],
"execution_time_ms": 30
}
```
5 changes: 3 additions & 2 deletions docs/user-guide/query-data/overview.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
keywords: [query languages, PromQL, SQL, views, CTE, query libraries, external data]
description: Overview of query languages supported by GreptimeDB, including PromQL and SQL, and recommended libraries for querying data.
keywords: [query languages, PromQL, SQL, views, CTE, query libraries, external data, log query]
description: Overview of query languages and features supported by GreptimeDB, including PromQL, SQL, and log query capabilities.
---

# Overview
Expand All @@ -9,6 +9,7 @@ description: Overview of query languages supported by GreptimeDB, including Prom

- [PromQL](./promql.md)
- [SQL](./sql.md)
- [Log Query](./log-query.md) (Experimental)

Since v0.9, GreptimeDB supports view and CTE just like other databases, used to simplify queries:

Expand Down
1 change: 1 addition & 0 deletions sidebars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const sidebars: SidebarsConfig = {
'user-guide/query-data/view',
'user-guide/query-data/cte',
'user-guide/query-data/query-external-data',
'user-guide/query-data/log-query',
],
},
{ type: 'category', label: 'Manage Data', items: ['user-guide/manage-data/overview', 'user-guide/manage-data/data-index'] },
Expand Down
Loading