Connectors
Reference, rendered from docs/chloedb/connectors.md.
These docs follow main, which can be ahead of the latest release, 0.3.11 (its docs): a change made after it says so where it is described.
On this page
A connector brings another system's data into a table of chloedb-server, and keeps it coming: it reads the system on a schedule (a pull), takes what the system sends (a push), or, for Kafka, keeps reading its topics while it is on (a stream); it turns each record into a row by a map, and upserts the rows by the table's key, so a record read twice is the same row (a stream writes each event once, by its offset). Connectors are configured as rows of a table, each writes with a key limited to its own target, and the command center's Data > Connectors page shows each one's health.
| kind | pull or push | what it brings in | default table |
|---|---|---|---|
prometheus |
pull | PromQL queries over each new step (query_range), joined by labels into one row per subject and minute: the rollups an incident needs, the full series staying in Prometheus (or Thanos, Mimir, VictoriaMetrics) |
prometheus_rollups |
jira |
pull | issues matching a JQL query updated since the last run (Jira Cloud's /rest/api/3/search/jql, or Data Center's /rest/api/2/search) |
jira_issues |
servicenow |
pull | records of a table (change_request, incident, problem, ...) updated since the last run, through the Table API |
servicenow_records |
oxidized |
pull, and push from its hook | device configurations from oxidized-web: each node whose backup changed is fetched and kept as a version | device_configs |
mail |
push | emails handed over raw: headers, text, and the maintenance fields carriers attach (the BCOP X-MAINTNOTE iCalendar properties: provider, maintenance id, circuits, window, impact, status) |
mail_messages |
webhook |
push | any system that posts JSON; preset alertmanager for Alertmanager's webhook |
webhook_events, alertmanager_alerts |
http_json |
pull | any REST API that answers JSON: records at a path, the next page at another, a cursor kept from the records | http_records |
kafka |
stream | Kafka (or Redpanda, MSK, Confluent Cloud) topics, read by the server itself while the connector is on, each event written once: its partition's offset is kept with its row (Kafka topics) | kafka_events |
postgres |
stream | a Postgres database's tables by logical replication, followed by the server itself while the connector is on: copied, then every change applied a moment after Postgres commits it (databases) | the source's own tables |
mysql |
stream | a MySQL database's tables by its binary log, the same way (databases) | the source's own tables |
mcp |
pull | any MCP server's tool, called on a schedule over the Streamable HTTP transport (or a resource, read): its result's records become rows (MCP servers) | mcp_records |
s3 |
pull | a prefix of S3, Cloud Storage (gs://), R2, Spaces or MinIO watched for new Parquet or JSON-lines files, each read once it appears and again when it is written over (Files and warehouses) |
made from the files' columns |
snowflake |
pull | a Snowflake table or query through the SQL API: all of it the first time, then the rows whose cursor column (updated_at) grew |
made from the table's columns |
bigquery |
pull | a BigQuery table or query through the jobs API, read as Snowflake's is | made from the table's columns |
stripe |
pull | a list of Stripe's API (customers, charges, invoices, subscriptions, ...): every object the first time, then the objects of its events, so that changes and deletes come too (Apps) | stripe_records |
shopify |
pull | a store's orders, products or customers (the Admin API's REST resources) updated since the last run | shopify_records |
odoo |
pull | an Odoo model's records (res.partner, sale.order, crm.lead, ...) written since the last run, through its JSON-RPC API |
made from the model's fields |
hubspot |
pull | a HubSpot CRM object's records (contacts, companies, deals, tickets, a custom object) modified since the last run, with a private app's token or a sign-in | hubspot_records |
google_drive |
pull | the files of a folder (and its subfolders), a shared drive or a list modified since the last run, with the text of Docs, Slides, Sheets, Word, PowerPoint, Excel and text files, to search: paste a link, sign in with Google (Google Drive and Sheets) | drive_files |
google_sheets |
pull | a tab of a Google Sheet (or an Excel or CSV file in Drive) as a table, its columns from the header row and typed from the values, kept in step when the file changes | made from the tab's header |
Other ways rows come in stay as they are, and the Connectors page lists their sources beside the connectors: OpenTelemetry logs (POST /v1/logs, server.md), streams with offsets applied once (POST /v1/stream, which a consumer of your own can write), Postgres and MySQL followed by a process of their own (follow-postgres, follow-mysql), and files (SQLite, Parquet and S3).
Connect by pasting#
The Connectors page's Connect box takes what you have, a link, an address or a key, and makes the connectors it needs: it works out the system, asks only for the fields still missing (each with where to find its value), tries every connector before making it, and runs each once, linking its table. Each keeps in step from then on.
| pasted | what it makes |
|---|---|
| a Google Drive or Sheets link | the connectors of Google Drive and Sheets |
a Stripe key, sk_live_..., sk_test_... or a restricted rk_... |
stripe-customers, stripe-charges, stripe-invoices and stripe-subscriptions, a table each (stripe_customers, ...); a list the key may not read is left out, and said so |
a HubSpot private app's token, pat-... |
hubspot-contacts, -companies, -deals and -tickets |
a Shopify Admin API token, shpat_... (asks for the store), or a store's address, https://my-store.myshopify.com (asks for the token) |
the store's orders, products and customers |
postgres://user@host:5432/db or mysql://... (asks for the password unless the address has it) |
a follower of the database (databases); the password is taken out of the address and kept as a secret |
s3://bucket/prefix/ or gs://bucket/prefix/ |
an s3 connector of the prefix (asks for the keys when the bucket is not public) |
kafka://broker:9092/topic (kafka+ssl:// for TLS) |
a kafka connector of the topics, on from then on |
https://mycompany.odoo.com |
Odoo's partners, sales orders and leads (asks for the database, the login and an API key) |
any other https:// address |
an MCP server's: asks for its token if it wants one, then for the tool to call, from its own list |
Pasting the same thing again finds the connectors it made and runs them again, with the secret given, rather than making them twice; another account's key makes connectors of its own (stripe-customers-2, into stripe_customers_2), each connector keeping which account it reads as its setting account (a key's, a few bytes of its SHA-256). A key refused by its system is asked for again, with why. The key or password is never answered nor kept in the connector's note.
curl -X POST localhost:7700/v1/admin/connect -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
-d '{"text": "postgres://ana@db.example.com:5432/shop"}'
# {"title": "Postgres", "need": [{"field": "password", "label": "Password", "secret": true, "help": "…"}]}
curl -X POST localhost:7700/v1/admin/connect -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
-d '{"text": "postgres://ana@db.example.com:5432/shop", "fields": {"password": "…"}}'
# {"title": "Postgres", "connectors": [{"name": "pg-shop", "kind": "postgres", "ok": true, "following": true}], "notes": []}
The body: text, fields (the values of the fields asked for, and objects or resources to choose Stripe's, HubSpot's or Shopify's lists, comma separated), grant (a Google sign-in's), oauth (a sign-in's below), every_s. Something it does not know is a 400 that lists what it reads; for those, Add a connector makes any kind with its settings.
Sign in with HubSpot, Shopify or Stripe#
Beside the box, Sign in with HubSpot, Shopify (paste the store's address first) and Stripe connect with nothing to copy: the system's page opens, you allow ChloeDB to read, read-only, and the connectors are made with what it granted. Each button is greyed out until the server has an app at that system: register one, once, and give the server its client id and secret.
| system | register the app | redirect | read access asked for | flags |
|---|---|---|---|---|
| HubSpot | a HubSpot developer account (developers.hubspot.com): Apps → Create app (a public app), its Auth tab | https://<server>/v1/oauth/hubspot/callback |
crm.objects.contacts.read, crm.objects.companies.read, crm.objects.deals.read, tickets |
--hubspot-client-id, --hubspot-client-secret |
| Shopify | the Partner Dashboard (partners.shopify.com) or the Dev Dashboard: Apps → Create app, its configuration's Allowed redirection URL(s); for orders and customers, request Protected customer data access in its API access settings | https://<server>/v1/oauth/shopify/callback |
read_orders, read_products, read_customers |
--shopify-client-id, --shopify-client-secret |
| Stripe | the platform's Stripe account: Settings → Connect → Onboarding options → OAuth, turn OAuth on; the client id (ca_...) is there |
https://<server>/v1/oauth/stripe/callback |
read_only (Stripe Connect's OAuth) |
--stripe-client-id ca_..., --stripe-client-secret (the platform's secret key, sk_...) |
Each flag can be the environment's instead, CHLOEDB_HUBSPOT_CLIENT_ID and CHLOEDB_HUBSPOT_CLIENT_SECRET and so on (on Kubernetes, the secrets from a Secret: the StrataCluster's spec.secretEnv). The redirect is --public-url's address when it is set, else the address the page was opened at, so register the address people open the command center at (http://localhost:7700/v1/oauth/<system>/callback to try one on a laptop, where the system allows http://localhost).
The flow is OAuth's authorization code: POST /v1/admin/oauth/<system>/start ({"shop": "my-store.myshopify.com"} for Shopify) answers the system's address to open and a state; the system sends the browser back to /v1/oauth/<system>/callback with a code, which the server trades at once (for Shopify, after checking the answer's HMAC with the app's secret, and that it is for that store); GET /v1/admin/oauth/grant?state= then answers {"state": "done", "grant": "…", "account": "…"}, and POST /v1/admin/connect {"oauth": "<grant>"} makes the connectors. A sign-in has 10 minutes, its state is used once, and a grant waits 30 minutes. What each keeps, as the connectors' secrets (in the secrets file, never in a table or an answer):
- HubSpot: the refresh token, with the app's client id and secret (
refresh_token,client_id,client_secret); each run trades them for an access token of 30 minutes. Uninstalling the app in HubSpot ends it, and the next run says to sign in again. - Shopify: the store's offline access token (
access_token), as a pasted one. - Stripe: the connected account's read-only key (
api_key), as a pasted one; the account is named by its id (acct_...).
Make one#
POST /v1/admin/connectors with an admin key:
{
"name": "jira-changes",
"kind": "jira",
"target": "netops_changes",
"every_s": 300,
"config": {"url": "https://example.atlassian.net", "jql": "project = NET AND issuetype = Change", "username": "bot@example.com",
"fields": {"window_start": "customfield_10050", "window_end": "customfield_10051"}},
"secrets": {"token": "<an Atlassian API token>"}
}
name: 1 to 48 lowercase letters, digits,-and_.target: the table it writes. Left out, the kind's own table, which is made then (its columns are in the table above's defaults). A table that does not exist and is not the kind's own is refused, unlessconfig.create_targetistrue, which makes it with the columns of the connector's ownmapwhen it has one (each typed by itsas:intanINT,floataFLOAT,boolaBOOL,timeor{"now": true}aTIMESTAMP,listaKEYWORD[],jsonaJSON,hashaKEYWORD, any otherTEXT, or the type a spec says:{"path": "$.action", "type": "KEYWORD"}for a value kept whole, to group or filter by, rather than searched as words;idits primary key, or none without anid), else with the kind's columns.every_s: seconds between pulls (at least 10; 0 runs only when asked). The defaults: 60 for Prometheus, 300 for Jira, ServiceNow and HTTP pulls, 900 for Oxidized. A failed pull waits twice as long after each failure in a row, up to 32 times its interval and never more than an hour; one that stopped at its limit (20,000 records a run) runs again at once.config: the kind's settings (below) and an optionalmap.secrets: passwords and tokens, by name. They are never written to a table nor answered: the server keeps them in<db>.connectors.jsonbeside the database, readable by its user only (--connector-secrets FILE; a coordinator without one keeps them in memory, so give it one, or name each secret as"env:VARIABLE", which the server reads from its environment at each run, as a Kubernetes Secret gives it). Anenv:secret names a variable whose name starts withCHLOEDB_CONNECTOR_SECRET_(--connector-env-prefixchooses another prefix), so that no connector reads the server's own tokens, model keys or cloud credentials; another name is refused with a 400.enabled(defaulttrue) andnote.
The answer has the connector, made_target, and for a push connector its key's secret, push_secret, shown this once.
GET /v1/admin/connectors |
every connector with its health, state (cursor, last run, last ok, failures in a row, runs, rows written) and last 12 runs; the kinds and their settings; whether pulls run on this server (scheduler); the stream sources |
GET /v1/admin/connectors/NAME |
one, with its last 50 runs and the map it writes with |
POST /v1/admin/connectors/NAME |
changes the settings the body gives (secrets are merged, a null taking one out) |
DELETE /v1/admin/connectors/NAME |
its config, state, secrets and push key; the rows it wrote stay, and its runs for their 30 days |
POST /v1/admin/connectors/NAME/run |
a pull now; answers what it did |
POST /v1/admin/connectors/NAME/key |
a new push key in place of the old one, which stops working now |
POST /v1/admin/connectors/test |
a dry run: what a connector would read and the first ten rows it would write, nothing written. The body is a connector's (kind, target, config, secrets, given as values: an env: one is refused; or name alone for a saved one), with sample, the body of a push, for a pushed kind |
POST /v1/connectors/NAME/push |
a system's push: any body (JSON, or a raw email), written with the sender's key. A body with no records at the connector's records path (Alertmanager's: $.alerts), or with no message for a mail connector, is refused with 422, which says what the body has instead (its top-level keys), so that a sender set up wrong finds out; an empty list there is a push of no records, answered 200 |
Health#
| health | |
|---|---|
ok |
the last run went well (and, for a pull, within three times its interval, or 15 minutes when that is longer) |
warning |
the last run went well but found something wrong: state.last_warning (and the run's warning) says what. An http_json pull whose records path matched nothing in an answer that had a body (no key of that name, as against an empty list) reads 0 records and says so: "the records path $.items matched nothing; the top-level keys are data, next". A dry run answers it as warning too |
invalid |
its row fails the API's checks (invalid says why): it does not run |
failing |
the last run failed: state.last_error says why, state.failures how many in a row (a request that failed says why, from its causes: the connection refused, a name that does not resolve, TLS, a timeout; an error names a URL without its query, and a secret's value nowhere: it reads ***, since a read key reads these tables) |
stale |
a pull whose last good run is older than that |
pending, waiting |
a pull not run yet (one run by hand, every_s 0, too); a push connector nothing was pushed to yet |
running, disabled |
On /metrics, the server that runs the connectors has each one that is on as chloedb_connector_up (0 while it is failing, stale or invalid), chloedb_connector_failures and chloedb_connector_last_ok_timestamp_seconds, by connector and kind; a Kafka connector also has chloedb_connector_lag_events, chloedb_connector_behind_seconds (while a partition has events waiting, since the last it wrote of it happened) and chloedb_connector_partition_lag_events by topic and partition. The built-in alerts connector-failing (one failing for two minutes) and connector-behind (a Kafka connector over 5 minutes behind for 5 minutes) read them (runbook).
Configured as rows#
Each connector is a row of chloedb_connectors (id its name, kind, target, enabled, every_s, config as JSON text, push_key its key's id, note, created, updated), each run a row of chloedb_connector_runs (trigger, started, took, ok, records read, rows written, records that made no row, columns left out, error, cursor after, warning; kept 30 days), and each connector's cursor and counts a row of chloedb_connector_state (its rows_total counts every row each run wrote, an upsert of a row already there too, so it can be more than the target's rows; the Connectors page's column says "rows written"). The tables are made with the first connector, with updated_by, who changed the config last, and the runs' warning and the state's last_warning (a server adds the columns it lacks to older tables). SQL reads them, and only the server writes them: a statement or a write that changes one of them (INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, /v1/write, /v1/kv) answers 403 server_owned for every key, an admin's too, since a row would choose the URL a connector sends its credentials to and the table its run's key writes. Change a connector through the API (POST /v1/admin/connectors/NAME {"enabled": false} turns one off), which checks it and writes the change in the audit log. The schedule reads chloedb_connectors again every 10 seconds and checks each row as the API does: a row that fails (one written with the server's own token, say, or by an older server) is shown with health invalid and why, and is neither pulled nor pushed to until an admin changes or deletes it.
SELECT connector, COUNT(*) AS runs, SUM(rows_) AS rows, AVG(took_ms) AS ms FROM chloedb_connector_runs WHERE ok = false AND started > '2026-11-13' GROUP BY connector;
What a connector reaches#
A connector asks its system from inside the database's network, so by default it reaches the public internet only: an address on the server's own machine, a private network (10/8, 172.16/12, 192.168/16, 100.64/10, fc00::/7) or another reserved range is refused, checked on each URL and again on each address a name resolves to. A system inside the network is reached when the connector's config says so, "allow_internal": true (a Prometheus at http://prometheus:9090, oxidized-web on the management network). Link-local addresses, where clouds answer instance metadata (169.254.169.254, fe80::/10), are refused even then. The hosts of HTTP_PROXY and HTTPS_PROXY are reachable, as the proxy is the operator's.
A connector's credentials (its basic or bearer auth, and its headers, where {secret:NAME} is expanded) go to the origin of its url (instance for ServiceNow) only. It follows a redirect within that origin, five at most; a redirect to another origin fails the run with where it led. An http_json next page on another origin is asked without them, and a {secret:NAME} in a URL read from an answer is expanded only when the configured url names that secret and the page is on its origin.
An answer is read up to 32 MiB ("max_body_mb", 1 to 1024), and a run that gets more fails saying so.
Keys#
A connector writes with a key of its own, never with the server's:
- A pull runs inside the server and writes its rows through the server's own API, with a key the server makes for the run (named
connector-run:<name>, kept in memory only) that may write the target and nothing else; the connectors' own tables are written with another (connectors), which may touch only those. So a pull's rows are checked as any client's are, and a map cannot write another table. -
A push connector gets a key of the keys file when it is made, named
connector:<name>and limited to writing its target (a key limited to tables). The sending system holds it, and a push is written with the key it came with: one leaked lets its holder write that table, nothing else, and read nothing: the server refuses such a key (by its name,connector:) every route but the push,POST /v1/writeandGET /v1/healthand/v1/whoami, so it cannot query or list even its own table. It is listed in Access and audit, rotated withPOST /v1/admin/connectors/NAME/key, and revoked when the connector is deleted. On an open server (no token, no key) a push needs no key, and none is made. -
A follower (
postgres,mysql) writes the source's tables and its marks in_sources, and tells the server how it stands, which a key limited to tables may not: it calls the server's own routes in the process with the server's credential (below). What it may write is still checked: the tables it creates and writes are the source's, and its config names no table of ChloeDB's.
Who runs the pulls#
A server of its own, or a coordinator; with several coordinators, the one that sends the alerts' messages (the lowest URL among those that answer), so each pull runs once. A replica or a shard runs none, and --connectors off (CHLOEDB_CONNECTORS=off) turns them off on any server. A push may go to any coordinator. A pull that runs twice anyway (a coordinator taking over) writes the same rows again, as upserts.
Maps#
A record is the JSON a connector read: a Jira issue, a point of a series, an alert, an email. config.map names each column of the row and how to fill it:
| spec | value |
|---|---|
"$.fields.summary" |
a path into the record: $ the record, .name or ["name"] a key, [0] an element, [*] every element |
"{key}-{fields.status.name}" |
a template, each {path} replaced by its value as text |
| any other value | itself |
{"path" \| "template" \| "const" \| "now": true, "split": ",", "values": {...}, "as": "...", "default": ...} |
the value, then in this order: text split into a list; a value replaced by another, by its text ("*" for any other); a conversion (text, int, float, bool, time, list, first, json, lower, upper, hash, text_of); a default when it came out empty |
A column the map does not name is left out; with no map at all (and no preset), the record is the row. The row is then fitted to the target's columns: a column the table does not have is left out and named in the run (dropped), a time in any of the forms systems write (ISO 8601 with any offset, ServiceNow's 2026-11-13 03:00:00, an email's date, iCalendar's 20261113T030000Z, seconds or milliseconds since 1970) becomes ISO 8601 text for a TIMESTAMP, a number in text a number, one value a list for a KEYWORD[] or INT[], and an object or list text for a TEXT or KEYWORD. A row without the table's primary key makes no row, and the run counts it (skipped) with the first reason.
"map": {
"id": "$.number",
"title": "$.short_description",
"status": {"path": "$.state", "as": "lower", "values": {"scheduled": "approved", "implement": "running", "*": "planned"}},
"window_start": "$.start_date",
"devices": {"path": "$.cmdb_ci", "as": "list"}
}
Default tables and presets#
Each kind writes its own table with a map of its own. Some targets of the network operations app have presets, used when the connector writes that table and gives no map:
| kind | target | |
|---|---|---|
servicenow |
netops_changes, netops_tickets |
a change's number, window, state as the app's status, CI as its devices; an incident's fields as a ticket |
jira |
netops_changes, netops_tickets |
an issue as a change (custom fields named in config.fields: window_start, window_end, devices, risk, approver, rollback_plan) or a ticket |
oxidized |
netops_configs |
a version of a device's configuration |
mail |
netops_maintenance |
a carrier's notice: provider, maintenance id as the reference, its first circuit, window, impact and status, the text as raw |
A Prometheus connector writes any table whose columns are its query names and key labels: {"queries": {"cpu": "...", "mem": "..."}, "key": ["device"]} writes rows {id, ts, device, cpu, mem} (id the key labels' values and the time), so netops_device_metrics takes them as they are (rename renames a label: {"instance": "device"}).
The kinds' settings#
prometheus: url (the base URL); queries ({"column": "PromQL"}); key (the labels that name a row's subject; default every label but __name__); rename; step_s (default 60); lag_s (how far behind now to stay, default 60, so a step is complete); backfill_s (how far back the first run reads, default 3600); auth (basic with username and secret password, or bearer with secret token). A run asks for the steps after the last one it wrote, up to 10,000 steps, and keeps 20,000 records at most: when its series make more, it ends at an earlier step and the next run goes on from there; when one step's series alone are more, the run fails and says so (aggregate them with sum by or topk).
jira: url; jql; username (the account's email: Cloud signs in with it and the secret token, an API token; without username, token is sent as a bearer token, as a Data Center personal access token is); api (cloud or server; default cloud for *.atlassian.net); fields ({"name": "customfield_10050"}, read into the record's custom); backfill_days (default 30). The record: key, url, project, issuetype, summary, description (text, from Atlassian's document format too), status, priority, assignee, reporter, labels, components, created, updated, resolution, resolved, due, custom. Since a date in JQL is read in the account's time zone, a run asks for updated >= "-Nm" (minutes on Jira's own clock) with a minute or two of overlap.
servicenow: instance; table; query (an encoded query that narrows them); fields; username and the secret password (or the secret token as a bearer token); backfill_days (default 30). A record is read with sysparm_display_value=all and kept flat: each field's display value (a choice's label, a reference's name) and, where it differs, its value as <field>_value; a date-time field's value, which is UTC (its display is in the user's zone). A run asks for sys_updated_on>=javascript:gs.minutesAgoStart(N), on the instance's own clock.
oxidized: url (oxidized-web's); username and secret password if it is behind basic auth; max_nodes (per run, default 200). A pull reads /nodes.json and fetches /node/fetch/<group>/<node> for each node whose last backup is newer than the one it fetched. The record: id (<node>@<first 12 hex digits of the SHA-256>), device, ip, model, group, ts, version (the backup's time in seconds, rising per device), lines, sha256, body. Oxidized's exec hook pushes a node as soon as it is stored:
hooks:
chloedb:
type: exec
events: [post_store]
cmd: 'curl -sS -X POST https://chloedb.example.com/v1/connectors/oxidized/push -H "Authorization: Bearer $CHLOEDB_PUSH_KEY" -H "Content-Type: application/json" -d "{\"node\":\"$OX_NODE_NAME\",\"group\":\"$OX_NODE_GROUP\"}"'
mail: no settings. The body is the raw message (any content type but JSON), or JSON {"raw": "..."} (or a list of those). Postfix hands a mailbox's mail over with a pipe (notices: "|curl -sS -X POST https://.../v1/connectors/carriers/push -H 'Authorization: Bearer sk_...' --data-binary @-" in /etc/aliases), fetchmail with --mda, and providers' inbound routes post it. The record: id (the Message-ID), from, sender, sender_domain, to, subject, date, received, body (the first text part, else the HTML part's text), and from a BCOP calendar part provider, account, maint_id, circuits, start, end, impact, status, calendar; without one, provider is the sender's domain's name. A notice in another format keeps its text in body for a parser that reads it.
webhook: records (the path to the list of records in a request; default the body, or its list); preset: "alertmanager" (records $.alerts, each alert a row keyed by its fingerprint and start, its labels and annotations as searchable text). In Alertmanager:
receivers:
- name: chloedb
webhook_configs:
- url: https://chloedb.example.com/v1/connectors/alertmanager/push
http_config:
authorization:
credentials: sk_...
http_json: url ({cursor} is replaced by the cursor, URL-encoded); records; next (the path to the next page's URL, or a path on the same host); cursor (the path in a record whose highest value is the next cursor) and start (the first one); headers ({secret:NAME} is replaced by a secret); auth, username.
Kafka topics#
A kafka connector reads topics into a table while it is on, and writes each event once. Its section on Data > Connectors lists the Kafka connectors with their consumers live: state, events a second, lag (each partition's end less the next offset to write, since there is no consumer group for Kafka's own lag tools to see), events and rows since the server started, replays skipped, events that made no row, and a table of partitions; Start and Stop turn one on and off (kept in its row, so it stays so across restarts), and Add a Kafka connector has a form with a dry run that connects and shows the rows a few events would make.
curl -X POST localhost:7700/v1/admin/connectors -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{
"name": "orders", "kind": "kafka", "target": "orders",
"config": {
"brokers": "kafka-1:9092,kafka-2:9092", "topics": "orders", "allow_internal": true, "create_target": true,
"map": {"id": "$.value.order_id", "customer": {"path": "$.key", "type": "KEYWORD"}, "total": {"path": "$.value.total", "as": "float"}, "at": {"path": "$.ts", "as": "time"}}
}
}'
curl -X POST localhost:7700/v1/admin/connectors/orders/stop -H "Authorization: Bearer $KEY"
curl -X POST localhost:7700/v1/admin/connectors/orders/start -H "Authorization: Bearer $KEY"
- Each event once. Each partition is a stream source named
<prefix><topic>/<partition>(prefixkafka/<name>/unlessprefixsays another), whose last offset the server keeps in_sourcesin the same transaction as the rows its events made. A consumer starts each partition after the offset ChloeDB has, not after one committed to Kafka, so a stop, a restart of the server or of a broker, or a coordinator taking over writes no event twice and misses none (a second write of an offset is a replay, and skipped). A partition ChloeDB has no offset of starts at its first event ("start": "earliest", the default) or its end ("latest"). Another prefix reads the topics again from the start; two connectors with the same prefix share their offsets. - Who reads. The server that runs the pulls (above) keeps one consumer per connector: a task per partition fetching, and one writer writing the rows in batches through the stream path, as
POST /v1/streamdoes. It commits nothing to Kafka and joins no consumer group. New partitions of its topics are found within 30 seconds and read from their first event. - Rows. An event's value is JSON (
"format": "json", the default), text ("text"), or a Debezium change event ("debezium", below). The map reads the event as{topic, partition, offset, ts, key, value, headers}:$.value.xa field of the value,$.key,$.offset,$.ts(milliseconds since 1970;"as": "time"makes it a time). Without a map, a JSON object's fields are the row; the default table,kafka_events, keeps each event as a row (id<topic>/<partition>/<offset>,topic,partition_,offset_,ts,msg_key,valueas JSON,textthe value's text, searched,headers). A keyed table whose row has no key gets<topic>/<partition>/<offset>; a keyed table's rows are upserted, another's inserted. An event no row comes of (a value that is not JSON, a map that fails) still moves its partition's offset, and is counted with the first reason. A tombstone (an event without a value) writes nothing, or, with"tombstones": "delete", deletes the row of its key. - When it fails. A broker that cannot be reached, a sign-in refused or a write that fails ends the consumer's session, and the next one starts after a wait that doubles up to a minute, from ChloeDB's offsets again; the connector's health is
failinguntil it streams. Events that the topic's retention deleted before they were read are counted (lost) and said in a warning, and the partition goes on from its first event kept. A partition whose offsets went back (a topic emptied or made again) stops the consumer with an error that says so, since its new offsets would be taken for events written already: give the connector another prefix to read it.
The settings, in config: brokers (bootstrap brokers, host:port, joined by commas or a list); topics (joined by commas or a list); start; format; map; prefix; tombstones (skip or delete); tls (true to connect with TLS, checked against the public roots, or against ca_pem, a PEM certificate); sasl ({"mechanism": "PLAIN" | "SCRAM-SHA-256" | "SCRAM-SHA-512", "username": "..."}, the password the secret password); allow_internal (the bootstrap brokers are checked as a pull's URL is: a private address, or this machine, only with true); batch (events written at a time, 1 to 4,096, default 1,000); max_wait_ms (how long a fetch waits for new events, 10 to 10,000, default 500); fetch_kb (1 to 65,536, default 1,024). The API answers a Kafka connector with "streams": true and its consumer as stream; POST /v1/admin/connectors/NAME/run is refused for one (it streams while it is on), and its runs table gets a row per session (trigger stream, every 10 minutes while it lasts).
Debezium change events#
With "format": "debezium", each event is a change Debezium (or Redpanda Connect, or Flink CDC in Debezium's format) read from a database's log, with its schema in the envelope or not ({"schema": ..., "payload": {...}}, or the payload alone). A create, an update or a snapshot's read (op c, u, r) upserts the row after the change; a delete (d) deletes the row named by the key of the row before it (the target's primary key read from before, or from the event's key); a truncate (t) is counted as an event that made no row, and a tombstone (the null Kafka writes after a delete) is skipped. The map reads $.value as the row after the change, with the envelope beside it: $.op, $.before, $.source ($.source.table, $.source.lsn...) and $.ts, the change's time in the source (source.ts_ms). Without a map, the row's columns are the target's.
curl -X POST localhost:7700/v1/admin/connectors -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{
"name": "shop-items", "kind": "kafka", "target": "items",
"config": {"brokers": "kafka-1:9092", "topics": "shop.public.items", "format": "debezium", "allow_internal": true,
"map": {"id": "$.value.id", "title": "$.value.title", "changed": {"path": "$.ts", "as": "time"}}}
}'
Since a partition's offset is kept with its rows, a change is applied once, in the order its partition has it (Debezium writes a row's changes to one partition, by its key). To follow Postgres without Kafka, the server reads its log itself (follow-postgres).
The test broker#
To try a connector without Kafka, the server has a test broker: a broker in its own process that speaks as much of Kafka's protocol as a consumer needs (and producing, so any Kafka client can write to it), keeps topics in memory (the last 200,000 events of each partition), and writes made-up click events ({event_id, user, item, action, page, at, price}, keyed by user) into a topic at a rate. On Data > Connectors the Test Kafka broker card starts and stops it, sets the rate, sends an event typed in, and Connect a connector to it fills the form with its address, its topic and a map into demo_clicks. By the API:
curl -X POST localhost:7700/v1/admin/kafka/test-broker -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
-d '{"listen": "127.0.0.1:19092", "topic": "demo.clicks", "partitions": 3, "rate": 5}' # or {"rate": 50} while it runs
curl -X POST localhost:7700/v1/admin/kafka/test-broker/produce -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
-d '{"topic": "orders", "messages": [{"key": "c42", "value": {"order_id": "o1", "total": 19.5}}]}'
curl localhost:7700/v1/admin/kafka/test-broker -H "Authorization: Bearer $KEY" # its topics, offsets and counts
curl -X DELETE localhost:7700/v1/admin/kafka/test-broker -H "Authorization: Bearer $KEY"
The API starts it on a loopback address only, and it stops with the server; username and password make it ask clients to sign in with SASL PLAIN. For one other machines reach, run it on its own: chloedb-server kafka-test-broker --listen 0.0.0.0:19092 --advertise test-kafka.internal --topic demo.clicks --rate 20 (--advertise is the host its clients are told to connect to after the first; --username with CHLOEDB_KAFKA_TEST_PASSWORD for a sign-in). Kafka's own tools that need no consumer group read and write it too: rpk topic consume demo.clicks -X brokers=127.0.0.1:19092. It is for trying and testing, not a Kafka: one broker, no replication, nothing kept on disk.
Databases followed by their logs#
A postgres or mysql connector runs the follower of follow-postgres or follow-mysql inside the server, while the connector is on: it copies the database's tables, then applies each change a moment after the database commits it, and keeps what it applied in _sources with the rows, so a stop, a restart of the server or a coordinator taking over goes on from there. Its tables are named after the database's (a table of another MySQL database is <database>_<table>), so it has no target; they take no other writes while it follows them (409, followed_table).
curl -X POST localhost:7700/v1/admin/connectors -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{
"name": "shop", "kind": "mysql",
"config": {"url": "mysql://chloedb@db.internal:3306/shop?ssl-mode=verify_identity", "tables": "orders,customers", "allow_internal": true},
"secrets": {"password": "env:CHLOEDB_CONNECTOR_SECRET_SHOP_DB"}
}'
curl -X POST localhost:7700/v1/admin/connectors/shop/test -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{...the same body...}' # a dry run: the tables it would follow
- Settings.
url(postgres://user@host:5432/dbormysql://user@host:3306/db, withsslmodeorssl-modeas the commands take them, and no password: a URL with one is refused, since the config is a row a read key reads; the password is the secretpassword);ca_pem(a CA certificate, PEM, to check the database's by; a path to a file of the server's,sslrootcert, is refused);allow_internal(the database's host is checked as a pull's URL is);batch(rows of one write, default 1,000). Postgres:publication(defaultstrata),slot(defaultstrata_<name>),copy_workers(default 4). MySQL:tables(orders,shop.orders,shop.*, joined by commas; default every table of the URL's database),server_id(default a number made from the name). Set the database up as each page says (Postgres, MySQL). - Who follows. The server that runs the pulls (above) runs one follower per connector, with its own routes (no HTTP between them) and a credential of the server's: its token, or, on a server with keys and no token, an admin key it makes in memory for the follower (
connector-follower:<name>, listed in Access, ended when the follower stops). A follower that fails starts again after a wait that doubles up to a minute; the connector's health isfailingmeanwhile, with the error. - Health.
streamingonce it follows,copyingwhile it copies,connecting,failing,stale(it has not told how it stands for a minute),pending,disabled. The follower is listed underfollowerstoo, with its lag, tables and positions, as a follower run by itself is (Postgres, MySQL), andfollow-behindalerts on it. - Stop, start, delete.
POST .../stopstops reading: a Postgres slot keeps the WAL meanwhile, which can fill the database's disk over days, and MySQL may purge the binlog files, after which the next start copies again..../startgoes on from what ChloeDB applied. Deleting the connector stops it, releases its tables, which take other writes again, and drops a Postgres connector's slot, so that Postgres keeps no WAL for it (the answer'sreleasedsays what it did). When the database cannot be reached then, the answer says so and the tables stay followed: end it withfollow-postgres --drop-slotorfollow-mysql --releaseand the connector's name. To pause without losing the slot's place, stop it instead.POST .../runis refused: it follows while it is on.
MCP servers#
An mcp connector makes ChloeDB a client of an MCP server: each run opens a session over the Streamable HTTP transport (initialize, then notifications/initialized, with the Mcp-Session-Id the server gives on every later message), calls a tool with the connector's arguments, or reads a resource, and ends the session. So any system that has an MCP server (a SaaS product's, a company's own, another ChloeDB's /v1/mcp) can fill a table without a connector of its own.
curl -X POST localhost:7700/v1/admin/connectors -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{
"name": "shop-orders", "kind": "mcp", "target": "orders", "every_s": 300,
"config": {"url": "https://mcp.shop.example.com/mcp", "tool": "list_orders",
"arguments": {"updated_since": "{cursor}", "limit": 100}, "start": "2026-01-01T00:00:00Z",
"records": "$.orders", "cursor": "$.updated_at", "next": "$.next_page", "next_argument": "page_token", "create_target": true,
"map": {"id": "$.id", "customer": {"path": "$.customer", "type": "KEYWORD"}, "total": {"path": "$.total", "as": "float"}, "updated_at": {"path": "$.updated_at", "as": "time"}}},
"secrets": {"token": "env:CHLOEDB_CONNECTOR_SECRET_SHOP_MCP"}
}'
- The result. A tool's result is its
structuredContentwhen it has one; else its text content read as JSON (one text that is JSON is that value, several are a list of them), and texts that are not JSON are records{"text": ...}. A resource's contents are read the same way.recordsis a path into it (default: the result, or its list). A result withisErrorfails the run with the tool's own words. - Incremental reads.
cursoris a path in a record whose highest value is kept; an argument written"{cursor}"is given that value, a number staying a number (and its text inside a longer string);startis the first one (read as JSON when it is:"0"is the number 0). - Pages.
nextis a path into the result to the next page's token, given as the argumentnext_argument(defaultcursor) of the next call, until there is none. A run that reaches itsbatchstops after that page, and the next run goes on from the next page with the same cursor; the pass that reads the last page keeps the highest value it read. - Answers may be JSON or a stream of server-sent events, of which the event that answers the request is read (progress notices before it are passed over).
- Signing in. The secret
tokenis sent as a bearer token;headersadds others,{secret:NAME}a secret. A server's OAuth sign-in in a browser is not done by the connector: give it a token the server issues.
The settings: url (the Streamable HTTP endpoint); tool and arguments (an object), or resource (a URI); records; cursor; start; next; next_argument; headers; batch; map; allow_internal; max_body_mb. A dry run (POST /v1/admin/connectors/test) calls the tool (up to 200 records) and shows the rows it would write, writing none.
Files and warehouses#
s3 watches a prefix of an object store. Each run lists it, and reads the files modified since the last one it read, oldest first (then by name), up to batch rows (20,000 at most): a file larger than that is read over several runs, each from the row the last stopped at, and a file written over (a newer modification time) is read again. Its rows are upserted by the table's key, or inserted into a table without one. The requests are signed with SigV4 by the connector itself, with the secrets access_key_id, secret_access_key and session_token (temporary keys), never the server's own AWS_*; with neither secret, a bucket is read unsigned, as a public one is. For Cloud Storage, make HMAC keys (Cloud Storage > Settings > Interoperability) for a service account that reads the bucket.
curl -X POST localhost:7700/v1/admin/connectors -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{
"name": "events", "kind": "s3", "target": "events", "every_s": 300,
"config": {"url": "s3://my-lake/events/2026/", "region": "eu-west-1", "key": "event_id", "create_target": true},
"secrets": {"access_key_id": "env:CHLOEDB_CONNECTOR_SECRET_LAKE_ID", "secret_access_key": "env:CHLOEDB_CONNECTOR_SECRET_LAKE_KEY"}
}'
The settings: url (s3://bucket/prefix/ or gs://bucket/prefix/); format (parquet, the default, or jsonl); suffix (the files read, by how their names end: .parquet or .jsonl by default, "" for every object); region (default us-east-1, auto for gs://); endpoint (another store: https://<account>.r2.cloudflarestorage.com, https://<region>.digitaloceanspaces.com, MinIO's address; a plain http:// one needs allow_internal); path_style (the bucket in the path, not the host: the default for an endpoint, and on AWS for a bucket whose name has a dot); key; batch; max_body_mb (the largest file read, default 32 MiB, at most 1,024: a file is read whole). A Parquet file's rows are read with their columns' types (a time as a time, a list of text as a KEYWORD[], a fixed-size list of floats as a vector); each record also has _file, its file's name, for a map's $._file. A prefix of more than 200,000 objects is refused: name a narrower one.
snowflake and bigquery read a table ("table") or a query ("query", one SELECT or WITH). With a cursor column (updated_at), each run asks for the rows past the last value it read, in its order: SELECT * FROM <table> WHERE <cursor> > ? ORDER BY <cursor> LIMIT <batch + 1>, the value bound as a parameter, never written into the statement. A batch never ends inside a value: when the row past it shares the last rows' value, those rows are left to the next run, which reads them whole (a value shared by more rows than a batch is a run that fails and says so: choose a finer column). Rows with no value in the cursor column are not read. With no cursor but a key, the key orders the reads, and the table is read again from its start once a pass ends; with neither, the whole source each run (20,000 rows at most). A row read again is upserted by the key. Deletes in the warehouse are not seen: follow a log for those (Postgres, MySQL or Debezium), or read the whole table by key.
curl -X POST localhost:7700/v1/admin/connectors -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{
"name": "orders", "kind": "snowflake", "target": "orders", "every_s": 600,
"config": {"account": "myorg-myaccount", "user": "CHLOEDB_READER", "table": "SHOP.PUBLIC.ORDERS", "cursor": "updated_at", "key": "id", "warehouse": "XS_WH", "create_target": true},
"secrets": {"private_key": "env:CHLOEDB_CONNECTOR_SECRET_SNOWFLAKE_KEY"}
}'
curl -X POST localhost:7700/v1/admin/connectors -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{
"name": "signups", "kind": "bigquery", "target": "signups", "every_s": 600,
"config": {"project": "my-project", "table": "analytics.signups", "cursor": "created_at", "key": "user_id", "location": "US", "create_target": true},
"secrets": {"service_account": "env:CHLOEDB_CONNECTOR_SECRET_BQ_KEY"}
}'
Snowflake's settings: account (myorg-myaccount, or a locator such as xy12345.us-east-1); user; table (DATABASE.SCHEMA.TABLE) or query; cursor; key; warehouse; role; batch; token_type (pat, the default, or oauth, for the secret token); base_url (for a private link: default https://<account>.snowflakecomputing.com). It signs in with a key pair, the secret private_key (the user's RSA key in PKCS #8 PEM, BEGIN PRIVATE KEY, unencrypted, whose public key is the user's RSA_PUBLIC_KEY: ALTER USER CHLOEDB_READER SET RSA_PUBLIC_KEY='MIIB...'), or a programmatic access token (or OAuth's) as the secret token. A statement still running is waited for (5 minutes at most), and an answer in several partitions read whole. Its columns' names are read in lower case ($.updated_at), times as UTC, VARIANT, OBJECT and ARRAY as JSON.
BigQuery's settings: project (where the queries run and are billed); table (dataset.table or project.dataset.table) or query (GoogleSQL); cursor; key; location; batch; base_url. It signs in with a service account's key, the secret service_account (its JSON; its signed request for a token goes to https://oauth2.googleapis.com/token only, whatever the key names), or an access token as the secret token. Give the service account BigQuery Data Viewer on the dataset and BigQuery Job User on the project. Times are read to the microsecond, a RECORD as JSON, a REPEATED column as a list.
A target that does not exist is made, with "create_target": true (or as the kind's default table), from the source's columns: the first file's for s3, the table's or the query's (LIMIT 0) for a warehouse, key its primary key. A column of a type it does not keep (binary) or whose name is not one of letters, digits and _ is left out, and the answer says which (made_target.columns_left_out). With a map, the map's columns make it instead, as for any kind.
Apps#
Four kinds read an app's API (and Google Drive does too, below) with the app's own way of finding what changed, so each run after the first reads only that. Each signs in with a secret of its own, keeps its cursor as JSON in state.cursor, and goes on from the page it stopped at when a run reaches its batch. Each has a default table and map (GET /v1/admin/connectors lists them), the record whole in a JSON column (data, or properties) and its words in text, for MATCH; give a map for other columns.
curl -X POST localhost:7700/v1/admin/connectors -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{
"name": "customers", "kind": "stripe", "every_s": 300, "config": {"object": "customers"},
"secrets": {"api_key": "env:CHLOEDB_CONNECTOR_SECRET_STRIPE"}
}'
- stripe lists
object(/v1/customers, 100 a page) the first time, then reads the events of that object created since the list began (customer.*for customers,customer.subscription.*for subscriptions;eventsnames others), oldest first, each event's object a row, withdeletedtrue for a*.deletedevent and the event as_event. A batch ends between two seconds of events, so none is read twice or left out. Secret:api_key, a restricted key that can read the list and events (Stripe keeps events 30 days: a connector off longer than that lists again when its cursor is cleared). Settings:object,events,api_version(default2024-06-20). - shopify reads
resource(defaultorders;products,customers, ...) ordered byupdated_at, from the highest value read before, 250 a page, following theLinkheader's next page on the store's own address only; orders of everystatusunless it says one. Secret:access_token, an Admin API token (a custom app's,shpat_...) with the resource's read scope. Settings:shop(my-store.myshopify.com),resource,status,api_version(default2025-07). - odoo signs in through
/jsonrpc(common.authenticate) and readsmodelwithsearch_read, ordered bywrite_dateandid, each run from the last pair read (so records written in the same second are not lost), narrowed bydomainwhen it gives one. The fields read arefields, or every field but binaries (pictures, attachments); a many-to-one field is{"id", "name"}(JSON), a many-to-many one a list of ids, a date a time, and Odoo'sfalsefor an empty field no value. Its table is made from the model's fields (fields_get), with"create_target": trueor as the default,idits key. Secret:api_key(Preferences > Account Security > New API Key) orpassword. Settings:url,db,username,model,fields,domain,key. Records deleted in Odoo are not seen. - hubspot searches
object(/crm/v3/objects/<object>/search) for records whose last change (lastmodifieddatefor contacts,hs_lastmodifieddatefor the others) is at or after the highest read before, oldest first, 100 a page; a search that reaches HubSpot's 10,000 results begins again at once from the highest value read. A record's properties are its columns, withid,createdAt,updatedAtandarchived. Secret:token, a private app's access token with the object's read scope, or a sign-in'srefresh_token,client_idandclient_secret, traded at each run for an access token at<base_url>/oauth/v1/token. Settings:object,properties(default: HubSpot's default properties of the object).
Each also takes batch, map, base_url (another address: a test's, a proxy's), allow_internal and max_body_mb. A dry run (POST /v1/admin/connectors/test) reads the first page and shows the rows it would write.
Google Drive and Sheets#
Paste a link, and sign in with Google when the file is not shared with anyone who has the link: the Connectors page's Google Drive box makes the connectors a link needs, runs each once, and links their tables. Each keeps in step with Drive from then on, every 15 minutes.
- A spreadsheet (a Google Sheet, or an Excel
.xlsxor CSV file in Drive): each tab is a table of its own, named after the file and the tab (budget_2026_q1). The header row gives the columns, in lower case with_for spaces and signs (Amount ($)isamount), and each column's type is guessed from its values:INT,FLOAT,BOOL,TIMESTAMP(a Sheet's date cells, an Excel date, text that reads as a time) orTEXT. Each row is keyed by its row number in the sheet,sheet_row. When the file changes, the tab is read again whole: changed rows are updated, and rows no longer in it are deleted. A link to one tab (#gid=) imports that tab only. - A folder: its files and its subfolders' files, into one table (
team_docs_files), with their text, to search withMATCH(text, '...'). Docs and Slides are read as text, Sheets as CSV, Word (.docx), PowerPoint (.pptx) and Excel files read by the server, and text, JSON and XML files as they are, up to 2 MiB of text a file. PDFs and pictures come with their details only (name, type, owners, link, size, times). The folder's spreadsheets (the ten changed last) are each made tables too, as above. - A Doc, Slides or another file: a row of
drive_files.
# Signed in (the page does this): start, open the url, then ask for the grant.
curl -X POST localhost:7700/v1/admin/google/start -H "Authorization: Bearer $KEY" -d '{}'
# {"state": "…", "url": "https://accounts.google.com/o/oauth2/v2/auth?…", "redirect_uri": "…/v1/google/callback"}
curl "localhost:7700/v1/admin/google/grant?state=…" -H "Authorization: Bearer $KEY"
# {"state": "done", "grant": "…", "account": "ana@example.com"}
curl -X POST localhost:7700/v1/admin/google/import -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
-d '{"link": "https://docs.google.com/spreadsheets/d/1AbC…/edit", "grant": "…"}'
# {"connectors": [{"name": "budget-2026-q1", "kind": "google_sheets", "target": "budget_2026_q1", "ok": true, "rows": 212}, …], "account": "ana@example.com"}
Picking folders. After signing in, the box's Pick folders opens Drive in a drawer: My Drive, Shared with me and the shared drives, then each folder's subfolders, with how many files are in it and whether a connector already watches it. Tick folders and Watch the folders ticked makes a connector for each; unticking a watched one pauses its connector, and ticking it again starts it. A folder inside a watched one is watched already (its files are in that table). Once a folder connector exists the picker browses with its sign-in, so a later visit needs no new one. The page asks the server:
curl -X POST localhost:7700/v1/admin/google/browse -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' \
-d '{"folder": "root", "grant": "…"}' # or "connector": "team-docs-files" instead of the grant
# {"folder": "root", "folders": [{"id": "1AbC…", "name": "Team Docs", "modified": "…", "owner": "Ana", "watched_by": {"connector": "team-docs-files", "enabled": true}}, …],
# "here": {"files": 12, "more": false}, "account": "ana@example.com", "watched_here": null}
With no folder it answers the top level (root is My Drive, shared is Shared with me, and each shared drive by its id). POST /v1/admin/google/import takes connector in place of grant the same way, and copies that connector's sign-in to the new one.
Searching them. The command center's Documents page (Build) searches a Drive table's files as Drive does: the words against the text and the name, ranked by BM25 with the name counted twice and typos forgiven, the types and how recent as filters with their counts, each result's best passage marked, and a document read in a drawer with every match marked. It finds every table with the columns name, mime, url and a TEXT column text, and shows the SQL it ran:
SELECT id, name, mime, modified, owners, url, size FROM team_docs_files WHERE (MATCH(text, :q, syntax => 'plain', fuzzy => 'auto') OR MATCH(name, :q, syntax => 'plain', fuzzy => 'auto')) AND modified >= now() - INTERVAL '1 month' ORDER BY bm25(text, :q, fuzzy => 'auto') + 2 * bm25(name, :q, fuzzy => 'auto') DESC LIMIT 30
The passages come from POST /v1/highlight with keys (the rows' ids) in place of texts, so the server reads each document's text from its row and the page never fetches a long document whole.
Signing in. The sign-in asks Google for read-only access to Drive (drive.readonly) and the account's address, with the authorization code flow and PKCE: Google sends the browser back to <this server>/v1/google/callback with a code, which the server trades for a refresh token at once. The refresh token is kept as each connector's secret refresh_token (in the secrets file, never in a table or an answer), and each run trades it for an access token of an hour. A grant waits 30 minutes for the connectors made with it ("secrets": {"google_grant": "…"} in POST /v1/admin/connectors uses one too), and a sign-in has 10 minutes from its start. A run whose sign-in Google no longer honors (taken off at myaccount.google.com/permissions, a password changed, six months unused) fails and says to sign in again.
Without signing in. A Doc, Slides or Sheet shared "Anyone with the link" is read from Google's export addresses, with no credentials (a Sheet's tab as CSV, its types guessed from the text; it says nothing of when it changed, so the tab is read each run, and written only when it did). A folder needs a sign-in, a service account (the secret service_account; share the folder with its address) or, for one shared with anyone, an API key (the secret api_key).
Setting it up on a server. Signing in needs the server's Google OAuth client, the same one the command center's Google sign-in uses (or a new one of type Web application), once:
- In the Google Cloud console, in the client's project: APIs & Services, Library, turn on the Google Drive API and the Google Sheets API.
- Google Auth Platform, Data access: add the scope
.../auth/drive.readonly. It is a restricted scope: an app in testing works for its test users (up to 100), and an internal app of a Google Workspace organization for its people; an external app for anyone needs Google's verification. - Google Auth Platform, Clients, the client: under Authorized redirect URIs add
https://<this server>/v1/google/callback(andhttp://localhost:7700/v1/google/callbackto try it on a laptop), and make a client secret. - Start the server with
--google-client-idand--google-client-secret, orCHLOEDB_GOOGLE_CLIENT_IDandCHLOEDB_GOOGLE_CLIENT_SECRETin its environment (on Kubernetes, from a Secret:env: [{name: CHLOEDB_GOOGLE_CLIENT_SECRET, valueFrom: {secretKeyRef: {name: chloedb-google, key: client-secret}}}]). The redirect address is--public-url's when it is set, else the address the page was opened at. Without--google-allow, the client is used for Drive only, and nobody signs in to the command center with it.
The kinds' settings. google_sheets: url (the spreadsheet's link or id; an Excel or CSV file's in Drive too); sheet (the tab's title; default the link's #gid= tab, else the first); gid; header_row (default 1); key (a column to key rows by instead of sheet_row; rows gone from the tab are then not deleted). google_drive: folder (a folder's link or id); recursive (default true: its subfolders, to 500 folders); drive (a shared drive's id); files (a list of files' links or ids, read each run they changed); query (a Drive search that narrows them: mimeType = 'application/pdf'); text (false: details only). Both take batch, map, base_url, allow_internal and max_body_mb, and the secrets refresh_token (a sign-in's), service_account, token or api_key.
Limits#
- One run reads 20,000 records at most (a push too: one of more answers 413, and a push's body is 32 MiB at most, or
--max-body-mbwhen that is smaller), and writes them 500 rows (or about 4 MB) at a time; a run that stopped at the limit runs again at once. Anhttp_jsonpull whose cursor does not move its URL on (nocursorpath, or no{cursor}in the URL) keeps the next page's URL in its cursor instead ({"next": URL, "cursor": ...}, a secret in it kept as its{secret:NAME}), so the next run goes on from that page, and the run that reads the last page clears it. A run that fails partway keeps the rows it wrote and its cursor, so the next one reads them again, as upserts. - A pull runs for 10 minutes at most; each request to the system waits 60 seconds.
- Pulls are not yet spread over coordinators or shards, and a connector's runs are one at a time.
- A Kafka connector's writer writes up to
batchevents (default 1,000) at a time, and each partition's fetch asks for up tofetch_kb(default 1 MiB); one server reads every partition of its Kafka connectors (no consumer group spreads them over servers). - An
s3run reads each of its files whole (max_body_mb, 32 MiB by default), and a warehouse's run waits 5 minutes at most for its statement. - Not yet connectors: IMAP mailboxes (hand the mail over instead). Of the apps, only
stripesees deletes.