# Upload my logs from node to ElasticSearch

**URL:** <https://discuss.elastic.co/t/upload-my-logs-from-node-to-elasticsearch/187003>\
**Category:** Logs\
**Created:** [June 23, 2019, 11:43am UTC](https://discuss.elastic.co/t/upload-my-logs-from-node-to-elasticsearch/187003 "2019-06-23T11:43:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shahar-Y](https://avatars.discourse-cdn.com/v4/letter/s/8edcca/32.png) [@Shahar-Y](https://discuss.elastic.co/u/Shahar-Y)\
**Post date:** [June 23, 2019, 11:43am UTC](https://discuss.elastic.co/t/upload-my-logs-from-node-to-elasticsearch/187003/1 "2019-06-23T11:43:53Z")

</div>

Hi, I'm new to ElasticSearch.  
I want my application to upload its logs while it's running - to my ElasticSearch server.  
My application is using node (typescript), and I can't understand how to upload a JSON log I created to the server.  
Do I have to create my own log file and only then send it to the ES server?  
Please help 🙂

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [June 23, 2019, 11:54am UTC](https://discuss.elastic.co/t/upload-my-logs-from-node-to-elasticsearch/187003/2 "2019-06-23T11:54:17Z")

</div>

Writing to a local log file and then have e.g. Filebeat read this and forward it to Elasticsearch is generally a good practice as it provided buffering on disk in case of issues with your Elasticsearch cluster. If you send data directly any issues with Elasticsearch or connectivity to it could potentially affect your application.

---

<div class="post-metadata">

**Author:** ![Shahar-Y](https://avatars.discourse-cdn.com/v4/letter/s/8edcca/32.png) [@Shahar-Y](https://discuss.elastic.co/u/Shahar-Y)\
**Post date:** [June 24, 2019, 10:25am UTC](https://discuss.elastic.co/t/upload-my-logs-from-node-to-elasticsearch/187003/3 "2019-06-24T10:25:25Z")

</div>

Could you reference me to a code doing that, or to a guide?

---

<div class="post-metadata">

**Author:** ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)\
**Post date:** [June 24, 2019, 5:55pm UTC](https://discuss.elastic.co/t/upload-my-logs-from-node-to-elasticsearch/187003/4 "2019-06-24T17:55:58Z")

</div>

As @Christian_Dahlqvist said, you _could_ send your logs directly to Elasticsearch via the HTTP API, but using an intermediate log file can be useful as a persistent buffer and queue.

If you choose to write a log file and ingest it via filebeat, the [filebeat configuration documentation](https://www.elastic.co/guide/en/beats/filebeat/current/configuring-howto-filebeat.html) can get you started. In particular the [inputs documentation](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-log.html), the [elasticsearch output documentation](https://www.elastic.co/guide/en/beats/filebeat/current/elasticsearch-output.html) and the [json decoding documentation](https://www.elastic.co/guide/en/beats/filebeat/current/decode-json-fields.html) could be of use.

For the new fields added by decoding your json data, I would strongly recommend to add them to the [index template](https://www.elastic.co/guide/en/beats/filebeat/current/configuration-template.html) using the `setup.template.append_fields` setting. This ensures your data types are correctly interpreted by Elasticsearch.

If you run into any roadblocks along the way, please don't hesitate to ask for specific advice.

---

<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:** [July 22, 2019, 5:56pm UTC](https://discuss.elastic.co/t/upload-my-logs-from-node-to-elasticsearch/187003/5 "2019-07-22T17:56:00Z")

</div>

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