mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-11-06 17:04:08 +01:00
Add option to disable statistic collection per endpoint
This commit is contained in:
@@ -361,7 +361,7 @@ func (router *Router) logRequest(r *http.Request, succ bool, statusCode int, for
|
||||
// in that case we will log it by default and will not enter this routine
|
||||
return
|
||||
}
|
||||
if router.Option.StatisticCollector != nil {
|
||||
if router.Option.StatisticCollector != nil && !endpoint.DisableStatisticCollection {
|
||||
go func() {
|
||||
requestInfo := statistic.RequestInfo{
|
||||
IpAddr: netutils.GetRequesterIP(r),
|
||||
@@ -377,6 +377,7 @@ func (router *Router) logRequest(r *http.Request, succ bool, statusCode int, for
|
||||
}
|
||||
router.Option.StatisticCollector.RecordRequest(requestInfo)
|
||||
}()
|
||||
|
||||
}
|
||||
router.Option.Logger.LogHTTPRequest(r, forwardType, statusCode, originalHostname, upstreamHostname)
|
||||
}
|
||||
|
||||
@@ -207,8 +207,9 @@ type ProxyEndpoint struct {
|
||||
RateLimit int64 // Rate limit in requests per second
|
||||
|
||||
//Uptime Monitor
|
||||
DisableUptimeMonitor bool //Disable uptime monitor for this endpoint
|
||||
DisableLogging bool //Disable logging of reverse proxy requests
|
||||
DisableUptimeMonitor bool //Disable uptime monitor for this endpoint
|
||||
DisableLogging bool //Disable logging of reverse proxy requests
|
||||
DisableStatisticCollection bool //Disable statistic collection for this endpoint
|
||||
|
||||
// Chunked Transfer Encoding
|
||||
DisableChunkedTransferEncoding bool //Disable chunked transfer encoding for this endpoint
|
||||
|
||||
@@ -577,6 +577,9 @@ func ReverseProxyHandleEditEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||
// Disable logging
|
||||
disableLogging, _ := utils.PostBool(r, "dLogging")
|
||||
|
||||
// Disable statistic collection
|
||||
disableStatisticCollection, _ := utils.PostBool(r, "dStatisticCollection")
|
||||
|
||||
//Load the previous basic auth credentials from current proxy rules
|
||||
targetProxyEntry, err := dynamicProxyRouter.LoadProxy(rootNameOrMatchingDomain)
|
||||
if err != nil {
|
||||
@@ -619,6 +622,7 @@ func ReverseProxyHandleEditEndpoint(w http.ResponseWriter, r *http.Request) {
|
||||
newProxyEndpoint.DisableUptimeMonitor = disbleUtm
|
||||
newProxyEndpoint.DisableChunkedTransferEncoding = disableChunkedEncoding
|
||||
newProxyEndpoint.DisableLogging = disableLogging
|
||||
newProxyEndpoint.DisableStatisticCollection = disableStatisticCollection
|
||||
newProxyEndpoint.Tags = tags
|
||||
|
||||
//Prepare to replace the current routing rule
|
||||
|
||||
@@ -290,6 +290,13 @@
|
||||
<label>Disable Requests Logging<br>
|
||||
<small>Disable logging for all incoming requests for this hostname</small></label>
|
||||
</div>
|
||||
<br>
|
||||
<div class="ui checkbox" style="margin-top: 0.4em;">
|
||||
<input type="checkbox" class="DisableStatisticCollection">
|
||||
<label>Disable Statistic Collection<br>
|
||||
<small>Disable collecting statistics for this hostname but keep request logging</small></label>
|
||||
</div>
|
||||
<br>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -892,6 +899,7 @@
|
||||
let bypassGlobalTLS = $(editor).find(".BypassGlobalTLS")[0].checked;
|
||||
let disableChunkedTransferEncoding = $(editor).find(".DisableChunkedTransferEncoding")[0].checked;
|
||||
let disableLogging = $(editor).find(".DisableLogging")[0].checked;
|
||||
let disableStatisticCollection = $(editor).find(".DisableStatisticCollection")[0].checked;
|
||||
let tags = getTagsArrayFromEndpoint(uuid);
|
||||
if (tags.length > 0){
|
||||
tags = tags.join(",");
|
||||
@@ -909,6 +917,7 @@
|
||||
"rate" :requireRateLimit,
|
||||
"dChunkedEnc": disableChunkedTransferEncoding,
|
||||
"dLogging": disableLogging,
|
||||
"dStatisticCollection": disableStatisticCollection,
|
||||
"ratenum" :rateLimit,
|
||||
"tags": tags,
|
||||
};
|
||||
@@ -1250,8 +1259,25 @@
|
||||
editor.find(".DisableLogging").off('change');
|
||||
editor.find(".DisableLogging").prop("checked", subd.DisableLogging);
|
||||
editor.find(".DisableLogging").on("change", function() {
|
||||
// When logging is disabled, also disable statistic collection
|
||||
if ($(this).is(':checked')) {
|
||||
editor.find(".DisableStatisticCollection").prop("checked", true).prop("disabled", true);
|
||||
} else {
|
||||
editor.find(".DisableStatisticCollection").prop("disabled", false);
|
||||
}
|
||||
saveProxyInlineEdit(uuid);
|
||||
});
|
||||
|
||||
editor.find(".DisableStatisticCollection").off('change');
|
||||
editor.find(".DisableStatisticCollection").prop("checked", subd.DisableStatisticCollection);
|
||||
editor.find(".DisableStatisticCollection").on("change", function() {
|
||||
saveProxyInlineEdit(uuid);
|
||||
});
|
||||
|
||||
// Handle initial state: if logging is disabled, disable statistic collection
|
||||
if (subd.DisableLogging) {
|
||||
editor.find(".DisableStatisticCollection").prop("checked", true).prop("disabled", true);
|
||||
}
|
||||
|
||||
//Bind the edit button
|
||||
editor.find(".downstream_primary_hostname_edit_btn").off("click").on("click", function(){
|
||||
|
||||
Reference in New Issue
Block a user