Commit Graph
87 Commits
Author SHA1 Message Date
Wez Furlong 4255e02ffa WIP: smtp_server: scaffolding to support for batching by domain
This adds a `batch_handling` parameter that optionally allows splitting
up a recipient batch based on the destination domain.

The system does not yet have any support for correctly delivering such a
batch.
2025-10-07 07:52:57 +01:00
Wez Furlong 13a3debd6c rustfmt 2025-05-16 15:11:50 -07:00
Wez Furlong 42bf5c5e61 docs: adjust reference to improve search terms
We've been hoping that mkdocs-material will ship the much anticipated
search enhancements for some time, but it's time to recognize that
we need to do something to improve the search results with how
things work right now.

This is a big commit that changes the titles of the various pages
from the code-annotated synopsis to just the name of the function.

This makes it much easier now to match things like `kumo.reject`
directly, but `reject` remains awkward to find.

I think this is the best that we can do at this time.

A few functions have been annotated with the `status: deprecated` to
show as deprecated in the toc/nav (shows with a little trash can next
to the name).
2025-05-16 14:02:19 -07:00
Wez Furlong fedd2959b6 enhance log_arf, log_oob to support LogThenDrop
It is common to want to express that incoming reports should
be logged, but not relayed.

This commit facilitates that by expanding `log_arf` and `log_oob`
to allow more than just a simple boolean value.

We now support both LogThenRelay and LogThenDrop as dispositions
for an incoming report, as well as Ignore to not care about the
report content.

For the LogThenDrop case we'll log only the incoming OOB or Feedback
record to the logs and then discard the incoming message.

For LogThenRelay we'll log the incoming OOB/Feedback report as well
as enqueue the message and log a Reception and, subsequently, records
for its delivery attempts.

The previously supported boolean values are mapped to `Ignore` (false)
and `LogThenRelay` (true), respectively: their behavior is the same as
in prior releases.

The integration test and smtp server tracing infra has been enhanced a
bit to support extracting these new disposition states from the tracer
during the integration test.
2025-05-05 08:25:40 -07:00
Wez Furlong e3fdcaa628 cargo clippy --fix 2025-04-09 10:26:07 -07:00
Wez Furlong 129dbac461 kcli/top: support fuzzy matching series and heatmap names
Press f to edit the filter, watch it fuzzy match as you type.
2025-04-04 13:49:44 -07:00
Wez Furlong a9a096e76b kcli/top: refactor keyboard input
Move processing into state; this will aid in a future commit.
2025-04-04 10:32:07 -07:00
Wez Furlong bb9d786c86 kcli/top: scroll to tab when switching tabs 2025-04-04 08:14:04 -07:00
Wez Furlong f3a84fd40f kci/top: shift most heatmap math to accumulator stage
No need to rebuild/recompute the full data on each render
2025-04-04 08:11:12 -07:00
Wez Furlong 319b83bf8f kcli top: improve avg/freq labels
Some of the series ended up with bland labels like "lua" with
no context.  Let's include the overall metric name for those.

The consequence of this is that the labels column gets wider,
but I think that now that we have scrolling, we can adjust
that presentation in a follow up commit.
2025-04-04 07:59:46 -07:00
Wez Furlong 04ea7e5804 kcli top: auto add all histograms 2025-04-04 07:49:50 -07:00
Wez Furlong cb1c87ab15 kcli top: initial support for showing heatmaps 2025-04-04 07:17:05 -07:00
Wez Furlong ad7e98e7c5 kcli top: add basic help tab 2025-04-03 14:57:51 -07:00
Wez Furlong 4f8aadb05a kcli top: +/- increase/decrease the "zoom" of each row 2025-04-03 14:19:29 -07:00
Wez Furlong 0fc21cbbc6 kcli top: add vertical scrollbar
There are a lot of metrics these days, we need to scroll through them!
Use the arrow keys, page up/down and home/end for this purpose.

