diff --git a/imap/http_admin.c b/imap/http_admin.c index d7456fa43f..330b661d46 100644 --- a/imap/http_admin.c +++ b/imap/http_admin.c @@ -91,7 +91,7 @@ static int action_conf(struct transaction_t *txn); /* Namespace for admin service */ struct namespace_t namespace_admin = { - URL_NS_ADMIN, 1, "/admin", NULL, + URL_NS_ADMIN, 1, "admin", "/admin", NULL, http_allow_noauth_get, /*authschemes*/0, /*mbtype*/0, ALLOW_READ, diff --git a/imap/http_applepush.c b/imap/http_applepush.c index e0fd0783f9..432e07afd3 100644 --- a/imap/http_applepush.c +++ b/imap/http_applepush.c @@ -57,7 +57,7 @@ static int meth_get_applepush(struct transaction_t *txn, void *params); static int meth_post_applepush(struct transaction_t *txn, void *params); struct namespace_t namespace_applepush = { - URL_NS_APPLEPUSH, /*enabled*/0, "/applepush/subscribe", NULL, + URL_NS_APPLEPUSH, /*enabled*/0, "applepush", "/applepush/subscribe", NULL, http_allow_noauth_get, /*authschemes*/0, /*mbtype*/0, ALLOW_READ|ALLOW_POST, diff --git a/imap/http_caldav.c b/imap/http_caldav.c index 9918d34436..92882ef189 100644 --- a/imap/http_caldav.c +++ b/imap/http_caldav.c @@ -518,7 +518,7 @@ static struct meth_params caldav_params = { /* Namespace for CalDAV collections */ struct namespace_t namespace_calendar = { - URL_NS_CALENDAR, 0, "/dav/calendars", "/.well-known/caldav", + URL_NS_CALENDAR, 0, "calendar", "/dav/calendars", "/.well-known/caldav", http_allow_noauth_get, /*authschemes*/0, MBTYPE_CALENDAR, (ALLOW_READ | ALLOW_POST | ALLOW_WRITE | ALLOW_DELETE | @@ -558,7 +558,7 @@ struct namespace_t namespace_calendar = { /* Namespace for Freebusy Read URL */ struct namespace_t namespace_freebusy = { - URL_NS_FREEBUSY, 0, "/freebusy", NULL, + URL_NS_FREEBUSY, 0, "freebusy", "/freebusy", NULL, http_allow_noauth_get, /*authschemes*/0, MBTYPE_CALENDAR, ALLOW_READ, diff --git a/imap/http_carddav.c b/imap/http_carddav.c index 1966cb4853..b2d4c91ff8 100644 --- a/imap/http_carddav.c +++ b/imap/http_carddav.c @@ -304,7 +304,7 @@ static struct meth_params carddav_params = { /* Namespace for Carddav collections */ struct namespace_t namespace_addressbook = { - URL_NS_ADDRESSBOOK, 0, "/dav/addressbooks", "/.well-known/carddav", + URL_NS_ADDRESSBOOK, 0, "addressbook", "/dav/addressbooks", "/.well-known/carddav", http_allow_noauth_get, /*authschemes*/0, MBTYPE_ADDRESSBOOK, (ALLOW_READ | ALLOW_POST | ALLOW_WRITE | ALLOW_DELETE | diff --git a/imap/http_dav.c b/imap/http_dav.c index 3cb549e3a5..8fe2a97a8b 100644 --- a/imap/http_dav.c +++ b/imap/http_dav.c @@ -271,7 +271,7 @@ static struct meth_params princ_params = { /* Namespace for WebDAV principals */ struct namespace_t namespace_principal = { - URL_NS_PRINCIPAL, 0, "/dav/principals", NULL, + URL_NS_PRINCIPAL, 0, "principal", "/dav/principals", NULL, http_allow_noauth_get, /*authschemes*/0, /*mbtype */ 0, ALLOW_READ | ALLOW_DAV, @@ -8930,7 +8930,7 @@ struct meth_params notify_params = { /* Namespace for WebDAV notification collections */ struct namespace_t namespace_notify = { - URL_NS_NOTIFY, 0, "/dav/notifications", NULL, + URL_NS_NOTIFY, 0, "notify", "/dav/notifications", NULL, http_allow_noauth_get, /*authschemes*/0, MBTYPE_COLLECTION, (ALLOW_READ | ALLOW_POST | ALLOW_DELETE | diff --git a/imap/http_dblookup.c b/imap/http_dblookup.c index 71a0f43e25..fb916a745c 100644 --- a/imap/http_dblookup.c +++ b/imap/http_dblookup.c @@ -56,7 +56,7 @@ static int meth_get_db(struct transaction_t *txn, void *params); /* Namespace for DB lookups */ struct namespace_t namespace_dblookup = { - URL_NS_DBLOOKUP, /*enabled*/1, "/dblookup", NULL, + URL_NS_DBLOOKUP, /*enabled*/1, "dblookup", "/dblookup", NULL, http_allow_noauth, /*authschemes*/0, /*mbtype*/0, ALLOW_READ, diff --git a/imap/http_ischedule.c b/imap/http_ischedule.c index f63f263ecb..1246a7161b 100644 --- a/imap/http_ischedule.c +++ b/imap/http_ischedule.c @@ -116,7 +116,7 @@ static struct mime_type_t isched_mime_types[] = { }; struct namespace_t namespace_ischedule = { - URL_NS_ISCHEDULE, 0, "/ischedule", ISCHED_WELLKNOWN_URI, + URL_NS_ISCHEDULE, 0, "ischedule", "/ischedule", ISCHED_WELLKNOWN_URI, http_allow_noauth, /*authschemes*/0, /*mbtype*/0, (ALLOW_READ | ALLOW_POST | ALLOW_ISCHEDULE), @@ -146,7 +146,7 @@ struct namespace_t namespace_ischedule = { }; struct namespace_t namespace_domainkey = { - URL_NS_DOMAINKEY, 0, "/domainkeys", "/.well-known/domainkey", + URL_NS_DOMAINKEY, 0, "domainkey", "/domainkeys", "/.well-known/domainkey", http_allow_noauth, /*authschemes*/0, /*mbtype*/0, ALLOW_READ, diff --git a/imap/http_jmap.c b/imap/http_jmap.c index d26e81d41f..f822503cf5 100644 --- a/imap/http_jmap.c +++ b/imap/http_jmap.c @@ -103,7 +103,7 @@ static int myrights_byname(struct auth_state *authstate, /* Namespace for JMAP */ struct namespace_t namespace_jmap = { - URL_NS_JMAP, 0, "/jmap", "/.well-known/jmap", + URL_NS_JMAP, 0, "jmap", "/jmap", "/.well-known/jmap", jmap_checkurl, 1 << AUTH_BEARER, /*mbtype*/0, (ALLOW_READ | ALLOW_POST), diff --git a/imap/http_prometheus.c b/imap/http_prometheus.c index ccd1d1474d..2a0425da2f 100644 --- a/imap/http_prometheus.c +++ b/imap/http_prometheus.c @@ -57,6 +57,7 @@ static int prom_get(struct transaction_t *txn, void *params); struct namespace_t namespace_prometheus = { URL_NS_PROMETHEUS, /*enabled*/ 0, + "prometheus", "/metrics", /* XXX .well-known url*/ NULL, prom_need_auth, diff --git a/imap/http_rss.c b/imap/http_rss.c index 896bdf7583..7328a54010 100644 --- a/imap/http_rss.c +++ b/imap/http_rss.c @@ -108,7 +108,7 @@ static struct body *body_fetch_section(struct body *body, const char *section); /* Namespace for RSS feeds of mailboxes */ struct namespace_t namespace_rss = { - URL_NS_RSS, 0, "/rss", NULL, + URL_NS_RSS, 0, "rss", "/rss", NULL, http_allow_noauth_get, /*authschemes*/0, /*mbtype*/0, ALLOW_READ, diff --git a/imap/http_tzdist.c b/imap/http_tzdist.c index 74c0dd2ac8..66bc60d401 100644 --- a/imap/http_tzdist.c +++ b/imap/http_tzdist.c @@ -138,7 +138,7 @@ static struct mime_type_t tz_mime_types[] = { /* Namespace for tzdist service */ struct namespace_t namespace_tzdist = { - URL_NS_TZDIST, 0, "/tzdist", TZDIST_WELLKNOWN_URI, + URL_NS_TZDIST, 0, "tzdist", "/tzdist", TZDIST_WELLKNOWN_URI, http_allow_noauth, /*authschemes*/0, /*mbtype*/0, ALLOW_READ, diff --git a/imap/http_webdav.c b/imap/http_webdav.c index 20e42d2563..46039c96ad 100644 --- a/imap/http_webdav.c +++ b/imap/http_webdav.c @@ -229,7 +229,7 @@ struct meth_params webdav_params = { /* Namespace for Webdav collections */ struct namespace_t namespace_drive = { - URL_NS_DRIVE, 0, "/dav/drive", NULL, + URL_NS_DRIVE, 0, "drive", "/dav/drive", NULL, http_allow_noauth_get, /*authschemes*/0, MBTYPE_COLLECTION, (ALLOW_READ | ALLOW_POST | ALLOW_WRITE | ALLOW_DELETE | diff --git a/imap/httpd.c b/imap/httpd.c index face66eae5..39c148acd4 100644 --- a/imap/httpd.c +++ b/imap/httpd.c @@ -574,6 +574,9 @@ static int http2_frame_recv_cb(nghttp2_session *session, &txn->req_tgt.namespace->methods[txn->meth]; ret = (*meth_t->proc)(txn, meth_t->params); + + prometheus_increment(prometheus_lookup_label(http_methods[txn->meth].metric, + txn->req_tgt.namespace->name)); } if (ret == HTTP_UNAUTHORIZED) { @@ -1110,32 +1113,32 @@ static struct sasl_callback mysasl_cb[] = { /* Array of HTTP methods known by our server. */ const struct known_meth_t http_methods[] = { - { "ACL", 0 }, - { "BIND", 0 }, - { "COPY", METH_NOBODY }, - { "DELETE", METH_NOBODY }, - { "GET", METH_NOBODY }, - { "HEAD", METH_NOBODY }, - { "LOCK", 0 }, - { "MKCALENDAR", 0 }, - { "MKCOL", 0 }, - { "MOVE", METH_NOBODY }, - { "OPTIONS", METH_NOBODY }, - { "PATCH", 0 }, - { "POST", 0 }, - { "PROPFIND", 0 }, - { "PROPPATCH", 0 }, - { "PUT", 0 }, - { "REPORT", 0 }, - { "TRACE", METH_NOBODY }, - { "UNBIND", 0 }, - { "UNLOCK", METH_NOBODY }, - { NULL, 0 } + { "ACL", 0, CYRUS_HTTP_ACL_TOTAL }, + { "BIND", 0, CYRUS_HTTP_BIND_TOTAL }, + { "COPY", METH_NOBODY, CYRUS_HTTP_COPY_TOTAL }, + { "DELETE", METH_NOBODY, CYRUS_HTTP_DELETE_TOTAL }, + { "GET", METH_NOBODY, CYRUS_HTTP_GET_TOTAL }, + { "HEAD", METH_NOBODY, CYRUS_HTTP_HEAD_TOTAL }, + { "LOCK", 0, CYRUS_HTTP_LOCK_TOTAL }, + { "MKCALENDAR", 0, CYRUS_HTTP_MKCALENDAR_TOTAL }, + { "MKCOL", 0, CYRUS_HTTP_MKCOL_TOTAL }, + { "MOVE", METH_NOBODY, CYRUS_HTTP_MOVE_TOTAL }, + { "OPTIONS", METH_NOBODY, CYRUS_HTTP_OPTIONS_TOTAL }, + { "PATCH", 0, CYRUS_HTTP_PATCH_TOTAL }, + { "POST", 0, CYRUS_HTTP_POST_TOTAL }, + { "PROPFIND", 0, CYRUS_HTTP_PROPFIND_TOTAL }, + { "PROPPATCH", 0, CYRUS_HTTP_PROPPATCH_TOTAL }, + { "PUT", 0, CYRUS_HTTP_PUT_TOTAL }, + { "REPORT", 0, CYRUS_HTTP_REPORT_TOTAL }, + { "TRACE", METH_NOBODY, CYRUS_HTTP_TRACE_TOTAL }, + { "UNBIND", 0, CYRUS_HTTP_UNBIND_TOTAL }, + { "UNLOCK", METH_NOBODY, CYRUS_HTTP_UNLOCK_TOTAL }, + { NULL, 0, 0 } }; /* Namespace to fetch static content from filesystem */ struct namespace_t namespace_default = { - URL_NS_DEFAULT, 1, "", NULL, + URL_NS_DEFAULT, 1, "default", "", NULL, http_allow_noauth, /*authschemes*/0, /*mbtype*/0, ALLOW_READ, @@ -2340,6 +2343,9 @@ static int http1_input(struct transaction_t *txn) &txn->req_tgt.namespace->methods[txn->meth]; ret = (*meth_t->proc)(txn, meth_t->params); + + prometheus_increment(prometheus_lookup_label(http_methods[txn->meth].metric, + txn->req_tgt.namespace->name)); } if (ret == HTTP_UNAUTHORIZED) { diff --git a/imap/httpd.h b/imap/httpd.h index 5e27b6a4c2..cabc19f2a2 100644 --- a/imap/httpd.h +++ b/imap/httpd.h @@ -65,6 +65,7 @@ typedef struct { void *value; } nghttp2_nv; #include "hash.h" #include "http_client.h" #include "mailbox.h" +#include "prometheus.h" #include "spool.h" #define MAX_REQ_LINE 8000 /* minimum size per RFC 7230 */ @@ -113,6 +114,7 @@ typedef struct { void *value; } nghttp2_nv; struct known_meth_t { const char *name; unsigned flags; + enum prom_labelled_metric metric; }; extern const struct known_meth_t http_methods[]; @@ -441,6 +443,7 @@ struct method_t { struct namespace_t { unsigned id; /* Namespace identifier */ unsigned enabled; /* Is this namespace enabled? */ + const char *name; /* Text name of this namespace ([A-Z][a-z][0-9]+) */ const char *prefix; /* Prefix of URL path denoting namespace */ const char *well_known; /* Any /.well-known/ URI */ int (*need_auth)(txn_t *); /* Function run prior to unauthorized requests */ diff --git a/imap/promdata.p b/imap/promdata.p index 71df8e0a72..688a46e73d 100644 --- a/imap/promdata.p +++ b/imap/promdata.p @@ -80,3 +80,43 @@ metric counter cyrus_lmtp_sieve_autorespond_sent_total The number of sieve AUTO metric counter cyrus_http_connections_total The total number of HTTP connections metric gauge cyrus_http_active_connections The number of active HTTP connections metric gauge cyrus_http_ready_listeners The number of currently ready HTTP listeners +metric counter cyrus_http_acl_total The total number of HTTP ACLs + label cyrus_http_acl_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_bind_total The total number of HTTP BINDs + label cyrus_http_bind_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_copy_total The total number of HTTP COPYs + label cyrus_http_copy_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_delete_total The total number of HTTP DELETEs + label cyrus_http_delete_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_get_total The total number of HTTP GETs + label cyrus_http_get_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_head_total The total number of HTTP HEADs + label cyrus_http_head_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_lock_total The total number of HTTP LOCKs + label cyrus_http_lock_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_mkcalendar_total The total number of HTTP MKCALENDARs + label cyrus_http_mkcalendar_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_mkcol_total The total number of HTTP MKCOLs + label cyrus_http_mkcol_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_move_total The total number of HTTP MOVEs + label cyrus_http_move_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_options_total The total number of HTTP OPTIONSs + label cyrus_http_options_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_patch_total The total number of HTTP PATCHs + label cyrus_http_patch_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_post_total The total number of HTTP POSTs + label cyrus_http_post_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_propfind_total The total number of HTTP PROPFINDs + label cyrus_http_propfind_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_proppatch_total The total number of HTTP PROPPATCHs + label cyrus_http_proppatch_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_put_total The total number of HTTP PUTs + label cyrus_http_put_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_report_total The total number of HTTP REPORTs + label cyrus_http_report_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_trace_total The total number of HTTP TRACEs + label cyrus_http_trace_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_unbind_total The total number of HTTP UNBINDs + label cyrus_http_unbind_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive +metric counter cyrus_http_unlock_total The total number of HTTP UNLOCKs + label cyrus_http_unlock_total namespace default admin applepush calendar freebusy addressbook principal notify dblookup ischedule domainkeys jmap prometheus rss tzdist drive