Ops

Observability

Ops surface: Prometheus scrape plus an Oban-style jobs dashboard.

Prefer Ops.Plugin for a live SPA overview at /_ops over /_ops/socket. Jobs list/detail pages stay SSR via jobsPage / jobPage. Mutations use redirect after Jobs.cancel / Jobs.retry.

case Ops.match req of
    Ops.Metrics ->
        Server.string 200 [] "text/plain; version=0.0.4" (Ops.metrics ())

    Ops.Overview _ ->
        Ops.Plugin.dashboardShell

    Ops.JobsList query ->
        -- counts + list, then Ops.jobsPage

    Ops.None ->
        -- app routes

Types

JobsQuery

type alias JobsQuery =
{ state : Maybe String
, queue : Maybe String
, worker : Maybe String
, live : Bool
}

Filter + live flag for /_ops/jobs.

Route

type Route
= Overview Bool
| JobsList JobsQuery
| JobDetail Jobs.JobId
| CancelJob Jobs.JobId
| RetryJob Jobs.JobId
| Metrics
| None

Which ops route a request hit.

OverviewPage

type alias OverviewPage =
{ node : String
, peers : List String
, jobCounts : List Jobs.StateCount
, events : List Telemetry.Event
, recent : List Jobs.JobInfo
}

Data for the overview page.

Named OverviewPage so it does not clash with the Route constructor Overview.

JobsPage

type alias JobsPage =
{ jobCounts : List Jobs.StateCount
, jobs : List Jobs.JobInfo
, filter : Jobs.ListFilter
, live : Bool
}

Data for the jobs list page.

JobPage

type alias JobPage =
{ job : Maybe Jobs.JobInfo }

Data for a single job detail page.

Values

metrics

metrics : () -> String

Prometheus text from Telemetry aggregations.

Examples

Ops.metrics ()

match

match : Request -> Route

Classify /_ops, /_ops/jobs, job detail/actions, and /metrics.

Examples

Ops.match req

listFilter

listFilter : JobsQuery -> Jobs.ListFilter

Build a Jobs.ListFilter from an ops jobs query (limit 50).

overview

overview : List Jobs.StateCount -> List Jobs.JobInfo -> OverviewPage

Build an overview snapshot from counts and a recent job list.

overviewPage

overviewPage : OverviewPage -> Bool -> Response

Render the overview HTML page.

jobsPage

jobsPage : JobsPage -> Response

Render the jobs list HTML page.

jobPage

jobPage : JobPage -> Response

Render the job detail HTML page.

redirect

redirect : String -> Response

HTTP 303 redirect to location.