closes: https://github.com/KumoCorp/kumomta/issues/372
2025-04-03 14:00:59 -07:00
Wez Furlong 5e6e2c9497 kcli: update ratatui dep 2025-04-03 14:00:59 -07:00
Wez Furlong 3d0d0ebce1 kcli: refactor: split into more modules
no functional change
2025-04-03 12:48:57 -07:00
Wez Furlong 3af505f450 kcli: tracer: allow unbounded buffering of trace data
It's more acceptable for the client to go nuts with its own memory usage
than it is for the server side to waste memory on trace data, so let's
allow it to buffer indefinitely while it is busy formatting the output.
2025-01-28 11:07:59 -07:00
Wez Furlong dc1541c030 kcli: tracer: remove redundant bytes read|written output
When we output just a single line of data, there is no need
to also emit another line with its length. This was a side effect
of adding terse mode to the client side.

Now that we're doing the terse processing server side, the
non-Abbreviated cases are never actually terse-processing eligible
on the client (assuming that the client and server version match),
so having the byte length summary presented there is especially
noticeable.

We can simply elide it by trimming off trailing whitespace.
2025-01-28 10:59:09 -07:00
Wez Furlong 5f76d85d23 kcli: switch tracers to async websocket client
This should make things play a little more nicely in the client,
but it's not a significant difference in throughput or performance.
2025-01-28 10:49:23 -07:00
Wez Furlong d224feb62f tracing: enable server-side processing of terse flag
Cutting down on the data being transmitted can reduce the number
of lag events.

Increase the channel buffer size as well while we're in here.
2025-01-28 10:35:19 -07:00
Wez Furlong e3c3f5fbe0 tracing: emit diagnostic if the tracer has lagged
Previously we'd simply drop the connection. With this behavior we now
emit an error to the journal (once per tracer session) and emit a
diagnost to the client (each time) whenever some number of events
were dropped by the internal broadcast channel.
2025-01-28 10:35:19 -07:00
Wez Furlong 6841841283 first run at an inspect-sched-q command
This can return a sample (or all) of the messages as well as
some additional queue metadata for a named scheduled queue.

refs: #231
2025-01-23 17:10:41 -07:00
Wez Furlong ff8c0ccff2 Expose ready queue states via api, and in kcli queue-summary
This adds connection limit/throttle states to the readyq rows
in `kcli queue-summary`, alongside where we would show the
suspension state.

This makes it easier to understand when a given egress path
might be hitting connection limits.
2024-12-21 07:44:29 -07:00
Wez Furlong 6da455d42b kumod: process TSA Bounce rules and apply as bounces
Accepts scheduled queue bounce events from the event subscription,
and translates them into local admin bounce records.

refs: https://github.com/KumoCorp/kumomta/issues/272
2024-12-09 07:15:45 -07:00
Dirkjan Ochtman 16c73dfff8 Drop direct tungstenite dependency in favor of tokio-tungstenite 2024-11-13 13:50:27 -07:00
Wez Furlong a510e0d90c fix kcli double counting the ready queue size 2024-11-07 16:29:11 -07:00
Wez Furlong 12b3ae51ac fix TSA SuspendTenant rules always set duration to 5 minutes 2024-09-18 09:37:31 -07:00
Wez Furlong bb3a84fff5 provider-summary: make order of C/Q consistent with queue-summary 2024-09-16 18:24:31 -07:00
Wez Furlong a0d9fd7164 kcli: make bounce-list easier to read by default
Sites with lots of tenants and campaigns would produce an overwhelming
amount of output with the default json output mode.

Let's make json opt-in and default to a human readable output
mode that is more concise.

