Skip to content

How do I view logs for my service?

Keyword: How do I view logs for my service?

SmartTouch aggregates all service logs in Loki. You can access them from the terminal with stctl logs or from the Grafana Logs panel. Both methods support filtering by session ID, device ID, log level, and time range.


Goal

View and filter logs from the Remote Access Service, filtered to a specific session.


Prerequisites

  • The Remote Access Service deployed and running
  • stctl authenticated

Method 1 — Stream logs from the terminal

Stream live logs from all pods of your service:

stctl logs --env dev --service remote-access-service --follow

Expected output — structured JSON logs streamed from all pods:

{"level":"info","message":"Session opened","sessionId":"sess-a7c3f1","deviceId":"sensor-001","protocol":"shell","userId":"alex@example.com","timestamp":"2026-06-06T14:05:22Z"}
{"level":"info","message":"Session closed","sessionId":"sess-a7c3f1","duration":135,"closedBy":"user","timestamp":"2026-06-06T14:07:37Z"}

Press Ctrl+C to stop streaming.

Filter logs by session ID

stctl logs --env dev --service remote-access-service \
  --filter sessionId=sess-a7c3f1

Filter logs by device ID

stctl logs --env dev --service remote-access-service \
  --filter deviceId=sensor-001 \
  --since 1h

Filter by log level

stctl logs --env dev --service remote-access-service \
  --level error \
  --since 30m

View logs from a specific pod

stctl pods --env dev --service remote-access-service
# Note the pod name, then:
stctl logs --env dev --service remote-access-service \
  --pod remote-access-service-6c8d4f-ql7rn

Method 2 — Query logs in Grafana

Open the pre-built Grafana dashboard for your service:

stctl dashboard open --name service-logs --env dev

Loki query syntax

The Grafana Logs panel uses LogQL. Common queries for the Remote Access Service:

All logs from the Remote Access Service:

{service="remote-access-service", env="dev"}

Error logs only:

{service="remote-access-service", env="dev"} | json | level="error"

Logs for a specific session:

{service="remote-access-service", env="dev"} | json | sessionId="sess-a7c3f1"

Logs for a specific device:

{service="remote-access-service", env="dev"} | json | deviceId="sensor-001"

Session open events in the last hour:

{service="remote-access-service", env="dev"} | json | message="Session opened"

Validation

Logs are accessible when:

stctl logs --env dev --service remote-access-service --since 5m
# Returns recent log lines from the service

Troubleshooting

If no logs appear, see Why are my logs not appearing?.


Next steps