Public query embeds
Embed interactive, token-scoped queries in documentation and external sites.
Public query embeds
The /micro-query/{accountId} page displays a query editor and results without requiring a Logship login. Embed it in an iframe to let readers explore public demo data, or display a chart or table with the editor hidden.
Create a demo token
Create a personal access token under Account settings → Tokens, or call POST /auth/pat-token using an authenticated session:
{
"accounts": [
{
"accountId": "11111111-1111-1111-1111-111111111111",
"query": {
"default": { "queryTimeoutSeconds": 10 },
"schemas": [{ "schema": "demo.requests" }]
}
}
],
"expiration": "2027-01-01T00:00:00Z"
}Use an appropriate future expiration, grant query access only to the demo tables, and omit inflow permissions. Tokens remain subject to the issuing user's permissions. Replace the account ID, frontend URL, and token in the examples below with your deployment's values.
The token is public: anyone viewing the page can copy it and query all data in every permitted table, including through the API. An initial query, hidden editor, or iframe does not restrict access further. Publish only data intended for public access, use explicit table scopes, and set a query timeout and expiration. To rotate a token, publish a replacement; previously published tokens retain their existing validity until expiration or the underlying issuer permissions change.
Documentation block
Run existing documentation examples
The documentation site adds a Run example button to existing kusto and kql code blocks. It opens the example in an embedded editor; readers choose Execute to run it. Only one editor loads at a time, after a reader opens an example.
Configure the docs site's static/config/query-demo.json (served as /config/query-demo.json):
{
"frontendUrl": "https://try.logship.io",
"accountId": "00000000-0000-0000-0000-000000000000",
"token": "PUBLIC_SCOPED_TOKEN"
}Replace token with a public, query-only scoped token for that account. A blank token leaves the examples as static code blocks. The file is loaded at runtime: mount or replace it in the deployed docs site to rotate the token without rebuilding, then reload the page. For the docs container, mount it at /usr/share/nginx/html/config/query-demo.json. If changing the frontend origin, also update the docs server's CSP frame-src allowlist.
Examples use the query exactly as documented, including references to tables. Examples that depend on named tables require matching public demo data; readers can edit those queries in the embedded editor.
Add a standalone embed
Use :::query-demo in documentation Markdown. Attributes must be double-quoted. The block body is raw Kusto, without a code fence:
:::query-demo src="https://demo.example.com/micro-query/11111111-1111-1111-1111-111111111111#token=PUBLIC_SCOPED_TOKEN" title="Explore demo requests"
demo.requests
| summarize count() by bin(timestamp, 1h)
| render timechart
:::The generated iframe is lazy-loaded, fills its container's width, and defaults to 600 pixels high. Readers click Execute to run the query. Supply height="450" to change its height.
For an automatically executed results-only chart:
:::query-demo src="https://demo.example.com/micro-query/11111111-1111-1111-1111-111111111111?mode=results&autorun=1&theme=dark#token=PUBLIC_SCOPED_TOKEN" title="Demo request volume" height="450"
demo.requests
| summarize count() by bin(timestamp, 1h)
| render timechart
:::External sites
Create the iframe URL using UTF-8 base64 for the initial query. Place the scoped token in the URL fragment, which is not sent with the page request:
const url = new URL(
'https://demo.example.com/micro-query/11111111-1111-1111-1111-111111111111'
);
const bytes = new TextEncoder().encode('demo.requests | take 20');
url.searchParams.set('embed', '1');
url.searchParams.set('query', btoa(Array.from(bytes, byte => String.fromCharCode(byte)).join('')));
url.hash = new URLSearchParams({ token: 'PUBLIC_SCOPED_TOKEN' }).toString();
const iframe = document.createElement('iframe');
iframe.src = url.toString();
iframe.title = 'Explore demo requests';
iframe.width = '100%';
iframe.height = '600';
iframe.loading = 'lazy';
iframe.referrerPolicy = 'no-referrer';
document.querySelector('#demo-query').append(iframe);| Parameter | Default | Meaning |
|---|---|---|
embed | Required: 1 | Uses the supplied scoped token independently of login cookies. |
query | Required | Base64-encoded UTF-8 Kusto query. The docs block generates it. |
mode | editor | editor shows the editor and results; results hides the editor. Both retain Execute/Cancel controls. |
autorun | 0 | 1 executes on load; 0 waits for a click. |
theme | auto | auto, light, or dark. Auto follows the system preference without changing application settings. |
#token | Required | Scoped bearer token, supplied through the fragment instead of the query string. |
An expired or invalid token displays an error within the embed. Embeds never fall back to a visitor's logged-in session. Configure reverse proxies to allow framing of /micro-query/; other application pages retain their framing protections. The embedding site's Content Security Policy must allow the demo frontend in frame-src.