From 2c4f86504b01d817e50abee39272d141bf114578 Mon Sep 17 00:00:00 2001 From: Bennet Gallein Date: Mon, 9 Sep 2024 15:20:50 +0200 Subject: [PATCH 1/3] feat: add zone label to zonemta_delivery_status prometheus --- README.md | 2 +- lib/queue-server.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 75a1825..4bd354f 100644 --- a/README.md +++ b/README.md @@ -527,7 +527,7 @@ The exposed metrics include a lot of different data but the most important ones ##### zonemta_delivery_status -`zonemta_delivery_status` exposes counters for delivery statuses. There are 3 different `result` label values +`zonemta_delivery_status` exposes counters for delivery statuses. There are 3 different `result` label values. The zone name is exposed in the `zone` label. - `result="delivered"` – count of deliveries accepted by remote MX - `result="rejected"` – count of deliveries that hard bounced diff --git a/lib/queue-server.js b/lib/queue-server.js index 016d924..f441297 100644 --- a/lib/queue-server.js +++ b/lib/queue-server.js @@ -13,7 +13,7 @@ const promClient = require('prom-client'); const deliveryStatusCounter = new promClient.Counter({ name: 'zonemta_delivery_status', help: 'Delivery status', - labelNames: ['status'] + labelNames: ['status', 'zone'] }); const messagePushCounter = new promClient.Counter({ name: 'zonemta_message_push', @@ -155,7 +155,8 @@ class QueueServer { deliveryStatus = data.status.delivered ? 'delivered' : 'rejected'; } deliveryStatusCounter.inc({ - status: deliveryStatus + status: deliveryStatus, + zone: client.zone.name }); return this.releaseDelivery(client.zone, client.id, data, (err, response) => { if (!client) { @@ -188,7 +189,8 @@ class QueueServer { }); } deliveryStatusCounter.inc({ - status: 'deferred' + status: 'deferred', + zone: client.zone.name }); return this.deferDelivery(client.zone, client.id, data, (err, response) => { From a37cb7013dd0418f9146e537841ce885087f079c Mon Sep 17 00:00:00 2001 From: Bennet Gallein Date: Mon, 9 Sep 2024 15:23:18 +0200 Subject: [PATCH 2/3] feat: add zone to other metrics --- lib/queue-server.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/queue-server.js b/lib/queue-server.js index f441297..b1f2661 100644 --- a/lib/queue-server.js +++ b/lib/queue-server.js @@ -18,15 +18,17 @@ const deliveryStatusCounter = new promClient.Counter({ const messagePushCounter = new promClient.Counter({ name: 'zonemta_message_push', help: 'Messages pushed to queue', - labelNames: ['result'] + labelNames: ['result', 'zone'] }); const bounceCounter = new promClient.Counter({ name: 'zonemta_bounce_generation', - help: 'Bounce generation' + help: 'Bounce generation', + labelNames: ['zone'] }); const dropCounter = new promClient.Counter({ name: 'zonemta_message_drop', - help: 'Messages dropped' + help: 'Messages dropped', + labelNames: ['zone'] }); const promMetrics = { @@ -213,7 +215,9 @@ class QueueServer { case 'BOUNCE': { - bounceCounter.inc(); + bounceCounter.inc({ + zone: client.zone.name + }); const bounce = data; bounce.headers = new Headers(bounce.headers || []); plugins.handler.runHooks( @@ -230,7 +234,9 @@ class QueueServer { break; case 'REMOVE': - dropCounter.inc(); + dropCounter.inc({ + zone: client.zone.name + }); this.queue.removeMessage(data.id, err => { if (!client) { // client already errored or closed @@ -290,7 +296,8 @@ class QueueServer { case 'PUSH': this.queue.push(data.id, data.envelope, err => { messagePushCounter.inc({ - result: err ? 'fail' : 'success' + result: err ? 'fail' : 'success', + zone: client.zone.name }); if (!client) { // client already errored or closed From 618ccaca144eafd57aaf4f6b7078e48abbcfb13c Mon Sep 17 00:00:00 2001 From: Bennet Gallein Date: Mon, 9 Sep 2024 15:28:40 +0200 Subject: [PATCH 3/3] Revert "feat: add zone to other metrics" This reverts commit a37cb7013dd0418f9146e537841ce885087f079c. --- lib/queue-server.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/queue-server.js b/lib/queue-server.js index b1f2661..f441297 100644 --- a/lib/queue-server.js +++ b/lib/queue-server.js @@ -18,17 +18,15 @@ const deliveryStatusCounter = new promClient.Counter({ const messagePushCounter = new promClient.Counter({ name: 'zonemta_message_push', help: 'Messages pushed to queue', - labelNames: ['result', 'zone'] + labelNames: ['result'] }); const bounceCounter = new promClient.Counter({ name: 'zonemta_bounce_generation', - help: 'Bounce generation', - labelNames: ['zone'] + help: 'Bounce generation' }); const dropCounter = new promClient.Counter({ name: 'zonemta_message_drop', - help: 'Messages dropped', - labelNames: ['zone'] + help: 'Messages dropped' }); const promMetrics = { @@ -215,9 +213,7 @@ class QueueServer { case 'BOUNCE': { - bounceCounter.inc({ - zone: client.zone.name - }); + bounceCounter.inc(); const bounce = data; bounce.headers = new Headers(bounce.headers || []); plugins.handler.runHooks( @@ -234,9 +230,7 @@ class QueueServer { break; case 'REMOVE': - dropCounter.inc({ - zone: client.zone.name - }); + dropCounter.inc(); this.queue.removeMessage(data.id, err => { if (!client) { // client already errored or closed @@ -296,8 +290,7 @@ class QueueServer { case 'PUSH': this.queue.push(data.id, data.envelope, err => { messagePushCounter.inc({ - result: err ? 'fail' : 'success', - zone: client.zone.name + result: err ? 'fail' : 'success' }); if (!client) { // client already errored or closed