|
4 | 4 | .. _platform_logging: |
5 | 5 |
|
6 | 6 | Platform logging |
7 | | -========================= |
| 7 | +================ |
8 | 8 |
|
9 | | -Comprehensive platform logging is a goal for Deis 1.0. We are currently investigating solutions for |
10 | | -this, and progress can be tracked in GitHub issue `#980`_. |
| 9 | +Logging for Deis components and deployed applications is handled by two components: |
| 10 | +:ref:`logger` and :ref:`logspout`. |
11 | 11 |
|
12 | | -In the meantime, however, ``journalctl`` can be used to pipe log output to a remote host. For example, |
13 | | -to send service log output to Papertrail: |
| 12 | +``deis-logspout`` is based on progrium's `logspout`_ project and runs on all CoreOS hosts. It |
| 13 | +collects logs from running containers and sends their logs to ``/deis/logs/host`` and |
| 14 | +``/deis/logs/port``. |
| 15 | + |
| 16 | +``deis-logger`` collects the logs sent by logspout and archives them for use by :ref:`Controller` |
| 17 | +when a client runs ``deis logs``. This component publishes its host and port to ``/deis/logs/host`` |
| 18 | +and ``/deis/logs/port``, and is typically the service which consumes logs from ``deis-logspout``. |
| 19 | + |
| 20 | +Routing logs to a custom location |
| 21 | +--------------------------------- |
| 22 | + |
| 23 | +Logging to an external location can be achieved without modifying the log flow within Deis - |
| 24 | +we can simply send the master journal on a CoreOS host using ``ncat``. For example, if I'm using the |
| 25 | +`Papertrail`_ hosted log service, I can forward all logs on a host to Papertrail using the host |
| 26 | +and port provided to me by Papertrail: |
| 27 | + |
| 28 | +.. code-block:: console |
| 29 | +
|
| 30 | + $ journalctl -o short -f | ncat --udp logs2.papertrailapp.com 23654 |
| 31 | +
|
| 32 | +This is really only useful when shipped as a service that we don't have to run ourselves in |
| 33 | +a shell. We can use a fleet service for this: |
14 | 34 |
|
15 | 35 | .. code-block:: console |
16 | 36 |
|
17 | | - journalctl -o short -f | ncat --udp logs.papertrailapp.com 34000 |
| 37 | + [Unit] |
| 38 | + Description=Log forwarder |
| 39 | +
|
| 40 | + [Service] |
| 41 | + ExecStart=/bin/sh -c "journalctl -o short -f | ncat --udp logs2.papertrailapp.com 23654" |
| 42 | +
|
| 43 | + [Install] |
| 44 | + WantedBy=multi-user.target |
| 45 | +
|
| 46 | + [X-Fleet] |
| 47 | + Global=true |
| 48 | +
|
| 49 | +Save the file as ``log-forwarder.service``. Load and start the service with |
| 50 | +``fleetctl load log-forwarder.service && fleetctl start log-forwarder.service``. |
| 51 | + |
| 52 | +Shortly thereafter, you should start to see logs from every host in your cluster appear in the |
| 53 | +Papertrail dashboard. |
18 | 54 |
|
19 | | -.. _`#980`: https://github.com/deis/deis/issues/980 |
| 55 | +.. _`logspout`: https://github.com/progrium/logspout |
| 56 | +.. _`papertrail`: https://papertrailapp.com/ |
0 commit comments