# Export aggregated reports into Postgres

**URL:** <https://discuss.elastic.co/t/export-aggregated-reports-into-postgres/349806>\
**Category:** Elasticsearch\
**Created:** [December 21, 2023, 2:33pm UTC](https://discuss.elastic.co/t/export-aggregated-reports-into-postgres/349806 "2023-12-21T14:33:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tmslara.a](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tmslara.a/32/116339_2.png) [@tmslara.a](https://discuss.elastic.co/u/tmslara.a)\
**Post date:** [December 21, 2023, 2:33pm UTC](https://discuss.elastic.co/t/export-aggregated-reports-into-postgres/349806/1 "2023-12-21T14:33:38Z")

</div>

Hello,

I am indexing data into an Elasticsearch cluster (of one node) based on events associated with different devices, each identified by an ID. Many events can occur during the day. At the end of each day, I would like to obtain a report, for example, indicating the number of documents per device ID.

I know how to perform this operation inside Elasticsearch, using terms and count aggregations. However, I want to save these daily 'reports' into a Postgresql database. My question is, Is there any way to compute this 'report' and send/export it to a Postgresql database? Or should I write a script?

I checked a connector between ES and Postgresql, however, it seems to be used for importing data from SQL instead of exporting data into it.

Thanks in advance,  
Best regards,

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [December 21, 2023, 4:31pm UTC](https://discuss.elastic.co/t/export-aggregated-reports-into-postgres/349806/2 "2023-12-21T16:31:43Z")

</div>

Hi @tmslara.a

> [@tmslara.a](#):
>
> Or should I write a script?

I don't think there is an out-of-the-box way to do this; I think a script in your favorite language / Python would probably be the best approach.

> [@tmslara.a](#):
>
> I checked a connector between ES and Postgresql, however, it seems to be used for importing data from SQL instead of exporting data into it.

Yes that is correct.

---

<div class="post-metadata">

**Author:** ![tmslara.a](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tmslara.a/32/116339_2.png) [@tmslara.a](https://discuss.elastic.co/u/tmslara.a)\
**Post date:** [December 21, 2023, 5:42pm UTC](https://discuss.elastic.co/t/export-aggregated-reports-into-postgres/349806/3 "2023-12-21T17:42:32Z")

</div>

Thank you. I'll write the script then.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 18, 2024, 5:43pm UTC](https://discuss.elastic.co/t/export-aggregated-reports-into-postgres/349806/4 "2024-01-18T17:43:13Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
