-
Notifications
You must be signed in to change notification settings - Fork 6
/
logs.html
111 lines (83 loc) · 4.82 KB
/
logs.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
---
layout: default
title: Application Logs
---
<div class='row'><div class='col-xs-12 col-sm-6 sidebar-text'><h1 id="application-logs">Application Logs</h1>
<h2 id="dump-and-stream-logs">Dump and stream logs</h2>
<p><code class="highlighter-rouge">GET https://logs.scalingo.com/apps/[:app]/logs?token=[:token]</code></p>
<p>To get an authenticated URL, see <a href="/apps.html#access-to-the-application-logs">Application#logs</a></p>
<h3 id="parameters">Parameters</h3>
<ul>
<li><code class="highlighter-rouge">n</code>: How many lines of the history should be returned</li>
<li><code class="highlighter-rouge">stream</code> (default false): toggle streaming</li>
</ul>
</div><div class='hidden-xs col-xs-12 col-sm-6 sidebar-code'></div></div><div class='row'><div class='col-xs-12 col-sm-6 sidebar-text'>
<h3 id="dump-logs">Dump logs</h3>
<p>If <code class="highlighter-rouge">stream=false</code> or is not set, the response will be simple text containing
the logs.</p>
</div><div class='col-xs-12 col-sm-6 sidebar-code'>
<p>Example request:</p>
<div class="highlighter-rouge"><pre class="highlight"><code>curl -X GET <span class="s1">'https://logs.scalingo.com/apps/example-app/logs?n=10'</span>
</code></pre>
</div>
<p>Response 200 OK</p>
<p>Content-Type: text/plain</p>
<div class="highlighter-rouge"><pre class="highlight"><code>2015-02-16 02:02:43.930163178 +0000 UTC [web-1] [martini] Started GET / for [filtered IP]
2015-02-16 02:02:43.930366145 +0000 UTC [web-1] [martini] Completed 200 OK in 706.641us
2015-02-16 14:47:03.193533257 +0000 UTC [web-1] [martini] Started GET / for [filtered IP]
2015-02-16 14:47:03.193707764 +0000 UTC [web-1] [martini] Completed 200 OK in 726.31us
2015-02-17 03:40:14.075695384 +0000 UTC [web-1] [martini] Started GET /robots.txt for [filtered IP]
2015-02-17 03:40:14.075881300 +0000 UTC [web-1] [martini] Completed 404 Not Found in 490.714us
2015-02-17 03:40:14.137580886 +0000 UTC [web-2] [martini] Started GET / for [filtered IP]
2015-02-17 03:40:14.137823473 +0000 UTC [web-2] [martini] Completed 200 OK in 479.471us
2015-02-17 16:49:08.560437937 +0000 UTC [web-1] [martini] Started GET / for [filtered IP]
2015-02-17 16:49:08.560662564 +0000 UTC [web-1] [martini] Completed 200 OK in 685.771us
</code></pre>
</div>
</div></div><div class='row'><div class='col-xs-12 col-sm-6 sidebar-text'>
<h3 id="stream-logs">Stream logs</h3>
<p>When <code class="highlighter-rouge">stream=true</code> two ways to fetch logs are possible</p>
<ul>
<li>Websocket
If your request contains the following headers:
<ul>
<li>Upgrade: websocket</li>
<li>Connection: Upgrade
An attempt to communicate through websocket will be done.</li>
</ul>
</li>
<li>Server Sent-Events (SSE)
If websocket is not required, it will fallback on SSE</li>
</ul>
<p>If you are not familiar with these technologies, here is a <a href="http://enterprisewebbook.com/ch8_websockets.html">nice
intro to them</a>.</p>
</div><div class='col-xs-12 col-sm-6 sidebar-code'>
<p>Websocket example:</p>
<div class="highlighter-rouge"><pre class="highlight"><code>curl -H <span class="s2">"Connection: Upgrade"</span> -H <span class="s2">"Upgrade: websocket"</span> -v <span class="se">\</span>
-X GET <span class="s1">'https://logs.scalingo.com/apps/example-app/logs?n=0&stream=true'</span>
</code></pre>
</div>
<p>Return 101 Switching Protocol</p>
<p>Each event:</p>
<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="w">
</span><span class="s2">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"log"</span><span class="p">,</span><span class="w">
</span><span class="s2">"log"</span><span class="p">:</span><span class="w"> </span><span class="s2">"<log content>"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre>
</div>
</div></div><div class='row'><div class='col-xs-12 col-sm-6 sidebar-text'>
<h3 id="keepalive-events-to-avoid-connection-timeout">Keepalive events to avoid connection timeout</h3>
<p>Our frontal servers disallow inactive connections. To avoid websockets or SSE
connections to be cut after 30 seconds of inactivity, both methods are send
keepalive data.</p>
<p>These events don’t expect any responser, they just ensure the connection is not
closed.</p>
</div><div class='col-xs-12 col-sm-6 sidebar-code'>
<p>Exemple of keepalive event</p>
<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="w">
</span><span class="s2">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ping"</span><span class="p">,</span><span class="w">
</span><span class="s2">"timestamp"</span><span class="p">:</span><span class="w"> </span><span class="s2">"<date>"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre>
</div>
</div></div>