dehaze

Viewing Logs

Space Cloud allows you to view the logs of your deployed services easily via Mission Control and space-cli both.

Via Mission Controllink

Head over to the Deployments section in Mission Control:

Deployment add service page

Expand the required service to view its replicas by clicking on the plus icon in the left:

Deployment replicas

Click on the View logs button beside any replica to view its logs:

Service 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.

Viewing logs since a specific durationlink

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:

Service Logs Duration Filter

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.

Viewing logs since a specific timelink

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:

Service Logs Time Filter

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.

Viewing all logs since the startlink

To view all logs since the start, select the Start option in the Show logs since field:

Service Logs All Filter

Limit the number of logs fetchedlink

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:

Service Logs Limit Rows

Searching logslink

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:

Service Logs Search

Via clilink

Viewing all logs since the startlink

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.

Viewing logs since a specific durationlink

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

Viewing logs since a specific timelink

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"

Limit the number of logs fetchedlink

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

Following logslink

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

Have a technical question?

Improve the docs!