~/ endpoints /logs.all
id: 1659a7b7-0b83-44f0-ad12-c018ddcf1cef
BigQuery SQL
with edge_logs as (
select
t.timestamp,
t.id,
t.event_message,
t.metadata
from `cloudflare.logs.prod` as t
cross join unnest(metadata) as m
where
-- order of the where clauses matters
-- project then timestamp then everything else
t.project = @project
AND CASE WHEN COALESCE(@iso_timestamp_start, '') = '' THEN TRUE ELSE cast(t.timestamp as timestamp) > cast(@iso_timestamp_start as timestamp) END
AND CASE WHEN COALESCE(@iso_timestamp_end, '') = '' THEN TRUE ELSE cast(t.timestamp as timestamp) <= cast(@iso_timestamp_end as timestamp) END
order by
cast(t.timestamp as timestamp) desc
),
postgres_logs as (
select
t.timestamp,
t.id,
t.event_message,
t.metadata
from `postgres.logs` as t
where
-- order of the where clauses matters
-- project then timestamp then everything else
t.project = @project
AND CASE WHEN COALESCE(@iso_timestamp_start, '') = '' THEN TRUE ELSE cast(t.timestamp as timestamp) > cast(@iso_timestamp_start as timestamp) END
AND CASE WHEN COALESCE(@iso_timestamp_end, '') = '' THEN TRUE ELSE cast(t.timestamp as timestamp) <= cast(@iso_timestamp_end as timestamp) END
order by cast(t.timestamp as timestamp) desc
),
function_edge_logs as (
select
t.timestamp,
t.id,
t.event_message,
t.metadata
from `deno-relay-logs` as t
cross join unnest(t.metadata) as m
where
CASE WHEN COALESCE(@iso_timestamp_start, '') = '' THEN TRUE ELSE cast(t.timestamp as timestamp) > cast(@iso_timestamp_start as timestamp) END
AND CASE WHEN COALESCE(@iso_timestamp_end, '') = '' THEN TRUE ELSE cast(t.timestamp as timestamp) <= cast(@iso_timestamp_end as timestamp) END
and m.project_ref = @project
order by cast(t.timestamp as timestamp) desc
),
function_logs as (
select
t.timestamp,
t.id,
t.event_message,
t.metadata
from `deno-subhosting-events` as t
cross join unnest(t.metadata) as m
where
-- order of the where clauses matters
-- project then timestamp then everything else
m.project_ref = @project
AND CASE WHEN COALESCE(@iso_timestamp_start, '') = '' THEN TRUE ELSE cast(t.timestamp as timestamp) > cast(@iso_timestamp_start as timestamp) END
AND CASE WHEN COALESCE(@iso_timestamp_end, '') = '' THEN TRUE ELSE cast(t.timestamp as timestamp) <= cast(@iso_timestamp_end as timestamp) END
order by cast(t.timestamp as timestamp) desc
),
auth_logs as (
select
t.timestamp,
t.id,
t.event_message,
t.metadata
from `gotrue.logs.prod` as t
cross join unnest(t.metadata) as m
where
-- order of the where clauses matters
-- project then timestamp then everything else
-- m.project = @project
t.project = @project
AND CASE WHEN COALESCE(@iso_timestamp_start, '') = '' THEN TRUE ELSE cast(t.timestamp as timestamp) > cast(@iso_timestamp_start as timestamp) END
AND CASE WHEN COALESCE(@iso_timestamp_end, '') = '' THEN TRUE ELSE cast(t.timestamp as timestamp) <= cast(@iso_timestamp_end as timestamp) END
order by cast(t.timestamp as timestamp) desc
),
realtime_logs as (
select
t.timestamp,
t.id,
t.event_message,
t.metadata
from `realtime.logs.prod` as t
cross join unnest(t.metadata) as m
where
m.project = @project
AND CASE WHEN COALESCE(@iso_timestamp_start, '') = '' THEN TRUE ELSE cast(t.timestamp as timestamp) > cast(@iso_timestamp_start as timestamp) END
AND CASE WHEN COALESCE(@iso_timestamp_end, '') = '' THEN TRUE ELSE cast(t.timestamp as timestamp) <= cast(@iso_timestamp_end as timestamp) END
order by cast(t.timestamp as timestamp) desc
),
storage_logs as (
select
t.timestamp,
t.id,
t.event_message,
t.metadata
from `storage.logs.prod.2` as t
cross join unnest(t.metadata) as m
where
m.project = @project
AND CASE WHEN COALESCE(@iso_timestamp_start, '') = '' THEN TRUE ELSE cast(t.timestamp as timestamp) > cast(@iso_timestamp_start as timestamp) END
AND CASE WHEN COALESCE(@iso_timestamp_end, '') = '' THEN TRUE ELSE cast(t.timestamp as timestamp) <= cast(@iso_timestamp_end as timestamp) END
order by cast(t.timestamp as timestamp) desc
),
postgrest_logs as (
select
t.timestamp,
t.id,
t.event_message,
t.metadata
from `postgREST.logs.prod` as t
cross join unnest(t.metadata) as m
where
CASE WHEN COALESCE(@iso_timestamp_start, '') = '' THEN TRUE ELSE cast(t.timestamp as timestamp) > cast(@iso_timestamp_start as timestamp) END
AND CASE WHEN COALESCE(@iso_timestamp_end, '') = '' THEN TRUE ELSE cast(t.timestamp as timestamp) <= cast(@iso_timestamp_end as timestamp) END
AND t.project = @project
order by cast(t.timestamp as timestamp) desc
),
pgbouncer_logs as (
select
t.timestamp,
t.id,
t.event_message,
t.metadata
from `pgbouncer.logs.prod` as t
cross join unnest(t.metadata) as m
where
CASE WHEN COALESCE(@iso_timestamp_start, '') = '' THEN TRUE ELSE cast(t.timestamp as timestamp) > cast(@iso_timestamp_start as timestamp) END
AND CASE WHEN COALESCE(@iso_timestamp_end, '') = '' THEN TRUE ELSE cast(t.timestamp as timestamp) <= cast(@iso_timestamp_end as timestamp) END
AND t.project = @project
order by cast(t.timestamp as timestamp) desc
)
SELECT id, timestamp, event_message, metadata
FROM edge_logs
LIMIT 100
- max rows: 1000
- caching: disabled
- query sandboxing: enabled
- redact PII: disabled
WITH edge_logs AS (SELECT t.timestamp, t.id, t.event_message, t.metadata FROM `cloudflare`.`logs`.`prod` AS t CROSS JOIN UNNEST(metadata) AS m WHERE t.project = @project AND CASE WHEN COALESCE(@iso_timestamp_start, '') = '' THEN true ELSE CAST(t.timestamp AS TIMESTAMP) > CAST(@iso_timestamp_start AS TIMESTAMP) END AND CASE WHEN COALESCE(@iso_timestamp_end, '') = '' THEN true ELSE CAST(t.timestamp AS TIMESTAMP) <= CAST(@iso_timestamp_end AS TIMESTAMP) END ORDER BY CAST(t.timestamp AS TIMESTAMP) DESC), postgres_logs AS (SELECT t.timestamp, t.id, t.event_message, t.metadata FROM `postgres`.`logs` AS t WHERE t.project = @project AND CASE WHEN COALESCE(@iso_timestamp_start, '') = '' THEN true ELSE CAST(t.timestamp AS TIMESTAMP) > CAST(@iso_timestamp_start AS TIMESTAMP) END AND CASE WHEN COALESCE(@iso_timestamp_end, '') = '' THEN true ELSE CAST(t.timestamp AS TIMESTAMP) <= CAST(@iso_timestamp_end AS TIMESTAMP) END ORDER BY CAST(t.timestamp AS TIMESTAMP) DESC), function_edge_logs AS (SELECT t.timestamp, t.id, t.event_message, t.metadata FROM `deno-relay-logs` AS t CROSS JOIN UNNEST(t.metadata) AS m WHERE CASE WHEN COALESCE(@iso_timestamp_start, '') = '' THEN true ELSE CAST(t.timestamp AS TIMESTAMP) > CAST(@iso_timestamp_start AS TIMESTAMP) END AND CASE WHEN COALESCE(@iso_timestamp_end, '') = '' THEN true ELSE CAST(t.timestamp AS TIMESTAMP) <= CAST(@iso_timestamp_end AS TIMESTAMP) END AND m.project_ref = @project ORDER BY CAST(t.timestamp AS TIMESTAMP) DESC), function_logs AS (SELECT t.timestamp, t.id, t.event_message, t.metadata FROM `deno-subhosting-events` AS t CROSS JOIN UNNEST(t.metadata) AS m WHERE m.project_ref = @project AND CASE WHEN COALESCE(@iso_timestamp_start, '') = '' THEN true ELSE CAST(t.timestamp AS TIMESTAMP) > CAST(@iso_timestamp_start AS TIMESTAMP) END AND CASE WHEN COALESCE(@iso_timestamp_end, '') = '' THEN true ELSE CAST(t.timestamp AS TIMESTAMP) <= CAST(@iso_timestamp_end AS TIMESTAMP) END ORDER BY CAST(t.timestamp AS TIMESTAMP) DESC), auth_logs AS (SELECT t.timestamp, t.id, t.event_message, t.metadata FROM `gotrue`.`logs`.`prod` AS t CROSS JOIN UNNEST(t.metadata) AS m WHERE t.project = @project AND CASE WHEN COALESCE(@iso_timestamp_start, '') = '' THEN true ELSE CAST(t.timestamp AS TIMESTAMP) > CAST(@iso_timestamp_start AS TIMESTAMP) END AND CASE WHEN COALESCE(@iso_timestamp_end, '') = '' THEN true ELSE CAST(t.timestamp AS TIMESTAMP) <= CAST(@iso_timestamp_end AS TIMESTAMP) END ORDER BY CAST(t.timestamp AS TIMESTAMP) DESC), realtime_logs AS (SELECT t.timestamp, t.id, t.event_message, t.metadata FROM `realtime`.`logs`.`prod` AS t CROSS JOIN UNNEST(t.metadata) AS m WHERE m.project = @project AND CASE WHEN COALESCE(@iso_timestamp_start, '') = '' THEN true ELSE CAST(t.timestamp AS TIMESTAMP) > CAST(@iso_timestamp_start AS TIMESTAMP) END AND CASE WHEN COALESCE(@iso_timestamp_end, '') = '' THEN true ELSE CAST(t.timestamp AS TIMESTAMP) <= CAST(@iso_timestamp_end AS TIMESTAMP) END ORDER BY CAST(t.timestamp AS TIMESTAMP) DESC), storage_logs AS (SELECT t.timestamp, t.id, t.event_message, t.metadata FROM `storage`.`logs`.`prod`.`2` AS t CROSS JOIN UNNEST(t.metadata) AS m WHERE m.project = @project AND CASE WHEN COALESCE(@iso_timestamp_start, '') = '' THEN true ELSE CAST(t.timestamp AS TIMESTAMP) > CAST(@iso_timestamp_start AS TIMESTAMP) END AND CASE WHEN COALESCE(@iso_timestamp_end, '') = '' THEN true ELSE CAST(t.timestamp AS TIMESTAMP) <= CAST(@iso_timestamp_end AS TIMESTAMP) END ORDER BY CAST(t.timestamp AS TIMESTAMP) DESC), postgrest_logs AS (SELECT t.timestamp, t.id, t.event_message, t.metadata FROM `postgREST`.`logs`.`prod` AS t CROSS JOIN UNNEST(t.metadata) AS m WHERE CASE WHEN COALESCE(@iso_timestamp_start, '') = '' THEN true ELSE CAST(t.timestamp AS TIMESTAMP) > CAST(@iso_timestamp_start AS TIMESTAMP) END AND CASE WHEN COALESCE(@iso_timestamp_end, '') = '' THEN true ELSE CAST(t.timestamp AS TIMESTAMP) <= CAST(@iso_timestamp_end AS TIMESTAMP) END AND t.project = @project ORDER BY CAST(t.timestamp AS TIMESTAMP) DESC), pgbouncer_logs AS (SELECT t.timestamp, t.id, t.event_message, t.metadata FROM `pgbouncer`.`logs`.`prod` AS t CROSS JOIN UNNEST(t.metadata) AS m WHERE CASE WHEN COALESCE(@iso_timestamp_start, '') = '' THEN true ELSE CAST(t.timestamp AS TIMESTAMP) > CAST(@iso_timestamp_start AS TIMESTAMP) END AND CASE WHEN COALESCE(@iso_timestamp_end, '') = '' THEN true ELSE CAST(t.timestamp AS TIMESTAMP) <= CAST(@iso_timestamp_end AS TIMESTAMP) END AND t.project = @project ORDER BY CAST(t.timestamp AS TIMESTAMP) DESC) SELECT id, timestamp, event_message, metadata FROM edge_logs LIMIT 100
Call your endpoint
# By UUID
curl "https://api.logflare.app/api/endpoints/query/1659a7b7-0b83-44f0-ad12-c018ddcf1cef" \
-H 'X-API-KEY: YOUR-ACCESS-TOKEN' \
-H 'Content-Type: application/json; charset=utf-8' \
-G -d "project=VALUE" -d "iso_timestamp_start=VALUE" -d "iso_timestamp_end=VALUE"
# By name
curl "https://api.logflare.app/api/endpoints/query/logs.all" \
-H 'X-API-KEY: YOUR-ACCESS-TOKEN' \
-H 'Content-Type: application/json; charset=utf-8' \
-G -d "project=VALUE" -d "iso_timestamp_start=VALUE" -d "iso_timestamp_end=VALUE"
# With per-request PII redaction
curl "https://api.logflare.app/api/endpoints/query/1659a7b7-0b83-44f0-ad12-c018ddcf1cef" \
-H 'X-API-KEY: YOUR-ACCESS-TOKEN' \
-H 'LF-ENDPOINT-REDACT-PII: true' \
-H 'Content-Type: application/json; charset=utf-8' \
-G -d "project=VALUE" -d "iso_timestamp_start=VALUE" -d "iso_timestamp_end=VALUE"