```console
$ kcli bounce-list
ID                                   REASON REMAIN                   BOUNCED CRITERIA
0d2402cc-2dce-44c8-85f6-a4c056300f55 boingo 4m 31s 150ms 560us 575ns  10,990 domain=hotmail.com
```
2024-09-13 08:52:54 -07:00
Wez Furlong be2eeda1f5 the bounce API endpoint is now always asynchronous
In systems with very large numbers of queues, it will take an
effectively unbounded amount of time to produce the initial
summary of results if we were to wait for the bounce to be
applied to every queue.

Let's adjust the output of the kcli to indicate that it is async,
and update the docs which already suggested that the numbers would
be partial to indicate that you can only really consume the id
from the response.
2024-09-13 08:52:54 -07:00
Wez Furlong 2366efad7e kcli queue-summary: show bounce/suspend reason
Include the reason for the bounce/suspension in the status annotation
that we show alongside a queue.

Previously, I considered this to be potentially noisy, but if you
consider that the most likely source of these annotations is likely
to be TSA, having that additional context is helpful.
2024-09-13 08:52:54 -07:00
Wez Furlong ed92367ea9 kcli: queue-summary: fix displaying suspension status
When rendering the suspension and bounce status, the various
queue name component parameters were flipped wrt. to the
suspension and bounce entries, causing them not to match.

This commit fixes that and restores stop sign and trash can
emoji status annotations to the output.
2024-09-13 08:52:54 -07:00
Wez Furlong 9c05e5e681 kcli queue-summary: fixup --limit handling for scheduled queues
The optimization to window over the minimal set wasn't excluding results
in the right way, so let's just remove that; we handle truncating
the overall results at a later stage anyway.
2024-09-13 08:52:54 -07:00
Wez Furlong aecb0d9713 kcli: *summary: use thousands separators for numeric output
Especially with provider-summary, the numbers can be very large
and adding the thousands separators makes them easier for humans
to parse.
2024-09-13 08:52:54 -07:00
Wez Furlong a90445a921 kcli: queue-summary: fixup output mentioning metrics endpoint
We switched from metrics.json to the main metrics endpoint,
so update this help text.
2024-09-13 08:52:54 -07:00
Wez Furlong ab12b9bc6a metrics: add provider rollups
Introduces the following new metrics:

* total_messages_(delivered|fail|transfail)_by_provider
  (labels: provider) - gives aggregates for a given provider/site.
* total_messages_(delivered|fail|transfail)_by_provider_and_source
  (labels: provider, source, pool) - gives aggregates for a given source
  to a specific provider/site.

These queued_count metrics sum the scheduled and ready queue counter
based on the provider, and provider_and_pool:

* queued_count_by_provider
  (labels: provider)
* queued_count_by_provider_and_pool
  (labels: provider, prool)

The provider label in this context is taken from the provider_name that
is set on the associated queue, or if none is set, the site name without
any source or protocol decoration.  This way it is relatively easy to
see at a glance the total queued volume for a given provider/site,
and also to see that broken down by the source *pool*.

And connection counts in a similar veing to the queued_counts:

* connection_count_by_provider
  (labels: provider) - number of connections currently established to
  a provider
* connection_count_by_provider_and_pool
  (labels: provider, pool) - number of connections currently established
  from a pool to a provider.

A new `kcli provider-summary` command shows a provider-centric view of
the queues, using these provider and pool based rollups.

refs: https://github.com/KumoCorp/kumomta/issues/274
2024-09-13 08:52:54 -07:00
Wez Furlong ad9a110920 rustfmt 2024-09-05 08:24:54 -07:00
Wez Furlong 5d4648782d kcli queue-summary: fix D and T columns in output
The recent changes in the streaming metrics parser made these look
at the wrong metric names.
2024-09-05 07:44:35 -07:00
Wez Furlong b384fb73a4 kcli trace-smtp-(client|server): improve usage for busy sites
This commit adds a couple of options that make it a bit easier
to make sense of high traffic environments.

It also fixes an issue with displaying timing: previously, if
we'd never seen the official start of a session, we'd never
show a reasonable time delta, and every record for that session
would be reported as `0ns`.

