From ceebf1b63de9bde34345f844cea83023eb8f975a Mon Sep 17 00:00:00 2001 From: Filipe Cabaco Date: Fri, 4 Aug 2023 12:23:09 +0100 Subject: [PATCH 1/2] When user isn't using Big Query adapter, we warn the user that they cannot use Log Explorer --- docker/docker-compose.yml | 4 ++++ .../pages/api/projects/[ref]/analytics/endpoints/[name].ts | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index b4a3a789897..4cf8e301d4f 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -46,6 +46,10 @@ services: LOGFLARE_API_KEY: ${LOGFLARE_API_KEY} LOGFLARE_URL: http://analytics:4000 NEXT_PUBLIC_ENABLE_LOGS: true + # Comment to use Big Query backend for analytics + NEXT_ANALYTICS_BACKEND_PROVIDER: postgres + # Uncomment to use Big Query backend for analytics + # NEXT_ANALYTICS_BACKEND_PROVIDER: big_query kong: container_name: supabase-kong diff --git a/studio/pages/api/projects/[ref]/analytics/endpoints/[name].ts b/studio/pages/api/projects/[ref]/analytics/endpoints/[name].ts index b9ab5791bea..8ab24a44941 100644 --- a/studio/pages/api/projects/[ref]/analytics/endpoints/[name].ts +++ b/studio/pages/api/projects/[ref]/analytics/endpoints/[name].ts @@ -15,6 +15,11 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { .status(400) .json({ error: { message: '[analytics] is not enabled in supabase/config.toml' } }) } + if (process.env.NEXT_ANALYTICS_BACKEND_PROVIDER !== 'big_query') { + return res + .status(400) + .json({ error: { message: 'Log Explorer is only supported by the [analytics] Big Query backend, please refer to the documentation to set it up' } }) + } const missingEnvVars = [ process.env.LOGFLARE_API_KEY ? null : 'LOGFLARE_API_KEY', process.env.LOGFLARE_URL ? null : 'LOGFLARE_URL', From e3b930b50183cec310b8c549527241056229c8d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Caba=C3=A7o?= Date: Fri, 4 Aug 2023 14:56:57 +0100 Subject: [PATCH 2/2] Apply review changes --- apps/docs/docs/ref/self-hosting-analytics/introduction.mdx | 3 ++- docker/docker-compose.yml | 2 +- studio/pages/api/projects/[ref]/analytics/endpoints/[name].ts | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/docs/docs/ref/self-hosting-analytics/introduction.mdx b/apps/docs/docs/ref/self-hosting-analytics/introduction.mdx index d5e21166eb1..1158463ba48 100644 --- a/apps/docs/docs/ref/self-hosting-analytics/introduction.mdx +++ b/apps/docs/docs/ref/self-hosting-analytics/introduction.mdx @@ -103,6 +103,8 @@ docker compose -f docker-compose.yml up > ⚠️ WARNING: Please be aware of the heavy consumption of analytics. For heavy usage you might want to consider the usage of a different database for analytics only by updating the `POSTGRES_BACKEND_URL` in the `analytics` service on the `docker-compose.yml` file. +Also be aware that you won't be able to use [Log Explorer](https://supabase.com/docs/guides/platform/logs#logs-explorer) when using the Postgres Backend as some of the querying features are still not supported by our translation layer. + #### Using the Big Query Backend Using the example [self-hosting stack based on docker-compose](https://github.com/supabase/supabase/tree/master/docker), you include the logging related services using the following command @@ -113,7 +115,6 @@ Using the example [self-hosting stack based on docker-compose](https://github.co - `GOOGLE_PROJECT_NUMBER` 2. Place your Service Account key in your present working directory with the filename `gcloud.json`. - 3. On `docker-compose.yml`, uncomment the block section below the commentary `# Uncomment to use Big Query backend for analytics` 4. On `docker-compose.yml`, comment the block section below the commentary `# Comment variables to use Big Query backend for analytics` diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 4cf8e301d4f..d6a3eefaf20 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -49,7 +49,7 @@ services: # Comment to use Big Query backend for analytics NEXT_ANALYTICS_BACKEND_PROVIDER: postgres # Uncomment to use Big Query backend for analytics - # NEXT_ANALYTICS_BACKEND_PROVIDER: big_query + # NEXT_ANALYTICS_BACKEND_PROVIDER: bigquery kong: container_name: supabase-kong diff --git a/studio/pages/api/projects/[ref]/analytics/endpoints/[name].ts b/studio/pages/api/projects/[ref]/analytics/endpoints/[name].ts index 8ab24a44941..6322ef0c48a 100644 --- a/studio/pages/api/projects/[ref]/analytics/endpoints/[name].ts +++ b/studio/pages/api/projects/[ref]/analytics/endpoints/[name].ts @@ -15,10 +15,10 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { .status(400) .json({ error: { message: '[analytics] is not enabled in supabase/config.toml' } }) } - if (process.env.NEXT_ANALYTICS_BACKEND_PROVIDER !== 'big_query') { + if (process.env.NEXT_ANALYTICS_BACKEND_PROVIDER !== 'bigquery') { return res .status(400) - .json({ error: { message: 'Log Explorer is only supported by the [analytics] Big Query backend, please refer to the documentation to set it up' } }) + .json({ error: { message: 'Log Explorer is only supported by the [analytics] Big Query backend. Please refer to https://supabase.com/docs/reference/self-hosting-analytics/introduction for more information' } }) } const missingEnvVars = [ process.env.LOGFLARE_API_KEY ? null : 'LOGFLARE_API_KEY',