Blueprints

Run Elastic ESQL query and read the data as a Pandas DataFrame

Source

yaml
id: elastic-esql-query-to-python-pandas-dataframe
namespace: company.team

tasks:
  - id: esql_query
    type: io.kestra.plugin.elasticsearch.Request
    connection:
      hosts:
        - "https://b08318eb65f34bfdadcca4a633ea1602.us-central1.gcp.cloud.es.io\
          :443"
      headers:
        - "Authorization: ApiKey {{ secret('ES_API_TOKEN') }}"
    method: "POST"
    endpoint: /_query?format=csv
    body:
      query: |
        FROM test
        | WHERE title IS NOT NULL

  - id: pandas
    type: io.kestra.plugin.scripts.python.Script
    inputFiles:
      data.csv: "{{ outputs.esql_query.response }}"
    beforeCommands:
      - pip install pandas
    script: |
      import pandas as pd
      data = pd.read_csv("data.csv", sep=',')
      print(data.head())

About this blueprint

Python API

This flow runs an Elastic ESQL query on the test index and converts the results to a pandas.DataFrame in Python.

Request

Script

More Related Blueprints

New to Kestra?

Use blueprints to kickstart your first workflows.

Get started with Kestra