Commit Graph

7 Commits (master)

Author SHA1 Message Date
Dustin 9e088c8419 ci: Add Jenkins build pipeline
dustin/mqtt2vl/pipeline/head This commit looks good Details
2025-06-01 19:49:32 -05:00
Dustin 32de3f0fee container: Add container image build script 2025-06-01 19:46:52 -05:00
Dustin 2265470710 Buffer message batches to send to HTTP server
Instead of "relaying" messages from the MQTT subscriber to the HTTP
request via a second channel, we now collect each batch of messages and
serialize them into a buffer.  This makes it possible to retry the HTTP
request if it fails, without losing any data.  Using the `Bytes` data
structure is the most effecient way to do this, as it implements `Clone`
without copying, so each iteration of the retry loop uses the same data
in memory.

Being able to retry failed HTTP requests eliminates the need for the
"preflight" request entirely.
2025-05-01 21:11:50 -05:00
Dustin 58faa88b2d Add metrics for HTTP sender errors 2025-05-01 07:29:22 -05:00
Dustin 3de1b53acd Close HTTP stream after each batch of messages
When Victoria Logs shuts down, it waits several seconds for clients to
disconnect themselves, then forcibly closes the connections to those
that do not.  With the long-running streaming connection, there is no
way for the server to indicate that the client should disconnect itself.
This can cause data loss as messages that are sent during this window
are not consumed by Victoria Logs.

To improve the resilience of the sender, it now uses multiple short
streaming HTTP requests, instead of one long-running request.  The relay
forwards messages from the MQTT subscriber to the sender's stream, then
closes the stream as soon as there is a 100ms delay between messages.
When the stream closes, the sender completes the HTTP request and
proceeds to the next iteration of the loop.  The relay will not create a
new stream until a new message arrives from the MQTT subscriber.

With this approach, when Victoria Logs starts shutting down, there is a
significantly reduced opportunity for data loss.  It is still possible
that messages sent in the request could be lost, if Victoria Logs
accepts the preflight request but not the actual stream.  Addressing
this possibility would be quite a bit more complex, so hopefully it does
not become too much of a problem.
2025-05-01 07:21:13 -05:00
Dustin ec364b8fd3 Implement Prometheus metrics
The `metrics` crate, along with `metrics-exporter-prometheus`, makes it
extremely easy to instrument code with metrics and export them to
Prometheus.  Here, we're adding a few metrics to track how many messages
are being processed and monitor the queue depth.
2025-04-30 21:20:04 -05:00
Dustin 753a0be931 Initial commit 2025-04-29 22:11:10 -05:00