Monitoring

SAQ comes with a simple UI for monitor workers and jobs:

SAQ Web UI

SAQ Web UI

Part of worker process

You can run it as part of the worker process:

saq examples.simple.settings --web

which wil serve it on port 8080 by default. You can specify a custom port by adding --port <portnum>. e.g.:

saq examples.simple.settings --web --port 7000

Mounted in your own web service

You can also mount the Web UI as part of your own web service

Starlette/FastAPI

Module saq.web.starlette contains a starlette instance for use in anything that is derived from Starlette.

from contextlib import asynccontextmanager

from fastapi import FastAPI

from saq import Queue
from saq.web.starlette import saq_web

# import it from your module where you defined your settings
queue = Queue.from_url("postgres://postgres@localhost")


@asynccontextmanager
async def lifespan(app: FastAPI):
    await queue.connect()

    yield


app = FastAPI(lifespan=lifespan)


app.mount("/monitor", saq_web("/monitor", queues=[queue]))

from saq.web.starlette import saq_web
from starlette.routing import Mount

routes = [
    ...
    Mount("/monitor", saq_web("/monitor", queues=all_the_queues_list))
]
saq.web.starlette.saq_web(root_path, queues)[source]

Create an embeddable monitoring Web UI

Example

routes = [
    Mount("/monitor", saq_web("/monitor", queues=all_the_queues_list))
]
Parameters:
  • root_path (str) – The absolute mount point, typically the same as where you mount it.

  • queues (list[saq.queue.Queue]) – The list of known queues

Returns:

Starlette ASGI instance.

Return type:

starlette.applications.Starlette