# Relaying host and container logs & console to logstash or logagent

**URL:** <https://forums.balena.io/t/relaying-host-and-container-logs-console-to-logstash-or-logagent/163413>\
**Category:** balenaOS\
**Created:** [July 27, 2020, 1:22pm UTC](https://forums.balena.io/t/relaying-host-and-container-logs-console-to-logstash-or-logagent/163413 "2020-07-27T13:22:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Charry2014](https://avatars.discourse-cdn.com/v4/letter/c/8e8cbc/32.png) [@Charry2014](https://forums.balena.io/u/Charry2014)\
**Post date:** [July 27, 2020, 1:22pm UTC](https://forums.balena.io/t/relaying-host-and-container-logs-console-to-logstash-or-logagent/163413/1 "2020-07-27T13:22:28Z")

</div>

Hello everyone - can anyone help me get logs and stdout & stderr output from containers running under BalenaOS into a log shipper like logstash or logagent. I am using [Sematext](https://sematext.com/) to collect and analyse logs from my application but would also like to gather information about the containers and host that are running these applications.

As a start it would be great to gather everything that is printed by the applications in the containers in the Balena Dashboard logs window. This output tends to show everything I need right now. I have been investigating with the `balena logs` command but do not know how to install something that would push all logs out to a remote collection tool.

This will be used on a production system to monitor it for reliability and generate alerts when bad things happen. Sematext have a [logagent docker](https://hub.docker.com/r/sematext/logagent) that can ship the logs remotely, but how to get the logs to it?

---

<div class="post-metadata">

**Author:** ![chrisys](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/chrisys/32/1731_2.png) [@chrisys](https://forums.balena.io/u/chrisys)\
**Post date:** [July 27, 2020, 1:59pm UTC](https://forums.balena.io/t/relaying-host-and-container-logs-console-to-logstash-or-logagent/163413/4 "2020-07-27T13:59:55Z")

</div>

Hey there @Charry2014

I think the best thing for you to start looking into for this would be receiving the Journald logs from the supervisor API: [https://www.balena.io/docs/reference/supervisor/supervisor-api/#journald-logs](https://www.balena.io/docs/reference/supervisor/supervisor-api/#journald-logs)

We also have an example here that uses Loggly, but you may be able to modify it for your use case: [https://github.com/balena-io-examples/device-cloud-logging](https://github.com/balena-io-examples/device-cloud-logging)

Let us know if you need any further information!

---

<div class="post-metadata">

**Author:** ![Charry2014](https://avatars.discourse-cdn.com/v4/letter/c/8e8cbc/32.png) [@Charry2014](https://forums.balena.io/u/Charry2014)\
**Post date:** [August 4, 2020, 3:41pm UTC](https://forums.balena.io/t/relaying-host-and-container-logs-console-to-logstash-or-logagent/163413/6 "2020-08-04T15:41:57Z")

</div>

Hi chrisys - many thanks for the tips. I did some playing and have understood what is going on here.

Added in docker-compose for the services that need to log:

```
labels:
  io.balena.features.supervisor-api: '1'
  io.balena.features.balena-api: '1'
  io.balena.features.balena-socket: '1'

```

Then:

`curl -X POST -H "Content-Type: application/json" --data '{"follow":true,"all":true}' "$BALENA_SUPERVISOR_ADDRESS/v2/journal-logs?apikey=$BALENA_SUPERVISOR_API_KEY"`

works a little like tail on the logs that are generated. So far so good. Thank you.
