]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/smb_prometheus_endpoint: add authentication metrics
authorRalph Boehme <slow@samba.org>
Mon, 5 Feb 2024 17:19:31 +0000 (18:19 +0100)
committerGünther Deschner <gd@samba.org>
Fri, 11 Apr 2025 18:46:41 +0000 (18:46 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
source3/utils/smb_prometheus_endpoint.c

index 3959a8511cc566c52560d65c2c9a3c672fd262ec..138fd53f8687653f2a10e399ab4b01dcca065ee7 100644 (file)
@@ -26,6 +26,8 @@
 
 struct export_state {
        struct evbuffer *buf;
+       bool sent_help_authentication : 1;
+       bool sent_help_authentication_failed : 1;
        bool sent_help_cpu_seconds : 1;
        bool sent_help_smb1_request_total : 1;
        bool sent_help_smb2_request_inbytes : 1;
@@ -38,7 +40,41 @@ static void export_count(const char *name,
                         const struct smbprofile_stats_count *val,
                         struct export_state *state)
 {
-       return;
+       int cmp;
+
+       cmp = strcmp(name, "authentication");
+       if (cmp == 0) {
+               if (!state->sent_help_authentication) {
+                       evbuffer_add_printf(
+                               state->buf,
+                               "# HELP smb_authentications Total number "
+                               "of authentication requests\n"
+                               "# TYPE smb_authentications counter\n");
+                       state->sent_help_authentication = true;
+               }
+
+               evbuffer_add_printf(
+                       state->buf,
+                       "smb_authentications %" PRIu64"\n",
+                       val->count);
+       }
+
+       cmp = strcmp(name, "authentication_failed");
+       if (cmp == 0) {
+               if (!state->sent_help_authentication_failed) {
+                       evbuffer_add_printf(
+                               state->buf,
+                               "# HELP smb_authentications_failed Total "
+                               "number of failed authentication requests\n"
+                               "# TYPE smb_authentications_failed counter\n");
+                       state->sent_help_authentication_failed = true;
+               }
+
+               evbuffer_add_printf(
+                       state->buf,
+                       "smb_authentications_failed %" PRIu64"\n",
+                       val->count);
+       }
 }
 
 static void export_time(const char *name,