The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
docs: add PR updates
TzeYiing62d077989793
diff --git a/apps/www/_blog/2023-04-10-o11y-day.mdx b/apps/www/_blog/2023-04-10-o11y-day.mdxindex a819da2d2c4..350eac684dc 100644--- a/apps/www/_blog/2023-04-10-o11y-day.mdx+++ b/apps/www/_blog/2023-04-10-o11y-day.mdx@@ -8,19 +8,21 @@ to_depth: 3author: chasers,ziinc----We are releasing Supabase Logs for both self-hosted users and CLI development, and have integrated Logflare as the observability component the Supabase development stack.+Today, we’re releasing Supabase Logs for both self-hosted users and CLI development## Logflare Introduction-Since [Logflare joined Supabase](https://supabase.com/blog/supabase-acquires-logflare) over a year ago it’s been quietly handling over 1 billion log events every day. These events come from various areas in the Supabase infrastructure, such as the API gateway, Postgres databases, Storage, Edge Functions, Auth, and Realtime.+Since [Logflare joined Supabase](https://supabase.com/blog/supabase-acquires-logflare) over a year ago it’s been quietly handling over 1 billion log events every day. These events come from various tools in the Supabase infrastructure - the API gateway, Postgres databases, Storage, Edge Functions, Auth, and Realtime.-Logflare ingests these log events and stores them into BigQuery. To handle and scale up to traffic generated by Supabase as well as Logflare's existing customers, we leverage a multi-node architecture for high availability. The cluster count averages at 6 high-compute nodes, steadily handling every spike that each customer, Supabase or otherwise, throws at it.+Logflare is a multi-node, highly available Elixir cluster, ingesting the log events and storing them into BigQuery for Supabase and Logflare’s customers. On average, the cluster has 6 nodes handling every spike our customers throw at it.-To utilize and expose all ingested Supabase Platform data to customers, we then leverage Logflare Endpoints to integrate into the Supabase Studio, powering the log query UIs and most timeseries charts. These charts live across the studio, such as the project home page and the new API reports.+To expose log data to customers, we leverage Logflare Endpoints. This provides an HTTP integration into Supabase Studio, powering the log query UIs and most timeseries charts. These charts live across the studio, such as the project home page and the new API reports.++<!-- add chart screenshot -->## Self-hosting Logflare-Logflare was previously available under a BSL license prior to joining Supabase. Following our open-source philosophy, we’ve now changed the license to [Apache 2.0](https://github.com/Logflare/logflare/blob/staging/LICENSE.md), aligning it with the rest of our open-source products.+Logflare was available under a BSL license prior to joining Supabase. We’ve since changed the license to [Apache 2.0](https://github.com/Logflare/logflare/blob/staging/LICENSE.md), aligning it with our open source philosophy.In the past few months we’ve made Logflare more developer-friendly for local development and self-hosting. While you’re building a project, you can view and query your logs from any Supabase service, just as you would in our cloud Platform.@@ -30,32 +32,32 @@ In the past few months we’ve made Logflare more developer-friendly for local d## The Ingestion Pipeline-Logflare receives Supabase log events via multiple methods. Some services, such as Postgres, use Vector to clean and forward log events to our the Logflare ingest API. Other services such as Realtime and Storage utilise direct one of our [integrations](https://github.com/Logflare/logflare#integrations) to directly send the log events. These then get processed and streamed into the BigQuery backend.+Logflare receives Supabase log events via multiple methods. Services like Postgres use Vector to clean and forward log events to our the Logflare ingest API. Other services such as Realtime and Storage utilize our [integrations](https://github.com/Logflare/logflare#integrations) to send the log events directly. These then get processed and streamed into BigQuery.## The Querying Pipeline-Now that we have ingested all these log events, the hard part is to not only search through these log events, but to aggregate and analyse them at scale. Crunching many terabytes of data on each analytics query is costly and expensive, and exposing the ingested data to Supabase customers in a naive manner would cause our querying costs to skyrocket.+The hard part comes after ingesting the logs: searching, aggregating ,and analyzing them at scale. Crunching many terabytes of data on each query is expensive, and exposing the ingested data to Supabase customers in a naive manner would cause our costs to skyrocket.-To solve these issues, we built and refined Logflare Endpoints, the querying engine that powers many realtime Supabase Platform features, such as the logs views, Logs Explorer, project home usage charts, Functions usage charts and the new API report.+To solve these issues, we built and refined Logflare Endpoints, the query engine that powers many of Supabase’s features, such as the logs views, Logs Explorer, and usage charts.-With Endpoints, you can create HTTP API endpoints from any SQL query, including parameterised queries. Endpoints is a bit like a PostgREST view but with some benefits:+With Endpoints, you can create HTTP API endpoints from a SQL query, including parameterized queries. Endpoints is like a PostgREST view but with some benefits:-- Query parameters- - Query parameters of your Endpoint query URL are provided as query string parameters to the SQL query.-- Read-through caching+- **Query parameters**+ - You can provide string parameters to the SQL query via the HTTP endpoint.+- **Read-through caching**- Results from the query are cached in memory for fast response times.- A read-through cache provides results if cached results do not exist.-- Active cache warming+- **Active cache warming**- Query results are proactively warmed at a configurable interval for a combination of fast response times and as-realtime-as-needed data.-- Query sandboxing+- **Query sandboxing**- If an Endpoint query contains a CTE and the sandbox option is selected, the Endpoint will inject the query string of the `sql` query parameter into the Endpoint SQL replacing the default query (the part of the SQL query after the CTE).- Endpoints parse SQL to allow `select` queries only. No DML or DDL statements are permitted to run through Logflare Endpoints.-This feature set has let Supabase build any view we’ve needed on top of billions of log events processed daily.+With this feature set, Supabase has been able to build any view we’ve needed on top of billions of daily log events.### Logflare Endpoint Example-This example showcases a GitHub webhook that sends all event in all Supabase GitHub organizations to Logflare. This gives Logflare structured events where the payload of the Github webhook gets turned into metadata for a log event:+Using webhooks, we can send all GitHub events in the Supabase organization to Logflare. The webhook sends structured events, and Logflare transforms the payload into metadata:```json{@@ -77,7 +79,7 @@ This example showcases a GitHub webhook that sends all event in all Supabase Git}```-We’re interested in the top contributors org wide, and this can be extracted by creating an Endpoint with SQL (in BigQuery dialect):+We’re interested in the top contributors, which can be extracted with SQL (in BigQuery dialect):```sqlselect@@ -105,7 +107,7 @@ curl "https://logflare.app/endpoints/query/69425db0-1cfb-48b4-84c7-2a872b6f0a61"-G -d "day=30"```-Which gives us the response with the top org wide contributors for the last 30 days!+This returns a JSON response with the top org wide contributors for the last 30 days!```json{@@ -159,19 +161,19 @@ Which gives us the response with the top org wide contributors for the last 30 d}```-We can then configure this Endpoint to cache results for a set interval of 10 minutes after the first API request, and proactively update those cached results every 2 minutes. This would result in 5 separate queries spread out áo cross the 10 minute cache time. Even if we were to throw tens of thousands of API requests at the endpoint, we would only sustain the cost of 5 queries to update the cached data.+We can configure this Endpoint to cache results for an interval of 10 minutes after the first API request, and proactively update those cached results every 2 minutes - 5 queries across the 10 minute interval. Even if we hit the Endpoint thousands of times, we only sustain the cost of 5 queries.-The initial request is fast because Logflare also performs setup (such as partitioning) on our BigQuery tables appropriately. Subsequent requests made are extremely fast as they get cached in-memory.+The initial request is fast because Logflare also performs setup (such as partitioning) on our BigQuery tables appropriately. Subsequent requests are _extremely fast_ as they are cached in-memory.-The best part is that all these knobs can be tweaked based on the use case. If we have a hard realtime requirement, we can completely disable caching, or drop the proactive caching to update on a per-second basis.+The best part is that all these knobs can be tweaked for your use case. If we have a real-time requirement, we can completely disable caching or reduce the proactive caching to update on a per-second interval.## The Self-hosted Challenge-In order to execute the license change, we had to get rid of all closed-source dependencies. Prior to our efforts, Logflare relied on the closed source [General SQL Parser](https://www.sqlparser.com/) under a business licenses. However, it would not be an acceptable compromise under the Apache License.+To change the license, we needed to remove all closed-source dependencies. Previously, Logflare relied on the closed source [General SQL Parser](https://www.sqlparser.com/) under a business licenses. This is incompatible with the Apache License.-This resulted in an effort to switch Logflare over to an open source alternative, and we settled on the rust-based [sqlparser-rs](https://github.com/sqlparser-rs/sqlparser-rs) library, and also ended up helping to contribute a [few fixes](https://github.com/sqlparser-rs/sqlparser-rs/pulls?q=is%3Apr+is%3Amerged+author%3AZiinc) upstream for the BigQuery dialect.+We switched to an open source alternative, the rust-based [sqlparser-rs](https://github.com/sqlparser-rs/sqlparser-rs) library, contributing a [few updates](https://github.com/sqlparser-rs/sqlparser-rs/pulls?q=is%3Apr+is%3Amerged+author%3AZiinc) for the BigQuery dialect.-Besides the parser, a big part of getting Logflare working with Supabase locally was transforming the multi-tenant architecture into something that was self-hosting friendly and could be easily configurable. We also moved towards environment variable based configuration instead of compile-time configurations, and also exposed the Endpoints configurations necessary for Supabase Logs.+Along with the parser, we invested a lot of effort into transforming the multi-tenant architecture into something that was self-hosting friendly and easily configurable. We moved towards environment variable based configuration instead of compile-time configurations, exposing the Endpoints configurations necessary for Supabase Logs.## What’s Next?@@ -179,20 +181,20 @@ To further integrate Logflare into the Supabase platform, we are building out 2### Management API-The Management API allows users to programmatically interact with Logflare server and manage their Logflare account and resources. This feature will be available for both Logflare customers and self-hosted users.+The Management API allows users to interact programmatically with Logflare to manage their account and resources. This feature will be available for both Logflare customers and self-hosted users.You can check out the preview of our OpenAPI spec here: [https://logflare.app/swaggerui](https://logflare.app/swaggerui)-Not only that, we intend to expose user account provisioning to select partners. Soon, you’ll be able to apply to become a Logflare Partner and provision Logflare accounts with the Partner API. Perfect if you want to resell a log analytics service from within your platform.+Not only that, we intend to expose user account provisioning to select partners. Soon, you’ll be able to become a Logflare Partner to provision Logflare accounts through the Partner API. Perfect if you want to resell a log analytics service from your own platform.Contact us at [email protected] to get in early on that waitlist.## Multiple Backends+Logflare currently supports a BigQuery backend. We plan to add support for other analytics-optimized databases, like Clickhouse. We will also support pushing data to other web services, making Logflare a good fit for any data pipeline.-We understand that many of our customers are concerned about relying on closed-source products. Although Logflare currently supports a BigQuery backend, we hope to add support for other analytics optimized databases like Clickhouse. Beyond that, we can also support pushing data to other web services, allowing Logflare to fit into any data pipeline.-This would benefit our Supabase CLI integration, such that once Postgres support is available, Logflare would be able to integrate seamlessly out-of-the-box without the BigQuery requirement.+This will benefit the Supabase CLI: once Postgres support is available, Logflare will be able to integrate seamlessly, without the BigQuery requirement.## Wrapping Up