Using REST to access cloud logs
- Related topics
This page describes the logs
endpoint, which can be used to access
Magnolia cloud instance logs. For viewing and managing the logs via the
Cockpit, see the
Managing
cloud log levels page.
Obtaining an authentication token
Important When sending REST requests, make sure you always send them via a secure protocol such as HTTPS so that communication with the endpoint is encrypted. |
A REST request for a cloud log must be authenticated. Magnolia uses
authentication based on the
JSON Web Token. To obtain
a JWT token, issue the following curl
command in bash, where:
-
<your_username>
is the LDAP user name assigned to you in your Cloud subscription package to access the Cockpit. -
<your_password>
is the LDAP user name assigned to you in the package. -
<cockpit-domain-name>
is the domain name of your Cockpit.
curl -H "X-Auth-Username: <your_username>" -H "X-Auth-Password: <your_password>" -X POST https://<cockpit-domain-name>/authenticate
For example:
curl -H "X-Auth-Username: John" -H "X-Auth-Password: Doe" -X POST https://cockpit.example.com/authenticate
You should get a response like this:
{"authToken":"<token-header>.<token-payload>.<token-signature>"}
The token required is this part:
<token-header>.<token-payload>.<token-signature>
.
The request
Currently Magnolia clouds logs keep a maximum of the last 5 minutes of
log data or the last 1000 log lines, counted from time-now OR from a log
record matching the recordLocator
, if sent in the request.
Request URL
GET
https://<cockpit-domain-name>/.rest/instances/logs?siteName=<subscription-package-code>&environment=<int|uat|live>&mgnlInstanceName=<name-of-the-instance>&logMoveDirection={1|-1}&recordLocator=<locator-string>
Parameters
Parameter | Description | Parameter Type | Data Type | ||
---|---|---|---|---|---|
|
required The code of your subscription package. You can find the site name displayed in your
environments,
for example |
|
|
||
|
required The environment name. Can only be one of the following:
|
|
|
||
|
required The name of the instance. You can find the instance name after setting up an environment or in the View log page instance dropdown. For example: |
|
|
||
|
required The direction in which to traverse the log. Use |
|
|
||
|
optional A specific log record that serves as the main reference point. The locator is a Base64-encoded string.
|
|
|
Examples
GET the log from the public1 uat
instance of the
example-abbrev
cloud subscription package:
Command
curl -H "X-Auth-Token:{JWT-token}" -X GET "https://cockpit.example.com/.rest/instances/logs?siteName=example-abbrev&environment=uat&mgnlInstanceName=public1&logMoveDirection=-1"
{
"logs": [{
"message": "172.31.2.212 - - [27/Apr/2018:09:11:42 +0000] \"GET /.healthcheck/ HTTP/1.1\" 200 30",
"timestamp": "2018-04-27T09:11:46.000000000+00:00",
"recordLocator": "WzE1MjQ4MjAzMDgxMDYxNjYsMzAwNTExXQ=="
}, {
"message": "172.31.27.131 - - [27/Apr/2018:09:11:44 +0000] \"GET /.healthcheck/ HTTP/1.1\" 200 30",
"timestamp": "2018-04-27T09:11:46.000000000+00:00",
"recordLocator": "WzE1MjQ4MjAzMDgxMDYyMTYsODc5Nl0="
}, {
"message": "172.31.2.212 - - [27/Apr/2018:09:12:12 +0000] \"GET /.healthcheck/ HTTP/1.1\" 200 30",
"timestamp": "2018-04-27T09:12:16.000000000+00:00",
"recordLocator": "WzE1MjQ4MjAzMzgxMTExMDIsODU3NDBd"
}, {
"message": "172.31.27.131 - - [27/Apr/2018:09:12:14 +0000] \"GET /.healthcheck/ HTTP/1.1\" 200 30",
"timestamp": "2018-04-27T09:12:16.000000000+00:00",
"recordLocator": "WzE1MjQ4MjAzMzgxMTExNTEsMzAwNTIxXQ=="
}, {
"message": "172.31.2.212 - - [27/Apr/2018:09:12:42 +0000] \"GET /.healthcheck/ HTTP/1.1\" 200 30",
"timestamp": "2018-04-27T09:12:46.000000000+00:00",
"recordLocator": "WzE1MjQ4MjAzNjgxMTQ1OTYsODgwNV0="
}],
"lastRecordLocator": "WzE1MjQ4MjAzMDgxMDYxNjYsMzAwNTExXQ=="
}
GET the same as in the previous example but now relative to the
[1524820338111102,85740]
log record (Base64-encoded as
WzE1MjQ4MjAzMzgxMTExMDIsODU3NDBd
in the URL):
Command
curl -H "X-Auth-Token:{JWT-token}" -X GET "https://cockpit.example.com/.rest/instances/logs?siteName=example-abbrev&environment=uat&mgnlInstanceName=public1&logMoveDirection=-1&recordLocator=WzE1MjQ4MjAzMzgxMTExMDIsODU3NDBd"
{
"logs": [{
"message": "172.31.27.131 - - [27/Apr/2018:09:11:14 +0000] \"GET /.healthcheck/ HTTP/1.1\" 200 30",
"timestamp": "2018-04-27T09:11:16.000000000+00:00",
"recordLocator": "WzE1MjQ4MjAyNzgxMDIwODYsODc5NV0="
}, {
"message": "172.31.2.212 - - [27/Apr/2018:09:11:42 +0000] \"GET /.healthcheck/ HTTP/1.1\" 200 30",
"timestamp": "2018-04-27T09:11:46.000000000+00:00",
"recordLocator": "WzE1MjQ4MjAzMDgxMDYxNjYsMzAwNTE1XQ=="
}, {
"message": "172.31.27.131 - - [27/Apr/2018:09:11:44 +0000] \"GET /.healthcheck/ HTTP/1.1\" 200 30",
"timestamp": "2018-04-27T09:11:46.000000000+00:00",
"recordLocator": "WzE1MjQ4MjAzMDgxMDYyMTYsODc5Nl0="
}],
"lastRecordLocator": "WzE1MjQ4MjAyNzgxMDIwODYsODc5NV0="
}