Space Cloud allows you to view the logs of your deployed services easily via Mission Control and space-cli
both.
Head over to the Deployments
section in Mission Control:
Expand the required service to view its replicas by clicking on the plus icon in the left:
Click on the View logs
button beside any replica to view its logs:
The logs viewed via Mission Control are streamed in realtime (i.e. more logs will show up as and when they happen).
By default, the Mission Control applies a filter to view the logs from last 10 minutes only. You can change the applied filter by clicking on the Filters
button.
Many times, you might want to view logs since specific time duration. For example, you might want to view logs of the last 5 minutes or maybe last 1 hour.
To change the time duration, click on the Filters
button to open the following modal:
Select the Specific duration
option in the Show logs since
field.
The unit of duration can be changed via the dropdown. The unit can be seconds, minutes or hours.
Click on the Save filters
button to apply the filters.
To view logs since a specific time, click on the Filters
button to open the filters modal. Click on the Specific time
option in the Show logs since
field:
Select a specific date and time via the date and time picker in the modal.
Click on the Save filters
button to apply the filters.
To view all logs since the start, select the Start
option in the Show logs since
field:
It’s a good practice to limit the number of logs fetched, especially if you have a large number of logs. You can specify the number of most recent logs that you want to fetch in Mission Control.
Click on the Filters
button. Check the Tail logs
option and specify the limit:
Mission Control allows you to perform a contains
search on the logs fetched. Just type the text that you want to search for in the logs and Mission Control will show the matching logs:
To view all the logs of a service via space-cli, run the following command:
space-cli logs <replica-id> --project <project-id> --task <task-id>
The <replica-id>
will be autocompleted by space-cli
if you have enabled autocomplete for space-cli
.
Add the --since
flag to view logs since a specific duration:
space-cli logs <replica-id> --project <project-id> --task <task-id> --since=<duration>
Examples of duration:
10s
(10 seconds)30m
(30 minutes)2h
(2 hours)Example: Fetch logs since last 5 minutes:
space-cli logs <replica-id> --project <project-id> --task <task-id> --since=5m
Add the --since-time
flag to view logs since a specific time:
space-cli logs <replica-id> --project <project-id> --task <task-id> --since-time=<time>
The <time>
needs to be an ISO 8601 date string.
Example:
space-cli logs <replica-id> --project <project-id> --task <task-id> --since-time="2019–02–06T03:59:40.417Z"
It’s a good practice to limit the number of logs fetched, especially if you have a large number of logs. You can specify the number of most recent logs that you want to fetch via the --tail
command.
Example: Fetch last 20 logs:
space-cli logs <replica-id> --project <project-id> --task <task-id> --tail=20
While debugging your service, you often might want to follow/watch the logs as and when they are coming. Use the --follow
flag to follow a log stream:
space-cli logs <replica-id> --project <project-id> --task <task-id> --follow