The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: add OTLP log drain (#42869)
Jordi Enrica806f7dc4469
diff --git a/apps/docs/content/guides/telemetry/log-drains.mdx b/apps/docs/content/guides/telemetry/log-drains.mdxindex 03d30a507e9..94a025230ef 100644--- a/apps/docs/content/guides/telemetry/log-drains.mdx+++ b/apps/docs/content/guides/telemetry/log-drains.mdx@@ -19,6 +19,7 @@ The following table lists the supported destinations and the required setup conf| Loki | HTTP | URL <br /> Headers || Sentry | HTTP | DSN || Amazon S3 | AWS SDK | S3 Bucket <br/> Region <br/> Access Key ID <br/> Secret Access Key <br/> Batch Timeout |+| OTLP | HTTP | Endpoint <br /> Protocol <br/> Gzip <br /> Headers |HTTP requests are batched with a max of 250 logs or 1 second intervals, whichever happens first. Logs are compressed via Gzip if the destination supports it.@@ -236,7 +237,7 @@ Required configuration when creating an S3 Log Drain:- Region: the AWS region where the bucket is located.- Access Key ID: used for authentication.- Secret Access Key: used for authentication.-- Batch Timeout (ms): maximum time to wait before flushing a batch. Recommended 2000–5000ms.+- Batch Timeout (ms): maximum time to wait before flushing a batch. Recommended 2000-5000ms.<Admonition type="note">@@ -244,6 +245,114 @@ Ensure the AWS account tied to the Access Key ID has permissions to write to the</Admonition>++## OpenTelemetry protocol (OTLP)++Logs are sent to any OTLP-compatible endpoint using the OpenTelemetry Protocol over HTTP with Protocol Buffers encoding.++OTLP is an open-standard protocol for telemetry data, making it compatible with many observability platforms including:++<ul>+ <li>OpenTelemetry Collector</li>+ <li>Grafana Cloud</li>+ <li>New Relic</li>+ <li>Honeycomb</li>+ <li>Datadog (OTLP ingestion)</li>+ <li>Elastic</li>+ <li>And many more</li>+</ul>++Required configuration when creating an OTLP Log Drain:++<ul>+ <li>Endpoint: The full URL of your OTLP HTTP endpoint (typically ending in `/v1/logs`)</li>+ <li>Protocol: Currently only `http/protobuf` is supported</li>+ <li>Gzip: Enable compression to reduce bandwidth (recommended: enabled)</li>+ <li>Headers: Optional authentication headers (e.g., `Authorization`, `X-API-Key`)</li>+</ul>++Logs are sent as OTLP log record messages using Protocol Buffers encoding, following the [OpenTelemetry Logs specification](https://opentelemetry.io/docs/specs/otel/logs/).++<Admonition type="note">++Ensure your OTLP endpoint is configured to accept logs at the `/v1/logs` path with `application/x-protobuf` content type.++</Admonition>++<Accordion+ type="default"+ openBehaviour="multiple"+>+ <AccordionItem+ header="OpenTelemetry Collector Example"+ id="otel-collector"+ >++To receive Supabase logs with the OpenTelemetry Collector, configure an OTLP HTTP receiver:++```yaml+receivers:+ otlp:+ protocols:+ http:+ endpoint: 0.0.0.0:4318++processors:+ batch:++exporters:+ logging:+ loglevel: debug++service:+ pipelines:+ logs:+ receivers: [otlp]+ processors: [batch]+ exporters: [logging]+```++Then create a log drain in [Supabase dashboard](/dashboard/project/_/settings/log-drains) with:++<ul>+ <li>Endpoint: `https://your-collector:4318/v1/logs`</li>+ <li>Add authentication headers as needed for your setup</li>+</ul>++ </AccordionItem>++ <AccordionItem+ header="Authentication Examples"+ id="auth"++>++Different OTLP platforms use different authentication methods. Add headers accordingly:++**API Key Authentication:**++```+X-API-Key: your-api-key+```++**Bearer Token:**++```+Authorization: Bearer your-token+```++**Basic Authentication:**++```+Authorization: Basic base64(username:password)+```++Refer to your observability platform's documentation for specific authentication requirements.++ </AccordionItem>++</Accordion>+## PricingFor a detailed breakdown of how charges are calculated, refer to [Manage Log Drain usage](/docs/guides/platform/manage-your-usage/log-drains).diff --git a/apps/studio/components/interfaces/LogDrains/LogDrainDestinationSheetForm.tsx b/apps/studio/components/interfaces/LogDrains/LogDrainDestinationSheetForm.tsxindex d44db9b5e40..c77b2cebfaa 100644--- a/apps/studio/components/interfaces/LogDrains/LogDrainDestinationSheetForm.tsx+++ b/apps/studio/components/interfaces/LogDrains/LogDrainDestinationSheetForm.tsx@@ -45,7 +45,12 @@ import {LAST9_REGIONS,LOG_DRAIN_TYPES,LogDrainType,+ OTLP_PROTOCOLS,} from './LogDrains.constants'+import {+ getHeadersSectionDescription as getHeadersDescription,+ validateNewHeader,+} from './LogDrains.utils'const FORM_ID = 'log-drain-destination-form'@@ -125,6 +130,16 @@ const formUnion = z.discriminatedUnion('type', [}),z.object({type: z.literal('otlp'),+ endpoint: z+ .string()+ .min(1, { message: 'OTLP endpoint is required' })+ .refine(+ (url) => url.startsWith('http://') || url.startsWith('https://'),+ 'OTLP endpoint must start with http:// or https://'+ ),+ protocol: z.string().optional().default('http/protobuf'),+ gzip: z.boolean().optional().default(true),+ headers: z.record(z.string(), z.string()).optional(),}),])@@ -189,14 +204,20 @@ export function LogDrainDestinationSheetForm({// and it does not include `type` inside the config itself, so it's not trivial to create `discriminatedUnion`// out of it, therefore for an ease of use now, we bail to `any` until the better time come.const defaultConfig = (defaultValues?.config || {}) as any- const CREATE_DEFAULT_HEADERS = {- 'Content-Type': 'application/json',+ const defaultType = defaultValues?.type || 'webhook'+ const CREATE_DEFAULT_HEADERS_BY_TYPE: Partial<Record<LogDrainType, Record<string, string>>> = {+ webhook: { 'Content-Type': 'application/json' },+ otlp: { 'Content-Type': 'application/x-protobuf' },}- const DEFAULT_HEADERS = mode === 'create' ? CREATE_DEFAULT_HEADERS : defaultConfig?.headers || {}+ const DEFAULT_HEADERS =+ mode === 'create'+ ? CREATE_DEFAULT_HEADERS_BY_TYPE[defaultType] ?? {}+ : defaultConfig?.headers || {}const sentryEnabled = useFlag('SentryLogDrain')const s3Enabled = useFlag('S3logdrain')const axiomEnabled = useFlag('axiomLogDrain')+ const otlpEnabled = useFlag('otlpLogDrain')const last9Enabled = useFlag('Last9LogDrain')const { ref } = useParams()@@ -204,7 +225,6 @@ export function LogDrainDestinationSheetForm({ref,})- const defaultType = defaultValues?.type || 'webhook'const [newCustomHeader, setNewCustomHeader] = useState({ name: '', value: '' })const track = useTrack()@@ -230,6 +250,8 @@ export function LogDrainDestinationSheetForm({batch_timeout: defaultConfig?.batch_timeout ?? 3000,dataset_name: defaultConfig?.dataset_name || '',api_token: defaultConfig?.api_token || '',+ endpoint: defaultConfig?.endpoint || '',+ protocol: defaultConfig?.protocol || 'http/protobuf',},})@@ -247,19 +269,13 @@ export function LogDrainDestinationSheetForm({function addHeader() {const formHeaders = form.getValues('headers')if (!formHeaders) return- const headerKeys = Object.keys(formHeaders)- if (headerKeys?.length === 20) {- toast.error('You can only have 20 custom headers')- return- }- if (headerKeys?.includes(newCustomHeader.name)) {- toast.error('Header name already exists')- return- }- if (!newCustomHeader.name || !newCustomHeader.value) {- toast.error('Header name and value are required')++ const validation = validateNewHeader(formHeaders, newCustomHeader)+ if (!validation.valid) {+ toast.error(validation.error)return}+form.setValue('headers', { ...formHeaders, [newCustomHeader.name]: newCustomHeader.value })setNewCustomHeader({ name: '', value: '' })}@@ -272,16 +288,6 @@ export function LogDrainDestinationSheetForm({}}, [mode, open, form])- function getHeadersSectionDescription() {- if (type === 'webhook') {- return 'Set custom headers when draining logs to the Endpoint URL'- }- if (type === 'loki') {- return 'Set custom headers when draining logs to the Loki HTTP(S) endpoint'- }- return ''- }-return (<Sheetopen={open}@@ -353,6 +359,7 @@ export function LogDrainDestinationSheetForm({if (t.value === 'sentry') return sentryEnabledif (t.value === 's3') return s3Enabledif (t.value === 'axiom') return axiomEnabled+ if (t.value === 'otlp') return otlpEnabledif (t.value === 'last9') return last9Enabledreturn true}).map((type) => (@@ -606,6 +613,69 @@ export function LogDrainDestinationSheetForm({/></div>)}+ {type === 'otlp' && (+ <>+ <div className="grid gap-4 px-content">+ <LogDrainFormItem+ type="url"+ value="endpoint"+ label="OTLP Endpoint"+ placeholder="https://otlp.example.com:4318/v1/logs"+ formControl={form.control}+ description="The HTTP endpoint for OTLP log ingestion (typically ends with /v1/logs)"+ />+ <FormField_Shadcn_+ name="protocol"+ control={form.control}+ render={({ field }) => (+ <FormItemLayout+ layout="horizontal"+ label="Protocol"+ description="Only HTTP with Protocol Buffers is currently supported"+ >+ <FormControl_Shadcn_>+ <Select_Shadcn_ value={field.value} onValueChange={field.onChange}>+ <SelectTrigger_Shadcn_ className="col-span-3">+ <SelectValue_Shadcn_ placeholder="Select protocol" />+ </SelectTrigger_Shadcn_>+ <SelectContent_Shadcn_>+ <SelectGroup_Shadcn_>+ <SelectLabel_Shadcn_>Protocol</SelectLabel_Shadcn_>+ {OTLP_PROTOCOLS.map((proto) => (+ <SelectItem_Shadcn_ key={proto.value} value={proto.value}>+ {proto.label}+ </SelectItem_Shadcn_>+ ))}+ </SelectGroup_Shadcn_>+ </SelectContent_Shadcn_>+ </Select_Shadcn_>+ </FormControl_Shadcn_>+ </FormItemLayout>+ )}+ />+ </div>++ <FormField_Shadcn_+ control={form.control}+ name="gzip"+ render={({ field }) => (+ <FormItem_Shadcn_ className="space-y-2 px-4">+ <div className="flex gap-2 items-center">+ <FormControl_Shadcn_>+ <Switch checked={field.value} onCheckedChange={field.onChange} />+ </FormControl_Shadcn_>+ <FormLabel_Shadcn_ className="text-base">+ Gzip Compression+ </FormLabel_Shadcn_>+ <InfoTooltip align="start">+ Enable gzip compression for log data sent to the OTLP endpoint.+ </InfoTooltip>+ </div>+ </FormItem_Shadcn_>+ )}+ />+ </>+ )}{type === 'last9' && (<div className="grid gap-4 px-content"><FormField_Shadcn_@@ -666,14 +736,12 @@ export function LogDrainDestinationSheetForm({</Form_Shadcn_>{/* This form needs to be outside the <Form_Shadcn_> */}- {(type === 'webhook' || type === 'loki') && (+ {(type === 'webhook' || type === 'loki' || type === 'otlp') && (<><div className="border-t mt-4"><div className="px-content pt-2 pb-3 border-b bg-background-alternative-200"><h2 className="text-sm">Custom Headers</h2>- <p className="text-xs text-foreground-lighter">- {getHeadersSectionDescription()}- </p>+ <p className="text-xs text-foreground-lighter">{getHeadersDescription(type)}</p></div><div className="divide-y">{hasHeaders &&diff --git a/apps/studio/components/interfaces/LogDrains/LogDrains.constants.tsx b/apps/studio/components/interfaces/LogDrains/LogDrains.constants.tsxindex 10c361b915a..c75c7721391 100644--- a/apps/studio/components/interfaces/LogDrains/LogDrains.constants.tsx+++ b/apps/studio/components/interfaces/LogDrains/LogDrains.constants.tsx@@ -1,5 +1,5 @@import { components } from 'api-types'-import { Axiom, Datadog, Grafana, Last9, Sentry } from 'icons'+import { Axiom, Datadog, Grafana, Last9, Otlp, Sentry } from 'icons'import { BracesIcon, Cloud } from 'lucide-react'const iconProps = {@@ -17,6 +17,12 @@ export const LOG_DRAIN_TYPES = [description: 'Forward logs as a POST request to a custom HTTP endpoint',icon: <BracesIcon {...iconProps} />,},+ {+ value: 'otlp',+ name: 'OpenTelemetry Protocol (OTLP)',+ description: 'Send logs to any OpenTelemetry Protocol (OTLP) compatible endpoint',+ icon: <Otlp {...iconProps} fill="currentColor" strokeWidth={0} />,+ },{value: 'datadog',name: 'Datadog',@@ -110,3 +116,12 @@ export type LogDrainDatadogConfig = {export type LogDrainWebhookConfig = {url: string}++export const OTLP_PROTOCOLS = [{ label: 'HTTP/Protobuf', value: 'http/protobuf' }] as const++export type LogDrainOtlpConfig = {+ endpoint: string+ protocol?: string+ gzip?: boolean+ headers?: Record<string, string>+}diff --git a/apps/studio/components/interfaces/LogDrains/LogDrains.tsx b/apps/studio/components/interfaces/LogDrains/LogDrains.tsxindex f9eb7436d21..af49b253c02 100644--- a/apps/studio/components/interfaces/LogDrains/LogDrains.tsx+++ b/apps/studio/components/interfaces/LogDrains/LogDrains.tsx@@ -58,6 +58,7 @@ export function LogDrains({const sentryEnabled = useFlag('SentryLogDrain')const s3Enabled = useFlag('S3logdrain')const axiomEnabled = useFlag('axiomLogDrain')+ const otlpEnabled = useFlag('otlpLogDrain')const last9Enabled = useFlag('Last9LogDrain')const hasLogDrains = !!logDrains?.length@@ -92,11 +93,12 @@ export function LogDrains({if (!isLoading && !hasLogDrains) {return (<>- <div className="grid lg:grid-cols-2 gap-4">+ <div className="grid lg:grid-cols-3 gap-4">{LOG_DRAIN_TYPES.filter((t) => {if (t.value === 'sentry') return sentryEnabledif (t.value === 's3') return s3Enabledif (t.value === 'axiom') return axiomEnabled+ if (t.value === 'otlp') return otlpEnabledif (t.value === 'last9') return last9Enabledreturn true}).map((src) => (diff --git a/apps/studio/components/interfaces/LogDrains/LogDrains.utils.test.ts b/apps/studio/components/interfaces/LogDrains/LogDrains.utils.test.tsnew file mode 100644index 00000000000..3c37c43ad9b--- /dev/null+++ b/apps/studio/components/interfaces/LogDrains/LogDrains.utils.test.ts@@ -0,0 +1,277 @@+import { describe, expect, it } from 'vitest'++import {+ getHeadersSectionDescription,+ HEADER_VALIDATION_ERRORS,+ otlpConfigSchema,+ validateNewHeader,+} from './LogDrains.utils'++describe('getHeadersSectionDescription', () => {+ it('returns webhook description for webhook type', () => {+ const result = getHeadersSectionDescription('webhook')+ expect(result).toBe('Set custom headers when draining logs to the Endpoint URL')+ })++ it('returns loki description for loki type', () => {+ const result = getHeadersSectionDescription('loki')+ expect(result).toBe('Set custom headers when draining logs to the Loki HTTP(S) endpoint')+ })++ it('returns otlp description for otlp type', () => {+ const result = getHeadersSectionDescription('otlp')+ expect(result).toBe(+ 'Set custom headers for OTLP authentication (e.g., Authorization, X-API-Key)'+ )+ })++ it('returns empty string for unsupported types', () => {+ expect(getHeadersSectionDescription('datadog')).toBe('')+ expect(getHeadersSectionDescription('s3')).toBe('')+ expect(getHeadersSectionDescription('sentry')).toBe('')+ })+})++describe('validateNewHeader', () => {+ describe('valid cases', () => {+ it('accepts valid header with empty existing headers', () => {+ const result = validateNewHeader({}, { name: 'Authorization', value: 'Bearer token' })+ expect(result.valid).toBe(true)+ expect(result.error).toBeUndefined()+ })++ it('accepts valid header with existing headers', () => {+ const existingHeaders = {+ 'Content-Type': 'application/json',+ 'X-Custom': 'value',+ }+ const result = validateNewHeader(existingHeaders, {+ name: 'Authorization',+ value: 'Bearer token',+ })+ expect(result.valid).toBe(true)+ expect(result.error).toBeUndefined()+ })+ })++ describe('validation errors', () => {+ it('rejects when 20 headers already exist', () => {+ const existingHeaders = Object.fromEntries(+ Array.from({ length: 20 }, (_, i) => [`Header-${i}`, `value-${i}`])+ )+ const result = validateNewHeader(existingHeaders, { name: 'New-Header', value: 'value' })+ expect(result.valid).toBe(false)+ expect(result.error).toBe(HEADER_VALIDATION_ERRORS.MAX_LIMIT)+ })++ it('rejects duplicate header names', () => {+ const existingHeaders = {+ 'Content-Type': 'application/json',+ Authorization: 'Bearer old-token',+ }+ const result = validateNewHeader(existingHeaders, {+ name: 'Authorization',+ value: 'Bearer new-token',+ })+ expect(result.valid).toBe(false)+ expect(result.error).toBe(HEADER_VALIDATION_ERRORS.DUPLICATE)+ })++ it('rejects header with empty name', () => {+ const result = validateNewHeader({}, { name: '', value: 'some-value' })+ expect(result.valid).toBe(false)+ expect(result.error).toBe(HEADER_VALIDATION_ERRORS.REQUIRED)+ })++ it('rejects header with empty value', () => {+ const result = validateNewHeader({}, { name: 'Some-Header', value: '' })+ expect(result.valid).toBe(false)+ expect(result.error).toBe(HEADER_VALIDATION_ERRORS.REQUIRED)+ })++ it('rejects header with both empty name and value', () => {+ const result = validateNewHeader({}, { name: '', value: '' })+ expect(result.valid).toBe(false)+ expect(result.error).toBe(HEADER_VALIDATION_ERRORS.REQUIRED)+ })+ })++ describe('edge cases', () => {+ it('allows exactly 19 existing headers', () => {+ const existingHeaders = Object.fromEntries(+ Array.from({ length: 19 }, (_, i) => [`Header-${i}`, `value-${i}`])+ )+ const result = validateNewHeader(existingHeaders, { name: 'New-Header', value: 'value' })+ expect(result.valid).toBe(true)+ })++ it('is case-sensitive for duplicate checking', () => {+ const existingHeaders = { authorization: 'bearer token' }+ const result = validateNewHeader(existingHeaders, {+ name: 'Authorization',+ value: 'Bearer token',+ })+ expect(result.valid).toBe(true)+ })+ })+})++describe('otlpConfigSchema', () => {+ describe('valid OTLP configurations', () => {+ it('accepts valid HTTPS endpoint with all fields', () => {+ const config = {+ type: 'otlp' as const,+ endpoint: 'https://otlp.example.com:4318/v1/logs',+ protocol: 'http/protobuf',+ gzip: true,+ headers: { Authorization: 'Bearer token' },+ }+ const result = otlpConfigSchema.safeParse(config)+ expect(result.success).toBe(true)+ if (result.success) {+ expect(result.data).toEqual(config)+ }+ })++ it('accepts HTTP endpoint (for testing environments)', () => {+ const config = {+ type: 'otlp' as const,+ endpoint: 'http://localhost:4318/v1/logs',+ }+ const result = otlpConfigSchema.safeParse(config)+ expect(result.success).toBe(true)+ })++ it('applies default values for optional fields', () => {+ const config = {+ type: 'otlp' as const,+ endpoint: 'https://otlp.example.com/v1/logs',+ }+ const result = otlpConfigSchema.safeParse(config)+ expect(result.success).toBe(true)+ if (result.success) {+ expect(result.data.protocol).toBe('http/protobuf')+ expect(result.data.gzip).toBe(true)+ }+ })++ it('accepts empty headers object', () => {+ const config = {+ type: 'otlp' as const,+ endpoint: 'https://otlp.example.com/v1/logs',+ headers: {},+ }+ const result = otlpConfigSchema.safeParse(config)+ expect(result.success).toBe(true)+ })++ it('accepts multiple custom headers', () => {+ const config = {+ type: 'otlp' as const,+ endpoint: 'https://otlp.example.com/v1/logs',+ headers: {+ Authorization: 'Bearer token',+ 'X-API-Key': 'secret-key',+ 'X-Custom-Header': 'custom-value',+ },+ }+ const result = otlpConfigSchema.safeParse(config)+ expect(result.success).toBe(true)+ })+ })++ describe('invalid OTLP configurations', () => {+ it('rejects empty endpoint', () => {+ const config = {+ type: 'otlp' as const,+ endpoint: '',+ }+ const result = otlpConfigSchema.safeParse(config)+ expect(result.success).toBe(false)+ if (!result.success) {+ expect(result.error.issues[0].message).toContain('OTLP endpoint is required')+ }+ })++ it('rejects endpoint without protocol', () => {+ const config = {+ type: 'otlp' as const,+ endpoint: 'otlp.example.com/v1/logs',+ }+ const result = otlpConfigSchema.safeParse(config)+ expect(result.success).toBe(false)+ if (!result.success) {+ expect(result.error.issues[0].message).toContain('must start with http:// or https://')+ }+ })++ it('rejects endpoint with invalid protocol', () => {+ const config = {+ type: 'otlp' as const,+ endpoint: 'ftp://otlp.example.com/v1/logs',+ }+ const result = otlpConfigSchema.safeParse(config)+ expect(result.success).toBe(false)+ })++ it('rejects endpoint with ws:// protocol', () => {+ const config = {+ type: 'otlp' as const,+ endpoint: 'ws://otlp.example.com/v1/logs',+ }+ const result = otlpConfigSchema.safeParse(config)+ expect(result.success).toBe(false)+ })++ it('rejects wrong type field', () => {+ const config = {+ type: 'webhook' as const,+ endpoint: 'https://otlp.example.com/v1/logs',+ }+ const result = otlpConfigSchema.safeParse(config)+ expect(result.success).toBe(false)+ })+ })++ describe('edge cases', () => {+ it('accepts endpoint with port number', () => {+ const config = {+ type: 'otlp' as const,+ endpoint: 'https://otlp.example.com:4318/v1/logs',+ }+ const result = otlpConfigSchema.safeParse(config)+ expect(result.success).toBe(true)+ })++ it('accepts endpoint with query parameters', () => {+ const config = {+ type: 'otlp' as const,+ endpoint: 'https://otlp.example.com/v1/logs?tenant=123',+ }+ const result = otlpConfigSchema.safeParse(config)+ expect(result.success).toBe(true)+ })++ it('accepts endpoint with authentication in URL', () => {+ const config = {+ type: 'otlp' as const,+ endpoint: 'https://user:[email protected]/v1/logs',+ }+ const result = otlpConfigSchema.safeParse(config)+ expect(result.success).toBe(true)+ })++ it('allows gzip to be explicitly false', () => {+ const config = {+ type: 'otlp' as const,+ endpoint: 'https://otlp.example.com/v1/logs',+ gzip: false,+ }+ const result = otlpConfigSchema.safeParse(config)+ expect(result.success).toBe(true)+ if (result.success) {+ expect(result.data.gzip).toBe(false)+ }+ })+ })+})diff --git a/apps/studio/components/interfaces/LogDrains/LogDrains.utils.ts b/apps/studio/components/interfaces/LogDrains/LogDrains.utils.tsnew file mode 100644index 00000000000..5195513ce75--- /dev/null+++ b/apps/studio/components/interfaces/LogDrains/LogDrains.utils.ts@@ -0,0 +1,77 @@+/**+ * Utility functions for log drain management+ * Extracted for testability+ */++import { z } from 'zod'++import { LogDrainType } from './LogDrains.constants'++/**+ * Get the description text for the custom headers section based on log drain type+ */+export function getHeadersSectionDescription(type: LogDrainType): string {+ if (type === 'webhook') {+ return 'Set custom headers when draining logs to the Endpoint URL'+ }+ if (type === 'loki') {+ return 'Set custom headers when draining logs to the Loki HTTP(S) endpoint'+ }+ if (type === 'otlp') {+ return 'Set custom headers for OTLP authentication (e.g., Authorization, X-API-Key)'+ }+ return ''+}++/**+ * Validation errors for header management+ */+export const HEADER_VALIDATION_ERRORS = {+ MAX_LIMIT: 'You can only have 20 custom headers',+ DUPLICATE: 'Header name already exists',+ REQUIRED: 'Header name and value are required',+} as const++/**+ * Validates if a new header can be added to the existing headers+ */+export function validateNewHeader(+ existingHeaders: Record<string, string>,+ newHeader: { name: string; value: string }+): { valid: boolean; error?: string } {+ const headerKeys = Object.keys(existingHeaders)++ if (headerKeys.length >= 20) {+ return { valid: false, error: HEADER_VALIDATION_ERRORS.MAX_LIMIT }+ }++ if (headerKeys.includes(newHeader.name)) {+ return { valid: false, error: HEADER_VALIDATION_ERRORS.DUPLICATE }+ }++ if (!newHeader.name || !newHeader.value) {+ return { valid: false, error: HEADER_VALIDATION_ERRORS.REQUIRED }+ }++ return { valid: true }+}++/**+ * Zod schema for OTLP log drain configuration+ * Extracted for testing purposes+ */+export const otlpConfigSchema = z.object({+ type: z.literal('otlp'),+ endpoint: z+ .string()+ .min(1, { message: 'OTLP endpoint is required' })+ .refine(+ (url) => url.startsWith('http://') || url.startsWith('https://'),+ 'OTLP endpoint must start with http:// or https://'+ ),+ protocol: z.string().optional().default('http/protobuf'),+ gzip: z.boolean().optional().default(true),+ headers: z.record(z.string(), z.string()).optional(),+})++export type OtlpConfig = z.infer<typeof otlpConfigSchema>diff --git a/apps/studio/components/layouts/LogsLayout/LogsSidebarMenuV2.tsx b/apps/studio/components/layouts/LogsLayout/LogsSidebarMenuV2.tsxindex 412f796de34..fa3f1d5191d 100644--- a/apps/studio/components/layouts/LogsLayout/LogsSidebarMenuV2.tsx+++ b/apps/studio/components/layouts/LogsLayout/LogsSidebarMenuV2.tsx@@ -380,7 +380,9 @@ export function LogsSidebarMenuV2() {description="Send logs to your preferred observability or storage platform."illustration={<div className="flex items-center gap-4">- {LOG_DRAIN_TYPES.map((type) =>+ {LOG_DRAIN_TYPES.filter((t) =>+ ['datadog', 'sentry', 'webhook', 'loki'].includes(t.value)+ ).map((type) =>React.cloneElement(type.icon, { key: type.name, height: 20, width: 20 }))}</div>diff --git a/apps/studio/components/ui/DataTable/FilterSideBar.tsx b/apps/studio/components/ui/DataTable/FilterSideBar.tsxindex cceb6943e85..d3adfbc5479 100644--- a/apps/studio/components/ui/DataTable/FilterSideBar.tsx+++ b/apps/studio/components/ui/DataTable/FilterSideBar.tsx@@ -1,16 +1,16 @@-import { useRouter } from 'next/router'-import { useFlag, useParams } from 'common'import { useUnifiedLogsPreview } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'+import { LOG_DRAIN_TYPES } from 'components/interfaces/LogDrains/LogDrains.constants'+import Link from 'next/link'+import { useRouter } from 'next/router'+import React from 'react'import { Button, cn, ResizablePanel } from 'ui'+import { FeaturePreviewSidebarPanel } from '../FeaturePreviewSidebarPanel'import { DateRangeDisabled } from './DataTable.types'import { DataTableFilterControls } from './DataTableFilters/DataTableFilterControls'import { DataTableResetButton } from './DataTableResetButton'import { useDataTable } from './providers/DataTableProvider'-import Link from 'next/link'-import { LOG_DRAIN_TYPES } from 'components/interfaces/LogDrains/LogDrains.constants'-import React from 'react'interface FilterSideBarProps {dateRangeDisabled?: DateRangeDisabled@@ -69,9 +69,9 @@ export function FilterSideBar({ dateRangeDisabled }: FilterSideBarProps) {description="Send logs to your preferred observability or storage platform."illustration={<div className="flex items-center gap-4">- {LOG_DRAIN_TYPES.map((type) =>- React.cloneElement(type.icon, { height: 20, width: 20 })- )}+ {LOG_DRAIN_TYPES.filter((t) =>+ ['datadog', 'sentry', 'webhook', 'loki'].includes(t.value)+ ).map((type) => React.cloneElement(type.icon, { height: 20, width: 20 }))}</div>}actions={diff --git a/apps/studio/pages/project/[ref]/settings/log-drains.tsx b/apps/studio/pages/project/[ref]/settings/log-drains.tsxindex 252a9ae07f7..c23317b482a 100644--- a/apps/studio/pages/project/[ref]/settings/log-drains.tsx+++ b/apps/studio/pages/project/[ref]/settings/log-drains.tsx@@ -52,6 +52,7 @@ const LogDrainsSettings: NextPageWithLayout = () => {const sentryEnabled = useFlag('SentryLogDrain')const s3Enabled = useFlag('S3logdrain')const axiomEnabled = useFlag('axiomLogDrain')+ const otlpEnabled = useFlag('otlpLogDrain')const last9Enabled = useFlag('Last9LogDrain')const { data: logDrains } = useLogDrainsQuery(@@ -219,6 +220,7 @@ const LogDrainsSettings: NextPageWithLayout = () => {if (t.value === 'sentry') return sentryEnabledif (t.value === 's3') return s3Enabledif (t.value === 'axiom') return axiomEnabled+ if (t.value === 'otlp') return otlpEnabledif (t.value === 'last9') return last9Enabledreturn true}).map((drainType) => (diff --git a/packages/icons/__registry__/index.tsx b/packages/icons/__registry__/index.tsxindex 553a5ad7857..90dcfd1635f 100644--- a/packages/icons/__registry__/index.tsx+++ b/packages/icons/__registry__/index.tsx@@ -204,6 +204,16 @@ export const Index: Record<string, any> = [svg: "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" stroke=\"currentColor\"\n stroke-width=\"1\">\n <path\n d=\"M4.5 5.20679H4.53713M7.46241 5.21707H19.5M4.5 9.65839H4.53713M7.46241 9.66868H19.5M4.52692 14.164H4.53713M7.46241 14.1742H19.5M4.52692 18.7068L4.53713 18.6965M7.46241 18.7068H19.5\" />\n</svg>",jsx: "import { Logs } from \"icons\"\n <Logs/>\n "},+{+ name: "otlp",+ componentName: "Otlp",+ deprecated: false,+ raw: "import createSupabaseIcon from '../createSupabaseIcon';\n\n/**\n * @component @name Otlp\n * @description Supabase SVG icon component, renders SVG Element with children.\n *\n * @preview \n *\n * @param {Object} props - Supabase icons props and any valid SVG attribute\n * @returns {JSX.Element} JSX Element\n *\n */\nconst Otlp = createSupabaseIcon('Otlp', [\n [\n 'path',\n {\n d: 'M12.68 13.09c-.984 .984-.984 2.58 0 3.564.984.984 2.58.984 3.564 0 .984-.984.984-2.58 0-3.564-.984-.984-2.58-.984-3.564 0zm2.664 2.666a1.246 1.246 0 0 1-1.764 0 1.246 1.246 0 0 1 0-1.764 1.246 1.246 0 0 1 1.764 0c.487.485.487 1.277 0 1.764zM16.205.688l-1.544 1.544a.782.782 0 0 0 0 1.102l6.028 6.028a.782.782 0 0 0 1.102 0l1.544-1.544c.302-.302.302-.799 0-1.101l-6.028-6.028a.78.78 0 0 0-1.102 0zM5.388 20.418a.706.706 0 0 0 0-.996l-.784-.784a.706.706 0 0 0-.996 0l-1.621 1.621-.003.002-.445-.445c-.246-.246-.647-.246-.891 0-.246.246-.246.647 0 .891l2.671 2.671a.629.629 0 0 0 .89 0c.244-.246.246-.647 0-.89l-.445-.445.003-.002zm0 0',\n key: 'i7z0x6',\n },\n ],\n [\n 'path',\n {\n d: 'M13.555 5.121 10.126 8.55c-.305.305-.305.806 0 1.111l2.119 2.119c1.497-1.078 3.596-.944 4.943.404l1.715-1.715c.304-.305.304-.806 0-1.111l-3.429-3.429a.785.785 0 0 0-1.11 0zM11.353 12.673l-1.251-1.251c-.293-.293-.773-.293-1.066 0l-4.411 4.413a.757.757 0 0 0 0 1.066l2.5 2.5a.757.757 0 0 0 1.066 0l2.837-2.842c-.6-1.24-.492-2.735.325-3.886zm0 0',\n key: '5ytdqc',\n },\n ],\n]);\n\nexport default Otlp;\n",+ component: React.lazy(() => import('icons/src/icons/otlp')),+ import: "import { Otlp } from 'icons'",+ svg: "<svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"currentColor\" stroke=\"currentColor\" stroke-width=\"0\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M12.68 13.09c-.984 .984-.984 2.58 0 3.564.984.984 2.58.984 3.564 0 .984-.984.984-2.58 0-3.564-.984-.984-2.58-.984-3.564 0zm2.664 2.666a1.246 1.246 0 0 1-1.764 0 1.246 1.246 0 0 1 0-1.764 1.246 1.246 0 0 1 1.764 0c.487.485.487 1.277 0 1.764zM16.205.688l-1.544 1.544a.782.782 0 0 0 0 1.102l6.028 6.028a.782.782 0 0 0 1.102 0l1.544-1.544c.302-.302.302-.799 0-1.101l-6.028-6.028a.78.78 0 0 0-1.102 0zM5.388 20.418a.706.706 0 0 0 0-.996l-.784-.784a.706.706 0 0 0-.996 0l-1.621 1.621-.003.002-.445-.445c-.246-.246-.647-.246-.891 0-.246.246-.246.647 0 .891l2.671 2.671a.629.629 0 0 0 .89 0c.244-.246.246-.647 0-.89l-.445-.445.003-.002zm0 0\"/>\n <path d=\"M13.555 5.121 10.126 8.55c-.305.305-.305.806 0 1.111l2.119 2.119c1.497-1.078 3.596-.944 4.943.404l1.715-1.715c.304-.305.304-.806 0-1.111l-3.429-3.429a.785.785 0 0 0-1.11 0zM11.353 12.673l-1.251-1.251c-.293-.293-.773-.293-1.066 0l-4.411 4.413a.757.757 0 0 0 0 1.066l2.5 2.5a.757.757 0 0 0 1.066 0l2.837-2.842c-.6-1.24-.492-2.735.325-3.886zm0 0\"/>\n</svg>\n",+ jsx: "import { Otlp } from \"icons\"\n <Otlp/>\n "+},{name: "postgres",componentName: "Postgres",diff --git a/packages/icons/src/icons/index.ts b/packages/icons/src/icons/index.tsindex 1f3dcfd5392..9ff7a79fbbe 100644--- a/packages/icons/src/icons/index.ts+++ b/packages/icons/src/icons/index.ts@@ -18,6 +18,7 @@ export { default as InsertCode } from './insert-code';export { default as Integrations } from './integrations';export { default as Last9 } from './last9';export { default as Logs } from './logs';+export { default as Otlp } from './otlp';export { default as Postgres } from './postgres';export { default as Realtime } from './realtime';export { default as ReplaceCode } from './replace-code';diff --git a/packages/icons/src/icons/otlp.ts b/packages/icons/src/icons/otlp.tsnew file mode 100644index 00000000000..44f1d2b1ed3--- /dev/null+++ b/packages/icons/src/icons/otlp.ts@@ -0,0 +1,30 @@+import createSupabaseIcon from '../createSupabaseIcon';++/**+ * @component @name Otlp+ * @description Supabase SVG icon component, renders SVG Element with children.+ *+ * @preview + *+ * @param {Object} props - Supabase icons props and any valid SVG attribute+ * @returns {JSX.Element} JSX Element+ *+ */+const Otlp = createSupabaseIcon('Otlp', [+ [+ 'path',+ {+ d: 'M12.68 13.09c-.984 .984-.984 2.58 0 3.564.984.984 2.58.984 3.564 0 .984-.984.984-2.58 0-3.564-.984-.984-2.58-.984-3.564 0zm2.664 2.666a1.246 1.246 0 0 1-1.764 0 1.246 1.246 0 0 1 0-1.764 1.246 1.246 0 0 1 1.764 0c.487.485.487 1.277 0 1.764zM16.205.688l-1.544 1.544a.782.782 0 0 0 0 1.102l6.028 6.028a.782.782 0 0 0 1.102 0l1.544-1.544c.302-.302.302-.799 0-1.101l-6.028-6.028a.78.78 0 0 0-1.102 0zM5.388 20.418a.706.706 0 0 0 0-.996l-.784-.784a.706.706 0 0 0-.996 0l-1.621 1.621-.003.002-.445-.445c-.246-.246-.647-.246-.891 0-.246.246-.246.647 0 .891l2.671 2.671a.629.629 0 0 0 .89 0c.244-.246.246-.647 0-.89l-.445-.445.003-.002zm0 0',+ key: 'i7z0x6',+ },+ ],+ [+ 'path',+ {+ d: 'M13.555 5.121 10.126 8.55c-.305.305-.305.806 0 1.111l2.119 2.119c1.497-1.078 3.596-.944 4.943.404l1.715-1.715c.304-.305.304-.806 0-1.111l-3.429-3.429a.785.785 0 0 0-1.11 0zM11.353 12.673l-1.251-1.251c-.293-.293-.773-.293-1.066 0l-4.411 4.413a.757.757 0 0 0 0 1.066l2.5 2.5a.757.757 0 0 0 1.066 0l2.837-2.842c-.6-1.24-.492-2.735.325-3.886zm0 0',+ key: '5ytdqc',+ },+ ],+]);++export default Otlp;diff --git a/packages/icons/src/raw-icons/otlp.svg b/packages/icons/src/raw-icons/otlp.svgnew file mode 100644index 00000000000..c46acb322bc--- /dev/null+++ b/packages/icons/src/raw-icons/otlp.svg@@ -0,0 +1,4 @@+<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" stroke="currentColor" stroke-width="0" xmlns="http://www.w3.org/2000/svg">+ <path d="M12.68 13.09c-.984 .984-.984 2.58 0 3.564.984.984 2.58.984 3.564 0 .984-.984.984-2.58 0-3.564-.984-.984-2.58-.984-3.564 0zm2.664 2.666a1.246 1.246 0 0 1-1.764 0 1.246 1.246 0 0 1 0-1.764 1.246 1.246 0 0 1 1.764 0c.487.485.487 1.277 0 1.764zM16.205.688l-1.544 1.544a.782.782 0 0 0 0 1.102l6.028 6.028a.782.782 0 0 0 1.102 0l1.544-1.544c.302-.302.302-.799 0-1.101l-6.028-6.028a.78.78 0 0 0-1.102 0zM5.388 20.418a.706.706 0 0 0 0-.996l-.784-.784a.706.706 0 0 0-.996 0l-1.621 1.621-.003.002-.445-.445c-.246-.246-.647-.246-.891 0-.246.246-.246.647 0 .891l2.671 2.671a.629.629 0 0 0 .89 0c.244-.246.246-.647 0-.89l-.445-.445.003-.002zm0 0"/>+ <path d="M13.555 5.121 10.126 8.55c-.305.305-.305.806 0 1.111l2.119 2.119c1.497-1.078 3.596-.944 4.943.404l1.715-1.715c.304-.305.304-.806 0-1.111l-3.429-3.429a.785.785 0 0 0-1.11 0zM11.353 12.673l-1.251-1.251c-.293-.293-.773-.293-1.066 0l-4.411 4.413a.757.757 0 0 0 0 1.066l2.5 2.5a.757.757 0 0 0 1.066 0l2.837-2.842c-.6-1.24-.492-2.735.325-3.886zm0 0"/>+</svg>