Metabase Queries Run

Metabase Queries Run

Certified

Run a native Metabase query

Executes a native SQL query against a database connected to Metabase.

FETCH, FETCH_ONE and NONE call POST /api/dataset, which Metabase caps at 2,000 rows. STORE calls the export endpoint POST /api/dataset/json and streams every row to internal storage. The exported row keys are the ones Metabase writes in its JSON export, which can differ from the column names returned by the other fetch types.

yaml
type: io.kestra.plugin.metabase.queries.Run

Execute a native query and stream rows to Kestra storage

yaml
id: metabase_native_query
namespace: company.team

tasks:
  - id: run
    type: io.kestra.plugin.metabase.queries.Run
    url: "{{ secret('METABASE_URL') }}"
    apiKey: "{{ secret('METABASE_API_KEY') }}"
    databaseId: 2
    nativeQuery: "SELECT id, name, created_at FROM orders WHERE status = 'COMPLETED'"
    fetchType: STORE

Fetch single row from a native query

yaml
id: metabase_native_fetch_one
namespace: company.team

tasks:
  - id: get_count
    type: io.kestra.plugin.metabase.queries.Run
    url: "{{ secret('METABASE_URL') }}"
    apiKey: "{{ secret('METABASE_API_KEY') }}"
    databaseId: 2
    nativeQuery: "SELECT COUNT(*) as total FROM users"
    fetchType: FETCH_ONE
Installation

Our standard Docker images already include this plugin. If you use a -slim image or another setup, install it with the following command:

kestractl plugins get io.kestra.plugin:plugin-metabase --compatible-for $KESTRA_VERSION

For kestractl, use your Kestra version with --compatible-for, or specify an exact plugin version.

Properties

Database ID

The ID of the Metabase database to run the query on.

Native SQL query

The native SQL query to run.

Metabase server URL

Base URL of the Metabase instance, for example https://metabase.example.com or http://localhost: 3000.

Metabase API key

API key sent in the x-api-key header. Requires Metabase v0.47 or later. Set exactly one authentication mode: apiKey, sessionToken, or both username and password.

Assets this task consumes as inputs or produces as outputs, for lineage tracking and the asset graph (Enterprise Edition). A flow declaring this property on a task is rejected in the open-source edition.

Definitions
assetFailureBehaviorstring
Possible Values
IGNOREFAILWARN

Asset failure behavior

Behavior applied to the task state when a declared asset fails to render, emit, or be persisted (e.g. a lock conflict): FAIL escalates it to FAILED, WARN (default) warns it if it would otherwise succeed, IGNORE leaves the state untouched.

enableAutobooleanstring

Whether to auto-register assets referenced dynamically at runtime that are not statically declared in inputs or outputs.

inputsarray

The assets consumed as inputs.

id*string
Min length1
typestring
outputs

The assets produced as outputs.

id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*string
Min length1

Custom asset type

descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
DefaultFETCH
Possible Values
STOREFETCHFETCH_ONENONE

Fetch type

How results are handled: FETCH_ONE (first row), FETCH (all rows inline), STORE (stream into internal storage as an Ion file) or NONE (only the row count). FETCH_ONE, FETCH and NONE are limited to the 2,000 rows Metabase returns from /api/dataset. Use STORE for larger results.

Metabase password

Password used to open a session through POST /api/session. Must be set together with username.

DefaultPT1M

HTTP request timeout

Connect and read timeout for each HTTP request made to Metabase. Defaults to 60 seconds. Does not limit the task duration.

Metabase session token

Session token sent in the X-Metabase-Session header. Set exactly one authentication mode: apiKey, sessionToken, or both username and password.

Template tags

Optional Metabase template tags (variable bindings) for the native query.

Metabase username

Username or email used to open a session through POST /api/session. Must be set together with password. The session is closed with DELETE /api/session when the task ends.

A single row

Returned when fetchType is set to FETCH_ONE.

SubTypeobject

List of rows

Returned when fetchType is set to FETCH.

Number of returned rows

Total number of rows returned or stored by the query.

Formaturi

Internal storage URI

Returned when fetchType is set to STORE. Contains an Amazon Ion-serialized file of the rows.