Initial commit (code only without large binaries)
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
<first-menu>
|
||||
<menu-item code="index" href="/servers/accesslogs">策略列表</menu-item>
|
||||
<menu-item @click.prevent="createPolicy">[创建策略]</menu-item>
|
||||
<span class="item disabled">|</span>
|
||||
<span class="item"><tip-icon content="可以利用日志策略将服务的访问日志输出到特定的媒介中。"></tip-icon></span>
|
||||
</first-menu>
|
||||
@@ -0,0 +1,7 @@
|
||||
<first-menu>
|
||||
<menu-item href="/servers/accesslogs">策略列表</menu-item>
|
||||
<span class="item disabled">|</span>
|
||||
<menu-item :href="'policy?policyId=' + policy.id" code="policy">"{{policy.name}}"详情</menu-item>
|
||||
<menu-item :href="'test?policyId=' + policy.id" code="test">测试</menu-item>
|
||||
<menu-item :href="'update?policyId=' + policy.id" code="update">修改</menu-item>
|
||||
</first-menu>
|
||||
256
EdgeAdmin/web/views/@default/servers/accesslogs/createPopup.html
Normal file
256
EdgeAdmin/web/views/@default/servers/accesslogs/createPopup.html
Normal file
@@ -0,0 +1,256 @@
|
||||
{$layout "layout_popup"}
|
||||
|
||||
<h3>创建策略</h3>
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<csrf-token></csrf-token>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">策略名称 *</td>
|
||||
<td>
|
||||
<input type="text" name="name" maxlength="50" ref="focus"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>存储类型 *</td>
|
||||
<td>
|
||||
<select class="ui dropdown auto-width" name="type" v-model="type">
|
||||
<option value="">[选择类型]</option>
|
||||
<option v-for="t in types" :value="t.code">{{t.name}}</option>
|
||||
</select>
|
||||
<p class="comment">可选:文件、文件+MySQL、文件+ClickHouse、文件+MySQL+ClickHouse、ElasticSearch、TCP、Syslog、命令行等。</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- 文件(文件 / 文件+MySQL) -->
|
||||
<tbody v-show="type == 'file' || type == 'file_mysql'">
|
||||
<tr>
|
||||
<td>日志文件路径 *</td>
|
||||
<td>
|
||||
<input type="text" name="filePath"/>
|
||||
<p class="comment">
|
||||
存储日志的文件路径,文件名中支持变量:
|
||||
<span class="ui label tiny basic">年:${year}</span>
|
||||
<span class="ui label tiny basic">月:${month}</span>
|
||||
<span class="ui label tiny basic">周:${week}</span>
|
||||
<span class="ui label tiny basic">日:${day}</span>
|
||||
<span class="ui label tiny basic">时:${hour}</span>
|
||||
<span class="ui label tiny basic">分:${minute}</span>
|
||||
<span class="ui label tiny basic">秒:${second}</span>
|
||||
<span class="ui label tiny basic">年月日:${date}</span>,比如<span class="ui label tiny basic">/var/log/web-access-${date}.log</span>。
|
||||
<span v-if="type == 'file_clickhouse' || type == 'file_mysql_clickhouse'">当存储类型包含 ClickHouse 时,此文件会在节点侧写入,并由 Fluent Bit 采集后写入 ClickHouse。</span>
|
||||
<span v-else>此文件会在API节点上写入。</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>自动创建目录</td>
|
||||
<td>
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" name="fileAutoCreate" value="1" checked="checked"/>
|
||||
<label></label>
|
||||
</div>
|
||||
<p class="comment">选中后,如果文件目录不存在时可以自动创建。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<!-- 文件+ClickHouse / 文件+MySQL+ClickHouse -->
|
||||
<tbody v-show="type == 'file_clickhouse' || type == 'file_mysql_clickhouse'">
|
||||
<tr>
|
||||
<td>日志文件路径</td>
|
||||
<td>
|
||||
<p class="comment">当前类型包含 ClickHouse,日志文件路径将由节点侧按公用策略自动复用,或回退到默认日志目录,无需手动输入。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<!-- Elastic Search -->
|
||||
<tbody v-show="type == 'es'">
|
||||
<tr>
|
||||
<td>Endpoint *</td>
|
||||
<td>
|
||||
<input type="text" name="esEndpoint"/>
|
||||
<p class="comment">ES HTTP接口地址,类似于192.168.1.100:9200,需要能够被API节点访问。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Index *</td>
|
||||
<td>
|
||||
<input type="text" name="esIndex"/>
|
||||
<p class="comment">Index名称,支持变量:
|
||||
<span class="ui label tiny basic">年:${year}</span>
|
||||
<span class="ui label tiny basic">月:${month}</span>
|
||||
<span class="ui label tiny basic">周:${week}</span>
|
||||
<span class="ui label tiny basic">日:${day}</span>
|
||||
<span class="ui label tiny basic">时:${hour}</span>
|
||||
<span class="ui label tiny basic">分:${minute}</span>
|
||||
<span class="ui label tiny basic">秒:${second}</span>
|
||||
<span class="ui label tiny basic">年月日:${date}</span></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>数据流模式</td>
|
||||
<td>
|
||||
<checkbox name="esIsDataStream" v-model="esIsDataStream"></checkbox>
|
||||
<p class="comment">适用于索引是数据流(Data Stream)的场景,时间字段为<code-label>timeISO8601</code-label>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-show="!esIsDataStream">
|
||||
<td>Mapping Type *</td>
|
||||
<td>
|
||||
<input type="text" name="esMappingType"/>
|
||||
<p class="comment">Mapping名称,支持变量:
|
||||
<span class="ui label tiny basic">年:${year}</span>
|
||||
<span class="ui label tiny basic">月:${month}</span>
|
||||
<span class="ui label tiny basic">周:${week}</span>
|
||||
<span class="ui label tiny basic">日:${day}</span>
|
||||
<span class="ui label tiny basic">时:${hour}</span>
|
||||
<span class="ui label tiny basic">分:${minute}</span>
|
||||
<span class="ui label tiny basic">秒:${second}</span>
|
||||
<span class="ui label tiny basic">年月日:${date}</span></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>认证用户名</td>
|
||||
<td>
|
||||
<input type="text" name="esUsername"/>
|
||||
<p class="comment">配置了认证后才需要填写。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>认证密码</td>
|
||||
<td>
|
||||
<input type="text" name="esPassword"/>
|
||||
<p class="comment">配置了认证后才需要填写。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<!-- TCP Socket -->
|
||||
<tbody v-show="type == 'tcp'">
|
||||
<tr>
|
||||
<td>网络协议 *</td>
|
||||
<td>
|
||||
<select name="tcpNetwork" class="ui dropdown" style="width:10em">
|
||||
<option value="tcp">TCP</option>
|
||||
<option value="unix">Unix Socket</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>网络地址 *</td>
|
||||
<td>
|
||||
<input type="text" name="tcpAddr"/>
|
||||
<p class="comment">接收日志的网络地址,需要能够被API节点访问。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<!-- Syslog -->
|
||||
<tbody v-show="type == 'syslog'">
|
||||
<tr>
|
||||
<td>网络协议</td>
|
||||
<td>
|
||||
<select class="ui dropdown" name="syslogProtocol" v-model="syslogProtocol" style="width:10em">
|
||||
<option value="none">[无]</option>
|
||||
<option value="tcp">TCP</option>
|
||||
<option value="udp">UDP</option>
|
||||
<option value="socket">Unix Socket</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr v-if="syslogProtocol == 'tcp' || syslogProtocol == 'udp'">
|
||||
<td>网络地址 *</td>
|
||||
<td>
|
||||
<input type="text" name="syslogServerAddr"/>
|
||||
<p class="comment">IP地址或主机名,不包括端口,需要能够被API节点访问。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="syslogProtocol == 'tcp' || syslogProtocol == 'udp'">
|
||||
<td>端口</td>
|
||||
<td>
|
||||
<input type="text" name="syslogServerPort"/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr v-if="syslogProtocol == 'socket'">
|
||||
<td>Socket路径 *</td>
|
||||
<td>
|
||||
<input type="text" name="syslogSocket"/>
|
||||
<p class="comment">需要能够被API节点访问。</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>标签<em>(Tag)</em></td>
|
||||
<td>
|
||||
<input type="text" name="syslogTag"/>
|
||||
<p class="comment">选填项。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>优先级<em>(Priority)</em></td>
|
||||
<td>
|
||||
<select class="ui dropdown" name="syslogPriority" style="width:10em">
|
||||
<option v-for="priority in syslogPriorities" :value="priority.value">{{priority.name}}</option>
|
||||
</select>
|
||||
<p class="comment">选填项。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<!-- 命令行输入流 -->
|
||||
<tbody v-show="type == 'command'">
|
||||
<tr>
|
||||
<td>可执行文件 *</td>
|
||||
<td>
|
||||
<input type="text" name="commandCommand"/>
|
||||
<p class="comment">不带参数的可执行文件地址,此命令可执行文件需要部署在API节点上。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>参数</td>
|
||||
<td>
|
||||
<input type="text" name="commandArgs"/>
|
||||
<p class="comment">执行命令需要的参数</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>工作目录</td>
|
||||
<td>
|
||||
<input type="text" name="commandDir"/>
|
||||
<p class="comment">命令执行所在的工作目录</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<tr>
|
||||
<td>公用</td>
|
||||
<td>
|
||||
<checkbox name="isPublic" value="1"></checkbox>
|
||||
<p class="comment"><span class="red">选中后表示自动将此策略应用于所有集群,同时只会有一个公用策略。</span></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2"><more-options-indicator></more-options-indicator></td>
|
||||
</tr>
|
||||
<tbody v-show="moreOptionsVisible">
|
||||
<tr>
|
||||
<td>只记录WAF相关访问日志</td>
|
||||
<td>
|
||||
<checkbox name="firewallOnly"></checkbox>
|
||||
<p class="comment">默认记录所有访问日志;如果选中此项,则表示只记录WAF相关访问日志。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>停用默认数据库存储</td>
|
||||
<td>
|
||||
<checkbox name="disableDefaultDB"></checkbox>
|
||||
<p class="comment">选中后,表示停止将访问日志写入到默认的数据库中。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
@@ -0,0 +1,13 @@
|
||||
Tea.context(function () {
|
||||
this.type = ""
|
||||
|
||||
/**
|
||||
* syslog
|
||||
*/
|
||||
this.syslogProtocol = "none"
|
||||
|
||||
/**
|
||||
* Elastic Search
|
||||
*/
|
||||
this.esIsDataStream = false
|
||||
})
|
||||
33
EdgeAdmin/web/views/@default/servers/accesslogs/index.html
Normal file
33
EdgeAdmin/web/views/@default/servers/accesslogs/index.html
Normal file
@@ -0,0 +1,33 @@
|
||||
{$layout}
|
||||
{$template "menu"}
|
||||
|
||||
<p class="comment" v-if="policies.length == 0">暂时还没有访问日志策略。</p>
|
||||
|
||||
<table class="ui table celled selectable" v-if="policies.length > 0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 14em;">策略名称</th>
|
||||
<th class="op" style="width: 12em; white-space: nowrap;">类型</th>
|
||||
<th class="two wide">状态</th>
|
||||
<th class="two op">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr v-for="policy in policies">
|
||||
<td><a :href="Tea.url('.policy', {policyId: policy.id})">{{policy.name}}</a>
|
||||
<div style="margin-top: 0.3em" v-if="policy.isPublic || policy.firewallOnly">
|
||||
<span class="ui label olive tiny basic" v-if="policy.isPublic">公用</span>
|
||||
<span class="ui label tiny basic" v-if="policy.firewallOnly">只记录WAF</span>
|
||||
<span class="ui label tiny basic" v-if="policy.disableDefaultDB">停用默认数据库</span>
|
||||
</div>
|
||||
</td>
|
||||
<td style="white-space: nowrap;">{{policy.typeName}}</td>
|
||||
<td>
|
||||
<label-on :v-is-on="policy.isOn"></label-on>
|
||||
</td>
|
||||
<td>
|
||||
<a :href="Tea.url('.policy', {policyId: policy.id})">详情</a> <a href="" @click.prevent="deletePolicy(policy.id)">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="page" v-html="page"></div>
|
||||
20
EdgeAdmin/web/views/@default/servers/accesslogs/index.js
Normal file
20
EdgeAdmin/web/views/@default/servers/accesslogs/index.js
Normal file
@@ -0,0 +1,20 @@
|
||||
Tea.context(function () {
|
||||
this.createPolicy = function () {
|
||||
teaweb.popup(Tea.url(".createPopup", {}), {
|
||||
height: "24em",
|
||||
callback: NotifyReloadSuccess("保存成功")
|
||||
})
|
||||
}
|
||||
|
||||
this.deletePolicy = function (policyId) {
|
||||
teaweb.confirm("确定要删除这个日志策略吗?", function () {
|
||||
this.$post(".delete")
|
||||
.params({
|
||||
policyId: policyId
|
||||
})
|
||||
.success(function () {
|
||||
teaweb.successRefresh("保存成功")
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
194
EdgeAdmin/web/views/@default/servers/accesslogs/policy.html
Normal file
194
EdgeAdmin/web/views/@default/servers/accesslogs/policy.html
Normal file
@@ -0,0 +1,194 @@
|
||||
{$layout}
|
||||
{$template "policy_menu"}
|
||||
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">策略名称</td>
|
||||
<td>
|
||||
{{policy.name}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>状态</td>
|
||||
<td>
|
||||
<label-on :v-is-on="policy.isOn"></label-on>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>存储类型</td>
|
||||
<td>
|
||||
{{policy.typeName}}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- 文件 -->
|
||||
<tbody v-if="policy.type == 'file'">
|
||||
<tr>
|
||||
<td>日志文件路径</td>
|
||||
<td>
|
||||
{{policy.options.path}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>自动创建目录</td>
|
||||
<td>
|
||||
<span v-if="policy.options.autoCreate" class="green">Y</span>
|
||||
<span v-else class="disabled">N</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<!-- Elastic Search -->
|
||||
<tbody v-if="policy.type == 'es'">
|
||||
<tr>
|
||||
<td>Endpoint</td>
|
||||
<td>
|
||||
{{policy.options.endpoint}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Index</td>
|
||||
<td>
|
||||
{{policy.options.index}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="policy.options.isDataStream">
|
||||
<td>数据流模式</td>
|
||||
<td>
|
||||
<span class="green">Y</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!policy.options.isDataStream">
|
||||
<td>Mapping Type</td>
|
||||
<td>
|
||||
{{policy.options.mappingType}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>认证用户名</td>
|
||||
<td>
|
||||
<span v-if="policy.options.username.length > 0">{{policy.options.username}}</span>
|
||||
<span v-else class="disabled">没有填写。</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>认证密码</td>
|
||||
<td>
|
||||
<span v-if="policy.options.password.length > 0">{{policy.options.password}}</span>
|
||||
<span v-else class="disabled">没有填写。</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<!-- TCP Socket -->
|
||||
<tbody v-if="policy.type == 'tcp'">
|
||||
<tr>
|
||||
<td>网络协议</td>
|
||||
<td>
|
||||
{{policy.options.network.toUpperCase()}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>网络地址</td>
|
||||
<td>
|
||||
{{policy.options.addr}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<!-- Syslog -->
|
||||
<tbody v-if="policy.type == 'syslog'">
|
||||
<tr>
|
||||
<td>网络协议</td>
|
||||
<td>
|
||||
<span v-if="policy.options.protocol == 'none'" class="disabled">[无]</span>
|
||||
<span v-if="policy.options.protocol == 'tcp'">TCP</span>
|
||||
<span v-if="policy.options.protocol == 'udp'">UDP</span>
|
||||
<span v-if="policy.options.protocol == 'socket'">Unix Socket</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr v-if="policy.options.protocol == 'tcp' || policy.options.protocol == 'udp'">
|
||||
<td>网络地址</td>
|
||||
<td>
|
||||
{{policy.options.serverAddr}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="policy.options.protocol == 'tcp' || policy.options.protocol == 'udp'">
|
||||
<td>端口</td>
|
||||
<td>
|
||||
{{policy.options.serverPort}}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr v-if="policy.options.protocol == 'socket'">
|
||||
<td>Socket路径</td>
|
||||
<td>
|
||||
{{policy.options.socket}}
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>标签<em>(Tag)</em></td>
|
||||
<td>
|
||||
<span v-if="policy.options.tag.length > 0">{{policy.options.tag}}</span>
|
||||
<span v-else class="disabled">没有设置</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>优先级<em>(Priority)</em></td>
|
||||
<td>
|
||||
{{syslogPriorityName}}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<!-- 命令行输入流 -->
|
||||
<tbody v-if="policy.type == 'command'">
|
||||
<tr>
|
||||
<td>可执行命令</td>
|
||||
<td>
|
||||
{{policy.options.command}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>参数</td>
|
||||
<td>
|
||||
<div v-if="policy.options.args != null && policy.options.args.length > 0">
|
||||
<span v-for="arg in policy.options.args" class="ui label basic tiny">{{arg}}</span>
|
||||
</div>
|
||||
<span v-else class="disabled">没有设置参数。</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>工作目录</td>
|
||||
<td>
|
||||
<span v-if="policy.options.dir.length > 0">{{policy.options.dir}}</span>
|
||||
<span v-else class="disabled">没有设置工作目录。</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<tr>
|
||||
<td>公用</td>
|
||||
<td>
|
||||
<span v-if="policy.isPublic" class="green">Y</span>
|
||||
<span v-else class="disabled">N</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>只记录WAF相关访问日志</td>
|
||||
<td>
|
||||
<span v-if="policy.firewallOnly" class="green">Y</span>
|
||||
<span v-else class="disabled">N</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>停用默认数据库存储</td>
|
||||
<td>
|
||||
<span v-if="policy.disableDefaultDB" class="green">Y</span>
|
||||
<span v-else class="disabled">N</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
18
EdgeAdmin/web/views/@default/servers/accesslogs/test.html
Normal file
18
EdgeAdmin/web/views/@default/servers/accesslogs/test.html
Normal file
@@ -0,0 +1,18 @@
|
||||
{$layout "layout"}
|
||||
{$template "/code_editor"}
|
||||
{$template "policy_menu"}
|
||||
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success" data-tea-timeout="30" data-tea-done="done" data-tea-before="before">
|
||||
<input type="hidden" name="policyId" :value="policy.id"/>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">发送内容</td>
|
||||
<td>
|
||||
<source-code-box id="json-data-box" type="application/json" :read-only="false" name="bodyJSON">{$.testJSON}</source-code-box>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn v-if="!isRequesting && policy.isOn"></submit-btn>
|
||||
<p class="comment" v-if="!policy.isOn">当前策略未启用,无法执行测试</p>
|
||||
<button class="ui button disabled" type="button" v-if="isRequesting">发送中...</button>
|
||||
</form>
|
||||
15
EdgeAdmin/web/views/@default/servers/accesslogs/test.js
Normal file
15
EdgeAdmin/web/views/@default/servers/accesslogs/test.js
Normal file
@@ -0,0 +1,15 @@
|
||||
Tea.context(function () {
|
||||
this.isRequesting = false
|
||||
|
||||
this.success = function () {
|
||||
teaweb.successRefresh("发送成功")
|
||||
}
|
||||
|
||||
this.before = function () {
|
||||
this.isRequesting = true
|
||||
}
|
||||
|
||||
this.done = function () {
|
||||
this.isRequesting = false
|
||||
}
|
||||
})
|
||||
261
EdgeAdmin/web/views/@default/servers/accesslogs/update.html
Normal file
261
EdgeAdmin/web/views/@default/servers/accesslogs/update.html
Normal file
@@ -0,0 +1,261 @@
|
||||
{$layout}
|
||||
{$template "policy_menu"}
|
||||
|
||||
<h3>修改策略</h3>
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<csrf-token></csrf-token>
|
||||
<input type="hidden" name="policyId" :value="policy.id"/>
|
||||
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td class="title">策略名称 *</td>
|
||||
<td>
|
||||
<input type="text" name="name" maxlength="50" ref="focus" v-model="policy.name"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>存储类型 *</td>
|
||||
<td>
|
||||
<select class="ui dropdown auto-width" name="type" v-model="policy.typeDisplay">
|
||||
<option v-for="t in types" :value="t.code">{{t.name}}</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- 文件(文件 / 文件+MySQL) -->
|
||||
<tbody v-show="policy.typeDisplay == 'file' || policy.typeDisplay == 'file_mysql'">
|
||||
<tr>
|
||||
<td>日志文件路径 *</td>
|
||||
<td>
|
||||
<input type="text" name="filePath" v-model="policy.options.path"/>
|
||||
<p class="comment">
|
||||
存储日志的文件路径,文件名中支持变量:
|
||||
<span class="ui label tiny basic">年:${year}</span>
|
||||
<span class="ui label tiny basic">月:${month}</span>
|
||||
<span class="ui label tiny basic">周:${week}</span>
|
||||
<span class="ui label tiny basic">日:${day}</span>
|
||||
<span class="ui label tiny basic">时:${hour}</span>
|
||||
<span class="ui label tiny basic">分:${minute}</span>
|
||||
<span class="ui label tiny basic">秒:${second}</span>
|
||||
<span class="ui label tiny basic">年月日:${date}</span>,比如<span class="ui label tiny basic">/var/log/web-access-${date}.log</span>。
|
||||
<span v-if="policy.typeDisplay == 'file_clickhouse' || policy.typeDisplay == 'file_mysql_clickhouse'">当存储类型包含 ClickHouse 时,此文件会在节点侧写入,并由 Fluent Bit 采集后写入 ClickHouse。</span>
|
||||
<span v-else>此文件会在API节点上写入。</span>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>自动创建目录</td>
|
||||
<td>
|
||||
<div class="ui checkbox">
|
||||
<input type="checkbox" name="fileAutoCreate" value="1" v-model="policy.options.autoCreate"/>
|
||||
<label></label>
|
||||
</div>
|
||||
<p class="comment">选中后,如果文件目录不存在时可以自动创建。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<!-- 文件+ClickHouse / 文件+MySQL+ClickHouse -->
|
||||
<tbody v-show="policy.typeDisplay == 'file_clickhouse' || policy.typeDisplay == 'file_mysql_clickhouse'">
|
||||
<tr>
|
||||
<td>日志文件路径</td>
|
||||
<td>
|
||||
<p class="comment">当前类型包含 ClickHouse,日志文件路径将由节点侧按公用策略自动复用,或回退到默认日志目录,无需手动输入。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<!-- Elastic Search -->
|
||||
<tbody v-show="policy.typeDisplay == 'es'">
|
||||
<tr>
|
||||
<td>Endpoint *</td>
|
||||
<td>
|
||||
<input type="text" name="esEndpoint" v-model="policy.options.endpoint"/>
|
||||
<p class="comment">ES HTTP接口地址,类似于192.168.1.100:9200,需要能够被API节点访问。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Index *</td>
|
||||
<td>
|
||||
<input type="text" name="esIndex" v-model="policy.options.index"/>
|
||||
<p class="comment">Index名称,支持变量:
|
||||
<span class="ui label tiny basic">年:${year}</span>
|
||||
<span class="ui label tiny basic">月:${month}</span>
|
||||
<span class="ui label tiny basic">周:${week}</span>
|
||||
<span class="ui label tiny basic">日:${day}</span>
|
||||
<span class="ui label tiny basic">时:${hour}</span>
|
||||
<span class="ui label tiny basic">分:${minute}</span>
|
||||
<span class="ui label tiny basic">秒:${second}</span>
|
||||
<span class="ui label tiny basic">年月日:${date}</span></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>数据流模式</td>
|
||||
<td>
|
||||
<checkbox name="esIsDataStream" v-model="policy.options.isDataStream"></checkbox>
|
||||
<p class="comment">适用于索引是数据流(Data Stream)的场景,时间字段为<code-label>timeISO8601</code-label>。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-show="!policy.options.isDataStream">
|
||||
<td>Mapping Type *</td>
|
||||
<td>
|
||||
<input type="text" name="esMappingType" v-model="policy.options.mappingType"/>
|
||||
<p class="comment">Mapping名称,支持变量:
|
||||
<span class="ui label tiny basic">年:${year}</span>
|
||||
<span class="ui label tiny basic">月:${month}</span>
|
||||
<span class="ui label tiny basic">周:${week}</span>
|
||||
<span class="ui label tiny basic">日:${day}</span>
|
||||
<span class="ui label tiny basic">时:${hour}</span>
|
||||
<span class="ui label tiny basic">分:${minute}</span>
|
||||
<span class="ui label tiny basic">秒:${second}</span>
|
||||
<span class="ui label tiny basic">年月日:${date}</span></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>认证用户名</td>
|
||||
<td>
|
||||
<input type="text" name="esUsername" v-model="policy.options.username"/>
|
||||
<p class="comment">配置了认证后才需要填写。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>认证密码</td>
|
||||
<td>
|
||||
<input type="text" name="esPassword" v-model="policy.options.password"/>
|
||||
<p class="comment">配置了认证后才需要填写。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<!-- TCP Socket -->
|
||||
<tbody v-show="policy.typeDisplay == 'tcp'">
|
||||
<tr>
|
||||
<td>网络协议 *</td>
|
||||
<td>
|
||||
<select name="tcpNetwork" class="ui dropdown" style="width:10em" v-model="policy.options.network">
|
||||
<option value="tcp">TCP</option>
|
||||
<option value="unix">Unix Socket</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>网络地址 *</td>
|
||||
<td>
|
||||
<input type="text" name="tcpAddr" v-model="policy.options.addr"/>
|
||||
<p class="comment">接收日志的网络地址,需要能够被API节点访问。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<!-- Syslog -->
|
||||
<tbody v-show="policy.typeDisplay == 'syslog'">
|
||||
<tr>
|
||||
<td>网络协议</td>
|
||||
<td>
|
||||
<select class="ui dropdown" name="syslogProtocol" v-model="syslogProtocol" style="width:10em">
|
||||
<option value="none">[无]</option>
|
||||
<option value="tcp">TCP</option>
|
||||
<option value="udp">UDP</option>
|
||||
<option value="socket">Unix Socket</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr v-if="syslogProtocol == 'tcp' || syslogProtocol == 'udp'">
|
||||
<td>网络地址 *</td>
|
||||
<td>
|
||||
<input type="text" name="syslogServerAddr" v-model="policy.options.serverAddr"/>
|
||||
<p class="comment">IP地址或主机名,不包括端口,需要能够被API节点访问。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="syslogProtocol == 'tcp' || syslogProtocol == 'udp'">
|
||||
<td>端口</td>
|
||||
<td>
|
||||
<input type="text" name="syslogServerPort" v-model="policy.options.serverPort"/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr v-if="syslogProtocol == 'socket'">
|
||||
<td>Socket路径 *</td>
|
||||
<td>
|
||||
<input type="text" name="syslogSocket" v-model="policy.options.socket"/>
|
||||
<p class="comment">需要能够被API节点访问。</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>标签<em>(Tag)</em></td>
|
||||
<td>
|
||||
<input type="text" name="syslogTag" v-model="policy.options.tag"/>
|
||||
<p class="comment">选填项。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>优先级<em>(Priority)</em></td>
|
||||
<td>
|
||||
<select class="ui dropdown" name="syslogPriority" style="width:10em" v-model="policy.options.priority">
|
||||
<option v-for="priority in syslogPriorities" :value="priority.value">{{priority.name}}</option>
|
||||
</select>
|
||||
<p class="comment">选填项。</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
<!-- 命令行输入流 -->
|
||||
<tbody v-show="policy.typeDisplay == 'command'">
|
||||
<tr>
|
||||
<td>可执行文件 *</td>
|
||||
<td>
|
||||
<input type="text" name="commandCommand" v-model="policy.options.command"/>
|
||||
<p class="comment">不带参数的可执行文件地址,此命令可执行文件需要部署在API节点上。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>参数</td>
|
||||
<td>
|
||||
<input type="text" name="commandArgs" v-model="policy.options.args"/>
|
||||
<p class="comment">执行命令需要的参数</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>工作目录</td>
|
||||
<td>
|
||||
<input type="text" name="commandDir" v-model="policy.options.dir"/>
|
||||
<p class="comment">命令执行所在的工作目录</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
|
||||
<tr>
|
||||
<td>公用</td>
|
||||
<td>
|
||||
<checkbox name="isPublic" v-model="policy.isPublic"></checkbox>
|
||||
<p class="comment"><span class="red">选中后表示自动将此策略应用于所有集群,同时只会有一个公用策略。</span></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td>只记录WAF相关访问日志</td>
|
||||
<td>
|
||||
<checkbox name="firewallOnly" v-model="policy.firewallOnly"></checkbox>
|
||||
<p class="comment">默认记录所有访问日志;如果选中此项,则表示只记录WAF相关访问日志。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>停用默认数据库存储</td>
|
||||
<td>
|
||||
<checkbox name="disableDefaultDB" v-model="policy.disableDefaultDB"></checkbox>
|
||||
<p class="comment">选中后,表示停止将访问日志写入到默认的数据库中。</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>启用当前策略</td>
|
||||
<td>
|
||||
<checkbox name="isOn" v-model="policy.isOn"></checkbox>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<submit-btn></submit-btn>
|
||||
</form>
|
||||
24
EdgeAdmin/web/views/@default/servers/accesslogs/update.js
Normal file
24
EdgeAdmin/web/views/@default/servers/accesslogs/update.js
Normal file
@@ -0,0 +1,24 @@
|
||||
Tea.context(function () {
|
||||
this.success = NotifySuccess("html:保存成功<br/>新的配置将会在1分钟之内生效", ".policy", {policyId: this.policy.id})
|
||||
|
||||
this.type = this.policy.type
|
||||
|
||||
|
||||
/**
|
||||
* syslog
|
||||
*/
|
||||
this.syslogProtocol = this.policy.options.protocol
|
||||
|
||||
/**
|
||||
* command
|
||||
*/
|
||||
if (this.policy.type == "command") {
|
||||
let args = this.policy.options.args
|
||||
if (args == null) {
|
||||
args = ""
|
||||
} else {
|
||||
args = args.join(" ")
|
||||
}
|
||||
this.policy.options.args = args
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user