Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/content/docs/integrations/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ communication over numerous protocols and APIs:
<Integration>nats</Integration>, <Integration>amazon/sqs</Integration>,
<Integration>amqp</Integration>
- **Databases**: <Integration>snowflake</Integration>,
<Integration>clickhouse</Integration>, <Integration>mysql</Integration>
<Integration>clickhouse</Integration>, <Integration>mysql</Integration>,
<Integration>microsoft/sql-server</Integration>
- **Network protocols**: <Integration>tcp</Integration>,
<Integration>udp</Integration>, <Integration>http</Integration>,
<Integration>syslog</Integration>
Expand Down
110 changes: 110 additions & 0 deletions src/content/docs/integrations/microsoft/sql-server.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
---
title: Microsoft SQL Server
---

import Op from '@components/see-also/Op.astro';

This guide shows you how to read events from Microsoft SQL Server and Azure SQL
Database with Tenzir.

Use <Op>from_microsoft_sql</Op> to connect to Microsoft SQL Server over the
Tabular Data Stream (TDS) protocol. The operator can read a full table, execute
a custom query, list table metadata, or poll a table for newly inserted rows.

## Connect to Azure SQL

Azure SQL Database accepts TDS connections on port `1433` and requires TLS. Use
the server host name from Azure, usually in the form
`<server>.database.windows.net`, and set `tls=true`.

```tql
from_microsoft_sql query="SELECT TOP 10 * FROM dbo.events",
host="example.database.windows.net",
port=1433,
user="tenzir_reader",
password=secret("azure-sql-password"),
database="security",
tls=true
```

The operator currently supports SQL authentication. Microsoft Entra
authentication, managed identities, Windows authentication, and Kerberos are not
supported.

## Read from SQL Server

Use `table` to read every row from a table:

```tql
from_microsoft_sql table="dbo.events",
host="sql.example.com",
user="tenzir_reader",
password=secret("sql-server-password"),
database="security",
tls=true
```

Use `query` or `sql` when you want to select, filter, or join data in SQL
Server before Tenzir receives it:

```tql
from_microsoft_sql query=r"SELECT id, created_at, source, message
FROM dbo.events
WHERE severity >= 3",
host="sql.example.com",
user="tenzir_reader",
password=secret("sql-server-password"),
database="security",
tls=true
```

## Stream new rows

Set `live=true` to poll a table for newly inserted rows. Live mode uses a
monotonic integer tracking column as a watermark. If you don't specify
`tracking_column`, the operator tries to detect a single integer identity column
or a single integer primary-key column.

```tql
from_microsoft_sql table="dbo.events",
live=true,
tracking_column="id",
host="sql.example.com",
user="tenzir_reader",
password=secret("sql-server-password"),
database="security",
tls=true
```

Live mode initializes its watermark from the current maximum tracking value and
then emits rows with greater values. It doesn't emit an initial snapshot, and it
doesn't capture updates or deletes.

## Inspect metadata

List all base tables in the selected database:

```tql
from_microsoft_sql show="tables",
host="sql.example.com",
user="tenzir_reader",
password=secret("sql-server-password"),
database="security",
tls=true
```

List columns for a table:

```tql
from_microsoft_sql show="columns",
table="dbo.events",
host="sql.example.com",
user="tenzir_reader",
password=secret("sql-server-password"),
database="security",
tls=true
```

## See Also

- <Op>from_microsoft_sql</Op>
12 changes: 12 additions & 0 deletions src/content/docs/reference/operators.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ operators:
description: 'Reads events from a Microsoft Graph collection.'
example: 'from_microsoft_graph "auditLogs/signIns", auth={…}'
path: 'reference/operators/from_microsoft_graph'
- name: 'from_microsoft_sql'
description: 'Reads events from Microsoft SQL Server or Azure SQL Database.'
example: 'from_microsoft_sql table="dbo.events", host="sql.example.com", database="security", tls=true'
path: 'reference/operators/from_microsoft_sql'
- name: 'from_mysql'
description: 'Reads events from a MySQL database.'
example: 'from_mysql table="users", host="db.example.com", database="mydb"'
Expand Down Expand Up @@ -1526,6 +1530,14 @@ from_microsoft_graph "auditLogs/signIns", auth={…}

</ReferenceCard>

<ReferenceCard title="from_microsoft_sql" description="Reads events from Microsoft SQL Server or Azure SQL Database." href="/reference/operators/from_microsoft_sql">

```tql
from_microsoft_sql table="dbo.events", host="sql.example.com", database="security", tls=true
```

</ReferenceCard>

<ReferenceCard title="from_mysql" description="Reads events from a MySQL database." href="/reference/operators/from_mysql">

```tql
Expand Down
Loading
Loading