Initial commit (code only without large binaries)

This commit is contained in:
robin
2026-02-15 18:58:44 +08:00
commit 35df75498f
9442 changed files with 1495866 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
{$layout}
{$template "/datepicker"}
<first-menu>
<menu-item :href="path + '?' + query('')" :active="hasError == 0 && hasWAF == 0">所有日志</menu-item>
<menu-item :href="path + '?' + query('hasError=1')" :active="hasError > 0">错误日志</menu-item>
<menu-item :href="path + '?' + query('hasWAF=1')" :active="hasWAF > 0">WAF日志</menu-item>
<span class="item disabled">|</span>
<menu-item :href="'/servers/logs/settings'" code="settings">设置</menu-item>
</first-menu>
<form method="get" class="ui form small" :action="path">
<input type="hidden" name="serverId" :value="serverId"/>
<input type="hidden" name="hasError" :value="hasError"/>
<input type="hidden" name="hasWAF" :value="hasWAF"/>
<http-access-log-search-box :v-cluster-id="clusterId" :v-node-id="nodeId" :v-ip="ip" :v-domain="domain" :v-keyword="keyword">
<div class="ui field">
<div class="ui right labeled input">
<input type="text" name="day" maxlength="10" placeholder="选择日期" style="width:7.8em" id="day-input" v-model="day"/>
<span class="ui label"></span>
</div>
</div>
<div class="ui field">
<div class="ui right labeled input">
<input type="text" name="hour" maxlength="2" style="width: 3.5em" v-model="hour"/>
<span class="ui label"></span>
</div>
</div>
</http-access-log-search-box>
</form>
<http-access-log-partitions-box :v-partition="partition" :v-day="day" :v-query="currentQuery"></http-access-log-partitions-box>
<warning-message v-if="isSlowQuery">看起来你的访问日志查询非常慢({{slowQueryCost}}s建议<span v-if="domain.length == 0"> 1指定具体域名查询2</span>通过添加新的 <a href="/db">[日志节点]</a> 来分散存储访问日志。</warning-message>
<p class="comment" v-if="accessLogs.length == 0">暂时还没有访问日志。</p>
<table class="ui table selectable" v-if="accessLogs.length > 0">
<!-- 这里之所以需要添加 :key是因为要不然不会刷新显示 -->
<tr v-for="accessLog in accessLogs" :key="accessLog.requestId">
<td><http-access-log-box :v-access-log="accessLog" :v-keyword="keyword" :v-show-server-link="true"></http-access-log-box></td>
</tr>
</table>
<div v-if="accessLogs.length > 0">
<a :href="path + '?' + query('requestId=' + lastRequestId + '&hasError=' + hasError + '&hasWAF=' + hasWAF + '&partition=' + partition)" v-if="hasPrev">上一页</a>
<span v-else class="disabled">上一页</span>
<span class="disabled">&nbsp; | &nbsp;</span>
<a :href="path + '?' + query('requestId=' + nextRequestId + '&hasError=' + hasError + '&hasWAF=' + hasWAF + '&partition=' + partition)" v-if="hasMore">下一页</a>
<span v-else class="disabled">下一页</span>
<page-size-selector></page-size-selector>
</div>

View File

@@ -0,0 +1,78 @@
Tea.context(function () {
this.$delay(function () {
let that = this
teaweb.datepicker("day-input", function (day) {
that.day = day
})
})
let that = this
this.accessLogs.forEach(function (accessLog) {
if (typeof (that.regions[accessLog.remoteAddr]) == "string") {
accessLog.region = that.regions[accessLog.remoteAddr]
} else {
accessLog.region = ""
}
if (accessLog.firewallRuleSetId > 0 && typeof (that.wafInfos[accessLog.firewallRuleSetId]) == "object") {
accessLog.wafInfo = that.wafInfos[accessLog.firewallRuleSetId]
} else {
accessLog.wafInfo = null
}
})
this.query = function (args) {
// 初始化时页面尚未设置Vue变量所以使用全局的变量获取
let that = TEA.ACTION.data
if (that.clusterId == null) {
that.clusterId = 0
}
if (that.nodeId == null) {
that.nodeId = 0
}
if (that.serverId == null) {
that.serverId = 0
}
if (that.day == null) {
that.day = ""
}
if (that.keyword == null) {
that.keyword = ""
}
if (that.ip == null) {
that.ip = ""
}
if (that.domain == null) {
that.domain = ""
}
if (that.hour == null) {
that.hour = ""
}
if (that.pageSize == null) {
that.pageSize = 0
}
let query = 'clusterId=' + that.clusterId + '&nodeId=' + that.nodeId + '&serverId=' + that.serverId + '&day=' + that.day + '&keyword=' + encodeURIComponent(that.keyword) + '&ip=' + that.ip + '&domain=' + that.domain + '&hour=' + that.hour + '&pageSize=' + that.pageSize
if (args != null && args.length > 0) {
query += "&" + args
}
return query
}
this.allQuery = function () {
if (this.query == null) {
// 尚未初始化完成
return
}
let query = this.query()
if (this.hasError == 1) {
query += "&hasError=1"
}
if (this.hasWAF == 1) {
query += "&hasWAF=1"
}
return query
}
this.currentQuery = this.allQuery()
})

View File

@@ -0,0 +1,65 @@
{$layout}
<first-menu>
<menu-item :href="'/servers/logs'">所有日志</menu-item>
<menu-item :href="'/servers/logs?hasError=1'">错误日志</menu-item>
<menu-item :href="'/servers/logs?hasWAF=1'">WAF日志</menu-item>
<span class="item disabled">|</span>
<menu-item :href="'/servers/logs/settings'" code="settings">设置</menu-item>
</first-menu>
<div class="margin"></div>
<form class="ui form" data-tea-action="$" data-tea-success="success">
<csrf-token></csrf-token>
<h3>存储队列设置</h3>
<table class="ui table definition selectable">
<tr>
<td class="title">采样率</td>
<td>
<div class="ui input right labeled">
<input type="text" name="percent" v-model="config.percent" size="3" maxlength="3" style="width: 4em"/>
<span class="ui label">%</span>
</div>
<p class="comment">表示将写入{{config.percent}}%的访问日志数据此设置不影响WAF相关日志。</p>
</td>
</tr>
<tr>
<td>写入速度</td>
<td>
<div class="ui input right labeled">
<input type="text" name="countPerSecond" v-model="config.countPerSecond" size="6" maxlength="6" style="width: 6em"/>
<span class="ui label">条/秒</span>
</div>
<p class="comment">单个API节点每秒写入的访问日志数量0表示不限制。</p>
</td>
</tr>
<tr>
<td>队列长度</td>
<td>
<input type="text" name="maxLength" v-model="config.maxLength" size="6" maxlength="6" style="width: 6em"/>
<p class="comment">等待写入的队列最大长度超出此长度的访问日志将被丢弃0表示不限制。</p>
</td>
</tr>
</table>
<h3>自动分表设置</h3>
<table class="ui table definition selectable">
<tr>
<td class="title">启用自动分表</td>
<td>
<checkbox name="enableAutoPartial" v-model="config.enableAutoPartial"></checkbox>
<p class="comment">启用后,可以将单天访问日志自动存储到多个数据表中,以提升查询速度。</p>
</td>
</tr>
<tr v-show="config.enableAutoPartial">
<td>单表最多行数</td>
<td>
<input type="text" style="width: 8em" name="rowsPerTable" v-model="config.rowsPerTable" maxlength="16"/>
<p class="comment">单个数据表最多能存储的最多行数。</p>
</td>
</tr>
</table>
<submit-btn></submit-btn>
</form>

View File

@@ -0,0 +1,3 @@
Tea.context(function () {
this.success = NotifyReloadSuccess("保存成功,将会在一分钟之内生效")
})