Now we assume that the first record for a session is as good as
the starting time for the session. That allows us to show
some meaningful timing information in the case that we attach
to an in-flight session for which we missing the start.
2024-09-03 06:25:09 -07:00
Wez Furlong c824985042 deps: upgrade http ecosystem crates so that we're on rusttls 0.23
The blocker for this was axum-server which has been holding us back
for a while. There is now a released version with rustls 0.23 support,
so bump up the various crates in the ecosystem.
2024-09-02 10:42:15 -07:00
Wez Furlong 03c80d5672 kcli top: modularize time series collection
Previously, we had a bunch of individually updated vecs of numbers
and hardcoded logic to translate them all to sparklines in the UI.
This was a bit awkward to maintain and extend.

This commit modularizes all that logic by introducing:

* An Accumulator concept that produces some output value from the
  complete set of input metrics. There are concrete instances of
  the accumulator that look for specific metrics by name, or
  that can aggregate across labelled metrics, or produce composite
  values from multiple different metrics.
* A RateAccumulator that adapts an input accumulator by outputing
  its rate of change.
* TimeSeries which tracks the output of a (possibly composite)
  accumulator
* A Factory concept that can dynamically instantiate a TimeSeries
  based on observed metrics. We use this to show the various
  latency and thread pool metrics.
2024-09-02 10:42:15 -07:00
Wez Furlong 484e8aeb4a kcli: adopt streaming metrics parser for top
This makes performance super fast in the prescence of millions
of queues.
2024-09-02 10:42:15 -07:00
Wez Furlong 285f246bc7 kcli: adopt streaming prometheus parser for queue-summary
This makes it work faster when there are a large number of queues.
2024-09-02 10:42:15 -07:00
Wez Furlong 982c91158a kcli top: adopt tokio interval with skip policy for updates
In situations where the server is under heavy stress, the metrics
endpoint can take longer than the update interval to return.
Over a period of time this can result in a backlog of pending
update requests that put more pressure on the server, and that
will also be late.

This commit switchers to an alternative interval approach that
knows to skip intervals if we're running behind.
2024-08-25 10:24:47 -07:00
Wez Furlong 8c1bfe4c7e kcli: handle list form of json metrics
```
  "scheduled_by_tenant_campaign": {
    "help": "number of messages in the scheduled queue for a specific tenant and campaign combination",
    "type": "gauge",
    "value": [
      {
        "@": 0.0,
        "campaign": "my-campaign",
        "tenant": "my-tenant"
      },
      ]
```
2024-08-22 14:20:16 -07:00
Wez Furlong fedf1c5569 kcli top: switch latency back from p90 to avg
The bucketing in the histograms on a second-to-second
time span makes the p90 less useful; it always just shows
the upper bound of one of the buckets because there's not enough
data in any bucket for the interpolation to show anything else.

We'll need to do some math over a long sampling period than the
kcli update interval for it to be more useful.

So, for now, we're showing the avg.
2024-08-22 11:07:08 -07:00
Wez Furlong d68859969d kcli: make it easier to add and consume histograms
Add a pass over the metrics data to collect the items more dynamically
than previously. This should parse out any newly added metric without
requiring that it be specifically named in the metrics struct in
here, making for less boilerplate.
2024-08-22 11:07:07 -07:00
Wez Furlong a9daff1f42 metrics: kcli: display p90 instead of avg
This commit adjusts the formatting of the json rendition of
histogram buckets, and then teaches kcli how to compute
quantiles over the buckets.

We use that to collect and show the p90 rather than the avg
latency in kcli top.

I want to add more histogram specific presentation options
to kcli in a follow up commit; this is just capturing
the quantile logic.
2024-08-22 11:07:07 -07:00
Wez Furlong b7754fe509 smtp server: add histograms around reading and processing data 2024-08-20 11:06:52 -07:00