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

docs: api for querying logflare #2056

Merged
merged 1 commit into from
Apr 26, 2024
Merged
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
2 changes: 1 addition & 1 deletion docs/docs.logflare.com/docs/concepts/endpoints.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 4
sidebar_position: 5
---

# Endpoints
Expand Down
35 changes: 35 additions & 0 deletions docs/docs.logflare.com/docs/concepts/querying.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
sidebar_position: 4
---

# Querying

To run adhoc queries for exploratory analysis, use the Querying or Search functionality. The use case for this differs from other features that Logflare offers:

- For periodic query-based checks and data push integrations, use the Alerting functionality.
- For building GET APIs for downstream programmatic consumption and data pull integrations, use the Endpoints functionality

## Via Management API

Sources can be queried through SQL using our management API.

The following query parameters are available:

- `?sql=` (string): accepts a BQ SQL query, alias for `?bq_sql=`.
- `?bq_sql=` (string): accepts a BigQuery SQL query.
- `?pg_sql=` (string): accepts a Postgres SQL query, for running on PostgreSQL backends. The first PostgreSQL backend will be selected.

```
# Endpoint
GET https://api.logflare.app/api/query?sql=...

# With a query
GET https://api.logflare.app/api/query?bq_sql=select id, event_message, datetime(timestamp) as timestamp from `my_source` where timestamp > '2024-01-01'
```

## Caveats and Limitations

The following caveats apply when querying this management API route:

- Due to the partitioning that Logflare performs, queries must have a `WHERE` filter over the `timestamp` field at all times.
- A hard maximum of 1000 rows will be returned for the BigQuery backend.
Loading