# Ingesting a sql query

**URL:** <https://forum.opensearch.org/t/ingesting-a-sql-query/21176>\
**Category:** OpenSearch\
**Created:** [September 7, 2024, 11:46am UTC](https://forum.opensearch.org/t/ingesting-a-sql-query/21176 "2024-09-07T11:46:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![GRobertson](https://avatars.discourse-cdn.com/v4/letter/g/ed655f/32.png) [@GRobertson](https://forum.opensearch.org/u/GRobertson)\
**Post date:** [September 7, 2024, 11:46am UTC](https://forum.opensearch.org/t/ingesting-a-sql-query/21176/1 "2024-09-07T11:46:27Z")

</div>

Does anyone have a step by step guide to ingest a sql query into Opensearch.  
I’m migrating from Elastic v8 and this was an easy function using the metricbeat sql module.

---

<div class="post-metadata">

**Author:** ![Eugene7](https://avatars.discourse-cdn.com/v4/letter/e/bbce88/32.png) [@Eugene7](https://forum.opensearch.org/u/Eugene7)\
**Post date:** [September 9, 2024, 12:03pm UTC](https://forum.opensearch.org/t/ingesting-a-sql-query/21176/2 "2024-09-09T12:03:44Z")

</div>

hi @GRobertson ,

To ingest SQL query, you can send the request as in an example below:

```auto
POST _plugins/_sql
{
  "query": "SELECT * FROM my-index LIMIT 50"
}

```

Have you had the chance to read the following documentation?

> **[SQL](https://opensearch.org/docs/latest/search-plugins/sql/sql/index/)**
>
> SQL

---

<div class="post-metadata">

**Author:** ![GRobertson](https://avatars.discourse-cdn.com/v4/letter/g/ed655f/32.png) [@GRobertson](https://forum.opensearch.org/u/GRobertson)\
**Post date:** [September 9, 2024, 3:29pm UTC](https://forum.opensearch.org/t/ingesting-a-sql-query/21176/3 "2024-09-09T15:29:29Z")

</div>

Hi. I am referring to getting data from a SQL database into Opensearch, rather than querying data that already resides with my indices.

---

<div class="post-metadata">

**Author:** ![Eugene7](https://avatars.discourse-cdn.com/v4/letter/e/bbce88/32.png) [@Eugene7](https://forum.opensearch.org/u/Eugene7)\
**Post date:** [September 9, 2024, 5:25pm UTC](https://forum.opensearch.org/t/ingesting-a-sql-query/21176/4 "2024-09-09T17:25:22Z")

</div>

Metricbeat is also compatible with OpenSearch:

> **[Tools](https://opensearch.org/docs/latest/tools/)**
>
> OpenSearch tools

I think you can use the metricbeat sql module with OpenSearch as well.

---

<div class="post-metadata">

**Author:** ![GRobertson](https://avatars.discourse-cdn.com/v4/letter/g/ed655f/32.png) [@GRobertson](https://forum.opensearch.org/u/GRobertson)\
**Post date:** [September 9, 2024, 9:41pm UTC](https://forum.opensearch.org/t/ingesting-a-sql-query/21176/5 "2024-09-09T21:41:07Z")

</div>

Hi. Metricbeat OSS 7.12 doesn’t contain the sql module.

---

<div class="post-metadata">

**Author:** ![Eugene7](https://avatars.discourse-cdn.com/v4/letter/e/bbce88/32.png) [@Eugene7](https://forum.opensearch.org/u/Eugene7)\
**Post date:** [September 10, 2024, 12:46pm UTC](https://forum.opensearch.org/t/ingesting-a-sql-query/21176/6 "2024-09-10T12:46:27Z")

</div>

Another option is to use Fluent Bit or Logstash with an SQL input plugin and an OpenSearch output plugin:

> **[Fluent Bit + SQL | Fluent Bit: Official Manual](https://docs.fluentbit.io/manual/stream-processing/getting-started/fluent-bit-sql)**

> **[Jdbc input plugin | Logstash Reference \[8.15\] | Elastic](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html)**

> **[OpenSearch | Fluent Bit: Official Manual](https://docs.fluentbit.io/manual/pipeline/outputs/opensearch)**
>
> Send logs to Amazon OpenSearch Service

> **[GitHub - opensearch-project/logstash-output-opensearch: A Logstash plugin that sends event data to a...](https://github.com/opensearch-project/logstash-output-opensearch)**
>
> A Logstash plugin that sends event data to a OpenSearch clusters and stores as an index.
