2019-12-18 17:00:44 +08:00
|
|
|
|
<template>
|
2021-01-18 18:58:57 +08:00
|
|
|
|
<div class="right-box right-box-module" v-clickoutside="{obj:editModule,func:clickOutside}">
|
2021-04-23 11:47:38 +08:00
|
|
|
|
<div class="right-box__header">
|
|
|
|
|
|
<!-- begin--标题-->
|
2022-06-16 15:58:17 +08:00
|
|
|
|
<div class="header__title">{{editModule.id ? $t("project.module.editModule") : $t("overall.createModule")}}</div>
|
2021-04-23 11:47:38 +08:00
|
|
|
|
<!-- end--标题-->
|
2021-04-25 14:58:03 +08:00
|
|
|
|
<div class="header__operation">
|
2022-07-01 09:39:20 +08:00
|
|
|
|
<span v-cancel="{obj: editModule, func: esc}"><i class="nz-icon nz-icon-close" :title="$t('overall.close')"></i></span>
|
2021-04-23 11:47:38 +08:00
|
|
|
|
</div>
|
2020-07-28 19:42:25 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- begin--表单-->
|
2021-05-21 19:28:50 +08:00
|
|
|
|
<div class="right-box__container">
|
|
|
|
|
|
<div class="container__form">
|
|
|
|
|
|
<el-form ref="moduleForm" :model="editModule" :rules="rules" label-position="top" label-width="120px">
|
|
|
|
|
|
<!--name-->
|
2022-06-16 15:58:17 +08:00
|
|
|
|
<el-form-item :label='$t("overall.name")' label-width="125px" prop="name">
|
2022-11-18 16:18:49 +08:00
|
|
|
|
<el-input id="module-box-input-name" v-model="editModule.name" maxlength="64" placeholder="" show-word-limit size="small"></el-input>
|
2021-05-21 19:28:50 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--project-->
|
|
|
|
|
|
<el-form-item :label='$t("project.project.projectName")' prop="projectId">
|
2021-10-29 12:02:34 +08:00
|
|
|
|
<el-select id="module-box-input-project" v-model="editModule.projectId" :disabled="!!editModule.id" class="right-box__select" placeholder="" popper-class="right-box-select-top module-project-box-dropdown prevent-clickoutside" size="small" value-key="id">
|
2021-05-21 19:28:50 +08:00
|
|
|
|
<el-option v-for="item in projectList" :id="'module-project-'+item.id" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--remark-->
|
2021-06-07 18:28:07 +08:00
|
|
|
|
<el-form-item :label='$t("overall.remark")' prop="remark">
|
2021-05-21 19:28:50 +08:00
|
|
|
|
<el-input
|
|
|
|
|
|
id="module-box-input-remark"
|
|
|
|
|
|
v-model="editModule.remark"
|
|
|
|
|
|
class="not-fixed-height no-resize"
|
2021-05-28 10:43:41 +08:00
|
|
|
|
maxlength="256"
|
|
|
|
|
|
show-word-limit
|
2021-05-21 19:28:50 +08:00
|
|
|
|
placeholder=""
|
2022-06-10 14:55:46 +08:00
|
|
|
|
size="small" :rows="2"
|
2021-05-21 19:28:50 +08:00
|
|
|
|
type="textarea"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--Enpoint template-->
|
|
|
|
|
|
<div class="right-box-sub-title">{{ $t("overall.endpointTemplate") }}
|
2021-11-05 15:41:25 +08:00
|
|
|
|
<el-tooltip effect="light" placement="top" popper-class="prevent-clickoutside">
|
2021-05-21 19:28:50 +08:00
|
|
|
|
<div slot="content">
|
|
|
|
|
|
{{$t('project.module.tip.defaultEndpointSet')}}
|
|
|
|
|
|
<div></div>
|
|
|
|
|
|
{{$t('project.module.tip.relation')}}
|
2019-12-27 17:53:17 +08:00
|
|
|
|
</div>
|
2021-05-21 19:28:50 +08:00
|
|
|
|
<i class="nz-icon nz-icon-info-normal"></i>
|
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="right-box-line"></div>
|
2021-08-03 10:14:37 +08:00
|
|
|
|
<!--name pattern-->
|
|
|
|
|
|
<el-form-item :label='$t("project.endpoint.pattern")' prop="pattern">
|
|
|
|
|
|
<!-- <el-input placeholder="" v-model=""></el-input>-->
|
|
|
|
|
|
<el-autocomplete
|
|
|
|
|
|
id="module-box-input-pattern"
|
2023-06-25 14:52:20 +08:00
|
|
|
|
:maxlength="64"
|
2021-08-03 10:14:37 +08:00
|
|
|
|
v-model="editModule.endpointNameTmpl"
|
|
|
|
|
|
:fetch-suggestions="querySearch"
|
|
|
|
|
|
:placeholder="$t('overall.placeHolder')"
|
2021-10-29 12:02:34 +08:00
|
|
|
|
popper-class="right-box-select-top right-public-box-dropdown-top"
|
2021-08-03 10:14:37 +08:00
|
|
|
|
class="inline-input"
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
></el-autocomplete>
|
|
|
|
|
|
</el-form-item>
|
2022-11-23 11:09:05 +08:00
|
|
|
|
<!-- DashboardTemplate -->
|
2023-03-15 15:39:06 +08:00
|
|
|
|
<el-form-item :label="$t('model.dashboardtemplate')" prop="dashboardId" ref="dashboardTemplate">
|
2021-08-03 10:14:37 +08:00
|
|
|
|
<v-selectpage
|
2022-11-23 11:09:05 +08:00
|
|
|
|
:data="dashboardList"
|
|
|
|
|
|
:tb-columns="DashboardSearchShowFields"
|
|
|
|
|
|
:params="{
|
|
|
|
|
|
varType: 2,type: 'template'}"
|
|
|
|
|
|
:multiple="false"
|
|
|
|
|
|
:language="language"
|
|
|
|
|
|
title="DashboardSearch"
|
|
|
|
|
|
key-field="id"
|
2023-06-29 14:22:20 +08:00
|
|
|
|
:width="626"
|
2023-03-15 15:39:06 +08:00
|
|
|
|
v-model="editModule.dashboardId"
|
2022-11-23 11:09:05 +08:00
|
|
|
|
show-field="name"
|
|
|
|
|
|
class="form-control"
|
2023-03-15 15:39:06 +08:00
|
|
|
|
@values="(data) => {editModule.dashboardId = data.map(d => d.id).join(',')}"
|
2022-11-23 11:09:05 +08:00
|
|
|
|
:result-format="resultFormat"
|
2021-08-03 10:14:37 +08:00
|
|
|
|
></v-selectpage>
|
|
|
|
|
|
</el-form-item>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- Metrics -->
|
2021-08-02 11:47:34 +08:00
|
|
|
|
<div class="endpoint-title">
|
|
|
|
|
|
<span class="endpoint-title-content">
|
2021-08-03 10:14:37 +08:00
|
|
|
|
<i class="nz-icon nz-icon-arrow-down" :class="metricsShow?'':'is-active'" @click="metricsShow = !metricsShow"></i>
|
2022-07-12 14:06:14 +08:00
|
|
|
|
{{$t('overall.metrics')}}
|
2021-08-02 11:47:34 +08:00
|
|
|
|
</span>
|
2021-11-30 16:08:02 +08:00
|
|
|
|
<el-switch v-model="editModule.configs[0].enable" size="small" :active-value="1" :inactive-value="0"></el-switch>
|
2021-08-02 11:47:34 +08:00
|
|
|
|
</div>
|
2021-08-03 10:14:37 +08:00
|
|
|
|
<transition name="el-zoom-in-top">
|
2021-08-05 14:50:29 +08:00
|
|
|
|
<el-tabs v-model="activeName" v-show="metricsShow" v-if="editModule.configs[0].enable">
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<!-- Basic -->
|
2021-08-24 15:11:34 +08:00
|
|
|
|
<el-tab-pane :label="$t('project.endpoint.basic')" name="Basic">
|
2021-08-02 11:47:34 +08:00
|
|
|
|
<!--type-->
|
2022-06-16 15:58:17 +08:00
|
|
|
|
<el-form-item :label='$t("webshell.protocol")' class="half-form-item" prop="type">
|
2021-10-29 12:02:34 +08:00
|
|
|
|
<el-select id="module-box-input-type" v-model="editModule.configs[0].config.protocol" :disabled="!!editModule.id && editModule.configs[0].config.protocol === 'snmp'" class="right-box__select" placeholder="" popper-class="right-box-select-top prevent-clickoutside" size="small" value-key="id" @change="changeBasicType">
|
2021-10-18 17:06:08 +08:00
|
|
|
|
<el-option v-for="item in typeList" :id="'module-type-'+item.id" :key="item.value" :label="item.name" :value="item.value" :disabled="item.disabled && !!editModule.id"></el-option>
|
2021-08-02 11:47:34 +08:00
|
|
|
|
</el-select>
|
2021-05-21 19:28:50 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--host-->
|
2022-06-21 18:14:21 +08:00
|
|
|
|
<el-form-item :label='$t("asset.host")' class="half-form-item" prop="configs.0.config.host" :rules="[{ required: true, message: $t('validate.required'), trigger: 'blur' }]">
|
2021-08-02 11:47:34 +08:00
|
|
|
|
<el-input id="module-box-input-host" v-model="editModule.configs[0].config.host" placeholder="" size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
2021-08-27 16:15:05 +08:00
|
|
|
|
<!--path-->
|
2022-06-16 15:58:17 +08:00
|
|
|
|
<el-form-item :label='$t("config.terminallog.path")' class="half-form-item" prop="configs.metrics_path" :disabled="editModule.configs[0].config.protocol === 'snmp'">
|
2021-08-27 16:15:05 +08:00
|
|
|
|
<el-input id="module-box-input-path" v-model="editModule.configs[0].config.metrics_path" placeholder="" size="small" :disabled="editModule.configs[0].config.protocol === 'snmp'"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--port-->
|
2022-06-16 15:58:17 +08:00
|
|
|
|
<el-form-item :label='$t("asset.port")' class="half-form-item" prop="configs.0.config.port" :rules="[
|
2021-08-27 16:15:05 +08:00
|
|
|
|
{ validator: port, trigger: 'blur' },
|
|
|
|
|
|
{ required: true, message: $t('validate.required'), trigger: 'blur' }
|
|
|
|
|
|
]">
|
|
|
|
|
|
<el-input id="module-box-input-port" v-model.number="editModule.configs[0].config.port" placeholder="" size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
2021-08-02 11:47:34 +08:00
|
|
|
|
<!-- snmp表单 -->
|
2021-08-04 16:55:11 +08:00
|
|
|
|
<div v-if="editModule.configs[0].config.protocol && editModule.configs[0].config.protocol == 'snmp'" class="">
|
2021-08-02 11:47:34 +08:00
|
|
|
|
<el-row>
|
|
|
|
|
|
<el-col :span="6">
|
2021-08-04 16:55:11 +08:00
|
|
|
|
<div class="sub-label sub-label-required" style="padding-left: 0">{{$t('project.module.walk')}}</div>
|
2021-08-02 11:47:34 +08:00
|
|
|
|
</el-col>
|
|
|
|
|
|
<el-col :span="24">
|
2021-08-19 15:54:38 +08:00
|
|
|
|
<el-form-item prop="configs.0.config.walk" :rules="[{ required: true, message: $t('validate.required'), trigger: 'blur' }]">
|
2021-08-02 11:47:34 +08:00
|
|
|
|
<select-walk ref="selectWalk" :currentWalk="editModule.configs[0].config.walk" :expandedWalk="expandedWalkData" :placement="'bottom-start'" :walkData="walkData" @selectWalk="selectWalk">
|
|
|
|
|
|
<template v-slot:trigger>
|
|
|
|
|
|
<div class="el-cascader">
|
|
|
|
|
|
<div class="el-input">
|
|
|
|
|
|
<input aria-expanded="false" autocomplete="off" class="el-input__inner" readonly="readonly" type="text">
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="el-cascader__tags">
|
|
|
|
|
|
<div ref="walkScrollbar" style="height: 100%; overflow: auto;">
|
|
|
|
|
|
<span v-for="(item, index) in editModule.configs[0].config.walk" :key="index" class="el-tag el-tag--info el-tag--small el-tag--light">
|
|
|
|
|
|
<span v-html="mibName(item)"></span>
|
2022-07-01 09:39:20 +08:00
|
|
|
|
<div class="walk-close-box" @click.stop="removeWalk(item)" :title="$t('overall.close')">
|
2021-08-02 11:47:34 +08:00
|
|
|
|
<i class="el-tag__close nz-icon nz-icon-close walk-close"></i>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</select-walk>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<!--credentials-->
|
2021-08-02 11:47:34 +08:00
|
|
|
|
<el-form-item :label='$t("project.endpoint.credentials")' prop="credentials">
|
2021-10-29 12:02:34 +08:00
|
|
|
|
<el-select id="module-box-input-credentials" v-model="editModule.configs[0].config.snmpCredentialsId" class="right-box__select" placeholder="" popper-class="right-box-select-top prevent-clickoutside" size="small" value-key="id">
|
2021-08-02 11:47:34 +08:00
|
|
|
|
<el-option v-for="item in credentialList" :id="'module-type-'+item.id" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
|
|
|
|
|
</el-select>
|
2021-05-21 19:28:50 +08:00
|
|
|
|
</el-form-item>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<!-- more option-->
|
2021-05-21 19:28:50 +08:00
|
|
|
|
<transition name="el-zoom-in-top">
|
|
|
|
|
|
<div v-show="showAllBasicOption" >
|
|
|
|
|
|
<!--scrape_interval-->
|
2021-08-03 10:14:37 +08:00
|
|
|
|
<el-form-item :label='$t("project.endpoint.scrape_interval")' class="half-form-item" prop="configs.0.config.scrape_interval">
|
2022-06-21 14:17:46 +08:00
|
|
|
|
<el-input id="module-box-input-scrape_interval" v-model.number="editModule.configs[0].config.scrape_interval" :placeholder='$t("alert.config.inrPlaceholder")' size="small">
|
2021-05-21 19:28:50 +08:00
|
|
|
|
<template slot="append">s</template>
|
|
|
|
|
|
</el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--scrape_timeout-->
|
2021-08-03 10:14:37 +08:00
|
|
|
|
<el-form-item :label='$t("project.endpoint.scrape_timeout")' class="half-form-item" prop="configs.0.config.scrape_timeout">
|
2021-08-02 11:47:34 +08:00
|
|
|
|
<el-input id="module-box-input-scrape_timeout" v-model.number="editModule.configs[0].config.scrape_timeout" :placeholder='$t("project.endpoint.scrape_timeout_placeholder")' size="small">
|
2021-05-21 19:28:50 +08:00
|
|
|
|
<template slot="append">s</template>
|
|
|
|
|
|
</el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</transition>
|
2021-04-22 10:36:29 +08:00
|
|
|
|
|
2021-05-21 19:28:50 +08:00
|
|
|
|
<div style="text-align: center">
|
2021-11-17 11:12:06 +08:00
|
|
|
|
<span class="nz-btn nz-btn-size-normal nz-btn-style-light" style="border: none" @click="showAllBasicOption=!showAllBasicOption">
|
2021-05-21 19:28:50 +08:00
|
|
|
|
{{$t('overall.moreOption')}}
|
|
|
|
|
|
<i :class="showAllBasicOption?'is-active':''" class="nz-icon nz-icon-arrow-down need-rotate" ></i>
|
|
|
|
|
|
</span>
|
2021-04-14 15:38:37 +08:00
|
|
|
|
</div>
|
2021-05-21 19:28:50 +08:00
|
|
|
|
</el-tab-pane>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<!-- Parameter -->
|
2022-06-21 18:14:21 +08:00
|
|
|
|
<el-tab-pane :label="$t('config.assetLabel.params')" name="Parameter">
|
2021-05-21 19:28:50 +08:00
|
|
|
|
<div id="module-box-params" ref="labelBoxScrollbar" style="height: 100%; overflow: auto;">
|
|
|
|
|
|
<div v-for="(item, index) in editModule.paramObj" :key="index" class="param-box-row">
|
|
|
|
|
|
<el-form-item :prop="'paramObj.' + index + '.key'" class="param-box-row-key">
|
|
|
|
|
|
<el-input v-model="item.key" placeholder="key" size="mini" ></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<span class="param-box-row-eq">=</span>
|
|
|
|
|
|
<el-form-item :prop="'paramObj.' + index + '.value'" class="param-box-row-value">
|
|
|
|
|
|
<vue-tags-input
|
|
|
|
|
|
v-model="item.tags"
|
2023-08-25 15:44:21 +08:00
|
|
|
|
:placeholder="$t('tagsInput.placeholder')"
|
2021-05-21 19:28:50 +08:00
|
|
|
|
:tags="item.value"
|
|
|
|
|
|
@tags-changed="(newTags)=>{tagsChange(newTags, index)}"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
2022-07-01 09:39:20 +08:00
|
|
|
|
<span :id="'moduel-remove-param-'+index" class="param-box-row-symbol" @click="removeParam(index)" :title="$t('overall.delete')"><i class="nz-icon nz-icon-shanchu1"></i></span>
|
2021-05-21 19:28:50 +08:00
|
|
|
|
</div>
|
2021-04-14 15:38:37 +08:00
|
|
|
|
</div>
|
2021-05-21 19:28:50 +08:00
|
|
|
|
<div style="text-align: center">
|
|
|
|
|
|
<span id="module-add-param" class="right-box-form-add module-add-label" type="button" @click="addParam">
|
2022-07-01 09:39:20 +08:00
|
|
|
|
<span :title="$t('tip.add')"><i class="nz-icon nz-icon-plus" style="font-size: 16px;"></i></span>
|
2021-05-21 19:28:50 +08:00
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-tab-pane>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<!-- Labels -->
|
2021-08-24 15:11:34 +08:00
|
|
|
|
<el-tab-pane :label="$t('project.endpoint.labels2')" name="Labels">
|
2021-05-21 19:28:50 +08:00
|
|
|
|
<div id="module-box-labels" ref="labelBoxScrollbar" style="height: 100%; overflow: auto;">
|
|
|
|
|
|
<div v-for="(item, index) in editModule.labelModule" :key="index" class="param-box-row">
|
2021-11-22 14:04:15 +08:00
|
|
|
|
<el-form-item :prop="'labelModule.' + index + '.key'" :rules="[{ pattern: /[a-zA-Z_:][a-zA-Z0-9_:]*/, message: $t('overall.ASCIIKey') ,trigger: 'blur'}]" class="param-box-row-key">
|
2021-05-21 19:28:50 +08:00
|
|
|
|
<el-input v-model="item.key" placeholder="key" size="mini"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<span class="param-box-row-eq">=</span>
|
|
|
|
|
|
<el-form-item :prop="'labelModule.' + index + '.value'" class="param-box-row-value">
|
|
|
|
|
|
<el-input v-model="item.value" placeholder="value" size="mini"></el-input>
|
|
|
|
|
|
</el-form-item>
|
2022-07-01 09:39:20 +08:00
|
|
|
|
<span :id="'moduel-remove-label-'+index" class="param-box-row-symbol" @click="removeLabel(index)" :title="$t('overall.delete')"><i class="nz-icon nz-icon-shanchu1"></i></span>
|
2021-05-21 19:28:50 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style="text-align: center">
|
|
|
|
|
|
<span id="module-add-label" class="right-box-form-add module-add-label" type="button" @click="addLabel">
|
2022-07-01 09:39:20 +08:00
|
|
|
|
<span :title="$t('tip.add')"><i class="nz-icon nz-icon-plus" style="font-size: 16px;"></i></span>
|
2021-05-21 19:28:50 +08:00
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-tab-pane>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<!-- Relabel -->
|
|
|
|
|
|
<el-tab-pane :label="$t('project.endpoint.relabel')" name="Relabel">
|
|
|
|
|
|
<div id="module-box-relabel" ref="labelBoxScrollbar" style="height: 100%; overflow: hidden;">
|
|
|
|
|
|
<div v-for="(item, index) in editModule.configs[0].config.relabel_config" :key="index" class="">
|
|
|
|
|
|
<div class="pipeline-box">
|
|
|
|
|
|
<span class="pipeline-title">{{$t('project.endpoint.item') + index}}</span>
|
|
|
|
|
|
<span class="pipeline-option" :title="$t('overall.delete')">
|
|
|
|
|
|
<i class="nz-icon nz-icon-shanchu1" @click="removeRelabel(index)"></i>
|
2021-08-19 15:54:38 +08:00
|
|
|
|
</span>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<el-form-item :prop="'configs.0.config.relabel_config.' + index + '.action'" class="" :label="'Action'" :rules="[{ required: true, message: $t('validate.required'), trigger: 'change' }]">
|
|
|
|
|
|
<el-select v-model="item.action" :id="'action' + index " class="right-box__select " placeholder="" popper-class="right-box-select-top prevent-clickoutside" size="small" @change="actionChange(index)" :rules="[{ required: true, message: $t('validate.required'), trigger: 'change' }]">
|
|
|
|
|
|
<el-option v-for="item2 in actionList" :id="'module-action-'+item2.label" :key="item2.label" :label="item2.label" :value="item2.value"></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
:prop="'configs.0.config.relabel_config.' + index + '.source_labels'"
|
|
|
|
|
|
class="half-form-item" :label="'Source labels'"
|
|
|
|
|
|
:rules="[
|
|
|
|
|
|
{ required: item.action === 'replace' || item.action === 'keep' || item.action === 'drop', message: $t('validate.required'), trigger: 'change' },
|
|
|
|
|
|
{ validator: item.action === 'replace' || item.action === 'keep' || item.action === 'drop'? arrLength : requirdRelabel, trigger: 'change' }
|
|
|
|
|
|
]">
|
|
|
|
|
|
<vue-tags-input
|
|
|
|
|
|
v-model="item.tags"
|
|
|
|
|
|
ref="relabelTag"
|
|
|
|
|
|
tabindex="9999"
|
2023-08-25 15:44:21 +08:00
|
|
|
|
:placeholder="$t('tagsInput.placeholder')"
|
2022-10-09 11:28:00 +08:00
|
|
|
|
:tags="item.source_labels"
|
|
|
|
|
|
@before-adding-tag="beforeAddingTag"
|
|
|
|
|
|
@blur="relabelTabBlur"
|
|
|
|
|
|
@tags-changed="(newTags)=>{tagsChangeRelabel(newTags, index)}"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
:prop="'configs.0.config.relabel_config.' + index + '.target_label'"
|
|
|
|
|
|
class="half-form-item" :label="'Target label'"
|
|
|
|
|
|
:rules="[
|
|
|
|
|
|
{ required: item.action === 'replace', message: $t('validate.required'), trigger: 'blur' },
|
|
|
|
|
|
{ pattern: /[a-zA-Z_:][a-zA-Z0-9_:]*/, message: $t('overall.ASCIIKey') ,trigger: 'blur'}]"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input id="module-box-input-target_label" v-model="item.target_label" placeholder='' size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
2022-10-11 09:39:56 +08:00
|
|
|
|
<!-- more option-->
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<transition name="el-zoom-in-top">
|
|
|
|
|
|
<div v-show="item.showAllRelabelOption" >
|
|
|
|
|
|
<!--Regex-->
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
:label='"Regex"'
|
|
|
|
|
|
class="half-form-item"
|
|
|
|
|
|
:prop="'configs.0.config.relabel_config.' + index + '.regex'"
|
|
|
|
|
|
:rules="[{ required: true, message: $t('validate.required'), trigger: 'change' }]">
|
|
|
|
|
|
<el-input id="module-box-input-regex" v-model="item.regex" :placeholder="$t('overall.relabelConfigRegex')" size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--replacement-->
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
:label='"Replacement"'
|
|
|
|
|
|
class="half-form-item"
|
|
|
|
|
|
:prop="'configs.0.config.relabel_config.' + index + '.replacement'"
|
|
|
|
|
|
:rules="[{ required: item.action === 'replace' || item.action === 'labelmap', message: $t('validate.required'), trigger: 'change' }]">
|
|
|
|
|
|
<el-input id="module-box-input-replacement" v-model="item.replacement" :placeholder="$t('overall.relabelConfigReplacement')" size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
2021-08-19 15:54:38 +08:00
|
|
|
|
</div>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
</transition>
|
|
|
|
|
|
<div style="text-align: center">
|
|
|
|
|
|
<span class="nz-btn nz-btn-size-normal nz-btn-style-light" style="border: none" @click="item.showAllRelabelOption=!item.showAllRelabelOption">
|
|
|
|
|
|
{{$t('overall.moreOption')}}
|
|
|
|
|
|
<i :class="item.showAllRelabelOption?'is-active':''" class="nz-icon nz-icon-arrow-down need-rotate" ></i>
|
|
|
|
|
|
</span>
|
2021-08-19 15:54:38 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div style="text-align: center">
|
|
|
|
|
|
<span id="module-add-relabel" class="right-box-form-add module-add-label margin-t-10" type="button" @click="addRelabel">
|
|
|
|
|
|
<span :title="$t('tip.add')"><i class="nz-icon nz-icon-plus" style="font-size: 16px;"></i></span>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-tab-pane>
|
|
|
|
|
|
<!-- Authentication -->
|
2022-06-16 15:58:17 +08:00
|
|
|
|
<el-tab-pane v-if="editModule.configs[0].config.protocol !== 'snmp'" :label="$t('config.mib.credential.auth')" name="Auth">
|
2021-05-21 19:28:50 +08:00
|
|
|
|
<!--authtype-->
|
2022-06-16 15:58:17 +08:00
|
|
|
|
<el-form-item :label='$t("overall.type")' prop="authtype">
|
2021-10-29 12:02:34 +08:00
|
|
|
|
<el-select id="module-box-input-auth-type" v-model="authType" class="right-box__select" placeholder="" popper-class="right-box-select-top prevent-clickoutside" size="small" value-key="id" @change="changeAuthType">
|
2021-05-21 19:28:50 +08:00
|
|
|
|
<el-option v-for="item in authTypeList" :id="'module-type-'+item.id" :key="item.value" :label="item.name" :value="item.value"></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
2021-04-13 19:06:34 +08:00
|
|
|
|
|
2021-05-21 19:28:50 +08:00
|
|
|
|
<!--authtype 1-->
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<el-form-item v-if="authType === 1" :label='$t("profile.username")' class="half-form-item" prop="configs.0.config.basic_auth.username" :rules="[{ required: true, message: $t('validate.required'), trigger: 'blur' }]" key="username">
|
2021-08-17 10:49:18 +08:00
|
|
|
|
<el-input id="module-box-input-uername" v-model="editModule.configs[0].config.basic_auth.username" placeholder='' size="small"></el-input>
|
2021-05-21 19:28:50 +08:00
|
|
|
|
</el-form-item>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<el-form-item v-if="authType === 1" :label='$t("login.pin")' class="half-form-item" prop="configs.0.config.basic_auth.password" :rules="[{ required: true, message: $t('validate.required'), trigger: 'blur' }]" key="password">
|
2023-01-04 17:49:28 +08:00
|
|
|
|
<el-input id="module-box-input-password" v-model="editModule.configs[0].config.basic_auth.password" type="password" auto-complete="new-password" autocomplete="new-password" placeholder='' size="small"></el-input>
|
2021-05-21 19:28:50 +08:00
|
|
|
|
</el-form-item>
|
2021-04-13 19:06:34 +08:00
|
|
|
|
|
2021-05-21 19:28:50 +08:00
|
|
|
|
<!--authtype 2-->
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<el-form-item v-if="authType === 2" :label='$t("project.endpoint.authTypeToken")' prop="configs.0.config.bearer_token" :rules="[{ required: true, message: $t('validate.required'), trigger: 'blur' }]" key="bearer_token">
|
2021-08-17 10:49:18 +08:00
|
|
|
|
<el-input id="module-box-input-bearer_token" v-model="editModule.configs[0].config.bearer_token" placeholder='' size="small"></el-input>
|
2021-05-21 19:28:50 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-tab-pane>
|
|
|
|
|
|
</el-tabs>
|
2021-08-03 10:14:37 +08:00
|
|
|
|
</transition>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- Log -->
|
2021-08-02 11:47:34 +08:00
|
|
|
|
<div class="endpoint-title" style="margin-top: 10px">
|
|
|
|
|
|
<span class="endpoint-title-content">
|
2021-08-03 10:14:37 +08:00
|
|
|
|
<i class="nz-icon nz-icon-arrow-down" :class="logsShow?'':'is-active'" @click="logsShow = !logsShow"></i>
|
2022-06-16 15:58:17 +08:00
|
|
|
|
{{$t('overall.logs')}}
|
2021-08-02 11:47:34 +08:00
|
|
|
|
</span>
|
2021-11-30 16:08:02 +08:00
|
|
|
|
<el-switch v-model="editModule.configs[1].enable" size="small" :active-value="1" :inactive-value="0"></el-switch>
|
2021-08-02 11:47:34 +08:00
|
|
|
|
</div>
|
2021-08-03 10:14:37 +08:00
|
|
|
|
<transition name="el-zoom-in-top">
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<div v-show="logsShow" v-if="editModule.configs[1].enable">
|
|
|
|
|
|
<div v-for="(item, index) in editModule.configs[1].config" :key="index" style="position: relative">
|
|
|
|
|
|
<el-tabs v-model="activeNameLogs[index]" class="special-tabs" @tab-click="()=>{tabClick(index)}" :ref="'logsTabs' + index">
|
|
|
|
|
|
<!-- Basic -->
|
|
|
|
|
|
<el-tab-pane :label="$t('project.endpoint.basic')" name="Basic">
|
|
|
|
|
|
<!--type-->
|
|
|
|
|
|
<el-form-item :label='$t("overall.type")' class="half-form-item">
|
|
|
|
|
|
<el-select id="module-box-input-type" v-model="item.type" class="right-box__select" placeholder="" popper-class="right-box-select-top prevent-clickoutside" size="small" @change="logsBasicTypeChange(item,$event)">
|
|
|
|
|
|
<el-option v-for="item in logsBasicList" :key="item.value" :label="item.name" :value="item.value"></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- fileName -->
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-if='item.type === "file"'
|
2023-03-17 12:46:56 +08:00
|
|
|
|
:label='item.type === "file" ? $t("config.terminallog.path"):( item.type === "journal" ? $t("dashboard.dashboard.chartForm.unit") : $t("project.endpoint.basicTypeSyslog"))' class="half-form-item"
|
2022-10-09 11:28:00 +08:00
|
|
|
|
:prop="'configs.1.config.'+ index +'.fileName'"
|
|
|
|
|
|
:rules="[ { required: true, message: $t('validate.required'), trigger: 'blur' }]"
|
|
|
|
|
|
key="fileName"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input v-if='item.type === "file"' v-model="item.fileName" :id="'module-box-basic-value' +index" placeholder='' size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- unit -->
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-if='item.type === "journal"'
|
2023-03-17 12:46:56 +08:00
|
|
|
|
:label='item.type === "file" ? $t("config.terminallog.path"):( item.type === "journal" ? $t("dashboard.dashboard.chartForm.unit") : $t("project.endpoint.basicTypeSyslog"))' class="half-form-item"
|
2022-10-09 11:28:00 +08:00
|
|
|
|
:prop="'configs.1.config.'+ index +'.unit'"
|
|
|
|
|
|
:rules="[ { required: true, message: $t('validate.required'), trigger: 'blur' }]"
|
|
|
|
|
|
key="unit"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input v-if='item.type === "journal"' v-model="item.unit" :id="'module-box-basic-value' +index" placeholder='' size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- listenAddress -->
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-if='item.type === "syslog"'
|
2023-03-17 12:46:56 +08:00
|
|
|
|
:label='item.type === "file" ? $t("config.terminallog.path"):( item.type === "journal" ? $t("dashboard.dashboard.chartForm.unit") : $t("project.endpoint.basicTypeSyslog"))' class="half-form-item"
|
2022-10-09 11:28:00 +08:00
|
|
|
|
:prop="'configs.1.config.'+ index +'.listenAddress'"
|
|
|
|
|
|
:rules="[ { required: true, message: $t('validate.required'), trigger: 'blur' }]"
|
|
|
|
|
|
key="listenAddress"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input v-if='item.type === "syslog"' v-model="item.listenAddress" :id="'module-box-basic-value' +index" placeholder='' size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- appName -->
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-if="item.type === 'syslog'"
|
|
|
|
|
|
:label=' $t("project.endpoint.basicAppName")'
|
|
|
|
|
|
class="half-form-item"
|
|
|
|
|
|
:prop="'configs.1.config.'+ index +'.appName'"
|
|
|
|
|
|
:rules="[ { required: true, message: $t('validate.required'), trigger: 'blur' }]"
|
|
|
|
|
|
key="appName"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input v-model="item.appName" :id="'module-box-basic-appName' +index" placeholder='' size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- apiServer -->
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-if="item.type === 'kubernetes'"
|
|
|
|
|
|
:label='$t("project.endpoint.apiServer")'
|
|
|
|
|
|
class="half-form-item"
|
|
|
|
|
|
:prop="'configs.1.config.'+ index +'.apiServer'"
|
|
|
|
|
|
key="apiServer"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input v-model="item.apiServer" :id="'module-box-basic-apiServer' +index" placeholder='' size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- role -->
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-if='item.type === "kubernetes"'
|
|
|
|
|
|
:label='$t("profile.role")'
|
|
|
|
|
|
class="half-form-item"
|
|
|
|
|
|
:prop="'configs.1.config.'+ index +'.role'"
|
|
|
|
|
|
key="role"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-select v-model="item.role" class="right-box__select" placeholder="" popper-class="right-box-select-top prevent-clickoutside" size="small">
|
|
|
|
|
|
<el-option v-for="item in logsRoleList" :key="item.value" :label="item.name" :value="item.value"></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- namespaces -->
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
v-if="item.type === 'kubernetes'"
|
|
|
|
|
|
:label=' $t("project.endpoint.namespaces")'
|
|
|
|
|
|
class="half-form-item"
|
|
|
|
|
|
:prop="'configs.1.config.'+ index +'.namespaces.names'"
|
|
|
|
|
|
key="namespaces"
|
|
|
|
|
|
>
|
|
|
|
|
|
<vue-tags-input
|
|
|
|
|
|
v-model="item.namespaces.tags"
|
2023-08-25 15:44:21 +08:00
|
|
|
|
:placeholder="$t('tagsInput.placeholder')"
|
2022-10-09 11:28:00 +08:00
|
|
|
|
:tags="item.namespaces.names"
|
|
|
|
|
|
@tags-changed="(newTags)=>{logsTagsChange(newTags,item)}"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-tab-pane>
|
|
|
|
|
|
<!-- Labels -->
|
2022-10-18 14:49:05 +08:00
|
|
|
|
<el-tab-pane v-if="item.type!=='kubernetes'" :label="$t('project.endpoint.labels2')" name="Labels">
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<div id="module-box-logs-labels" ref="labelBoxScrollbar" style="height: 100%; overflow: auto;">
|
|
|
|
|
|
<div v-for="(item1, i) in item.labelModule" :key="i" class="param-box-row">
|
|
|
|
|
|
<el-form-item :prop="'configs.1.config.'+ index +'.labelModule.' + i + '.key'" :rules="[{ pattern: /[a-zA-Z_:][a-zA-Z0-9_:]*/, message: $t('overall.ASCIIKey') ,trigger: 'blur'}]" class="param-box-row-key">
|
|
|
|
|
|
<el-input v-model="item1.key" placeholder="key" size="mini"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<span class="param-box-row-eq">=</span>
|
|
|
|
|
|
<el-form-item class="param-box-row-value">
|
|
|
|
|
|
<el-input v-model="item1.value" placeholder="value" size="mini"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<span :id="'moduel-remove-label-'+i" class="param-box-row-symbol" @click="removeLogsLabel(index, i)" :title="$t('overall.delete')"><i class="nz-icon nz-icon-shanchu1"></i></span>
|
|
|
|
|
|
</div>
|
2021-08-03 10:14:37 +08:00
|
|
|
|
</div>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<div style="text-align: center">
|
|
|
|
|
|
<span id="module-add-logs-label" class="right-box-form-add module-add-label" type="button" @click="addLogsLabel(index)">
|
|
|
|
|
|
<span :title="$t('tip.add')"><i class="nz-icon nz-icon-plus" style="font-size: 16px;"></i></span>
|
|
|
|
|
|
</span>
|
2021-08-03 10:14:37 +08:00
|
|
|
|
</div>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
</el-tab-pane>
|
|
|
|
|
|
<!-- Relabel -->
|
|
|
|
|
|
<el-tab-pane :label="$t('project.endpoint.logRelabel')" name="Relabel">
|
|
|
|
|
|
<div id="module-box-relabel" ref="labelBoxScrollbar" style="height: 100%; overflow: hidden;">
|
|
|
|
|
|
<div v-for="(subItem, subIndex) in editModule.configs[1].config[index].relabel_config" :key="subIndex" class="">
|
|
|
|
|
|
<div class="pipeline-box">
|
|
|
|
|
|
<span class="pipeline-title">{{$t('project.endpoint.item') + subIndex}}</span>
|
|
|
|
|
|
<span class="pipeline-option" :title="$t('overall.delete')">
|
|
|
|
|
|
<i class="nz-icon nz-icon-shanchu1" @click="logsRemoveRelabel(index,subIndex)"></i>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<el-form-item :prop="'configs.1.config.' + index + '.relabel_config.' + subIndex + '.action'" class="" :label="'Action'" :rules="[{ required: true, message: $t('validate.required'), trigger: 'change' }]">
|
|
|
|
|
|
<el-select v-model="subItem.action" :id="'action' + subIndex " class="right-box__select " placeholder="" popper-class="right-box-select-top prevent-clickoutside" size="small" @change="logsActionChange(index,subIndex)" :rules="[{ required: true, message: $t('validate.required'), trigger: 'change' }]">
|
|
|
|
|
|
<el-option v-for="item2 in actionList" :id="'module-action-'+item2.label" :key="item2.label" :label="item2.label" :value="item2.value"></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
:prop="'configs.1.config.' + index + '.relabel_config.' + subIndex + '.source_labels'"
|
|
|
|
|
|
class="half-form-item" :label="'Source labels'"
|
|
|
|
|
|
:rules="[
|
|
|
|
|
|
{ required: subItem.action === 'replace' || subItem.action === 'keep' || subItem.action === 'drop', message: $t('validate.required'), trigger: 'change' },
|
|
|
|
|
|
{ validator: subItem.action === 'replace' || subItem.action === 'keep' || subItem.action === 'drop'? arrLength : requirdRelabel, trigger: 'change' }
|
|
|
|
|
|
]">
|
|
|
|
|
|
<vue-tags-input
|
|
|
|
|
|
v-model="subItem.tags"
|
|
|
|
|
|
:ref="'logsRelabelTag'+index+subIndex"
|
|
|
|
|
|
tabindex="9999"
|
2023-08-25 15:44:21 +08:00
|
|
|
|
:placeholder="$t('tagsInput.placeholder')"
|
2022-10-09 11:28:00 +08:00
|
|
|
|
:tags="subItem.source_labels"
|
|
|
|
|
|
@before-adding-tag="beforeAddingTag"
|
|
|
|
|
|
@blur="logsRelabelTabBlur(index,subIndex)"
|
|
|
|
|
|
@tags-changed="(newTags)=>{logsTagsChangeRelabel(newTags, index,subIndex)}"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
:prop="'configs.1.config.' + index + '.relabel_config.' + subIndex + '.target_label'"
|
|
|
|
|
|
class="half-form-item" :label="'Target label'"
|
|
|
|
|
|
:rules="[
|
|
|
|
|
|
{ required: subItem.action === 'replace', message: $t('validate.required'), trigger: 'blur' },
|
|
|
|
|
|
{ pattern: /[a-zA-Z_:][a-zA-Z0-9_:]*/, message: $t('overall.ASCIIKey') ,trigger: 'blur'}]"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input id="module-box-input-target_label" v-model="subItem.target_label" placeholder='' size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
2022-10-11 09:39:56 +08:00
|
|
|
|
<!-- more option-->
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<transition name="el-zoom-in-top">
|
|
|
|
|
|
<div v-show="subItem.showAllRelabelOption" >
|
|
|
|
|
|
<!--Regex-->
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
:label='"Regex"'
|
|
|
|
|
|
class="half-form-item"
|
|
|
|
|
|
:prop="'configs.1.config.' + index + '.relabel_config.' + subIndex + '.regex'"
|
|
|
|
|
|
:rules="[{ required: true, message: $t('validate.required'), trigger: 'change' }]">
|
|
|
|
|
|
<el-input id="module-box-input-regex" v-model="subItem.regex" :placeholder="$t('overall.relabelConfigRegex')" size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--replacement-->
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
:label='"Replacement"'
|
|
|
|
|
|
class="half-form-item"
|
|
|
|
|
|
:prop="'configs.1.config.' + index + '.relabel_config.' + subIndex + '.replacement'"
|
|
|
|
|
|
:rules="[{ required: subItem.action === 'replace' || subItem.action === 'labelmap', message: $t('validate.required'), trigger: 'change' }]">
|
|
|
|
|
|
<el-input id="module-box-input-replacement" v-model="subItem.replacement" :placeholder="$t('overall.relabelConfigReplacement')" size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</transition>
|
|
|
|
|
|
<div style="text-align: center">
|
|
|
|
|
|
<span class="nz-btn nz-btn-size-normal nz-btn-style-light" style="border: none" @click="subItem.showAllRelabelOption=!subItem.showAllRelabelOption">
|
|
|
|
|
|
{{$t('overall.moreOption')}}
|
|
|
|
|
|
<i :class="subItem.showAllRelabelOption?'is-active':''" class="nz-icon nz-icon-arrow-down need-rotate" ></i>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2021-08-03 10:14:37 +08:00
|
|
|
|
</div>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<div style="text-align: center">
|
|
|
|
|
|
<span id="module-add-relabel" class="right-box-form-add module-add-label margin-t-10" type="button" @click="logsAddRelabel(index)">
|
|
|
|
|
|
<span :title="$t('tip.add')"><i class="nz-icon nz-icon-plus" style="font-size: 16px;"></i></span>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</el-tab-pane>
|
|
|
|
|
|
<!-- Pipeline -->
|
|
|
|
|
|
<el-tab-pane :label="$t('project.endpoint.pipeline')" name="Pipeline">
|
|
|
|
|
|
<div v-for="(item2, index2) in item.pipeline" :key="index2">
|
|
|
|
|
|
<div class="pipeline-box">
|
|
|
|
|
|
<span class="pipeline-title">{{item2.type}}</span>
|
|
|
|
|
|
<span class="pipeline-option">
|
|
|
|
|
|
<pipelineSelect :index="index2" :father-pipeline="item.pipeline" @addPipeline="(pipelineIndex,obj)=>{addPipeline(obj,index,pipelineIndex,'splice')}" :type="'splice'"/>
|
|
|
|
|
|
<i class="nz-icon nz-icon-shanchu1" @click="delPipeline(index,index2)" :title="$t('overall.delete')"></i>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="item2.type === 'regex'">
|
2021-08-16 16:14:48 +08:00
|
|
|
|
<el-form-item
|
2022-10-09 11:28:00 +08:00
|
|
|
|
:label="'Expression'"
|
|
|
|
|
|
:prop="'configs.1.config.'+ index +'.pipeline.' + index2 + '.expression'"
|
2023-07-25 18:09:15 +08:00
|
|
|
|
:rules="[{ required: false, message: $t('validate.required'), trigger: 'blur' }]"
|
2021-08-16 16:14:48 +08:00
|
|
|
|
>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<el-input v-model="item2.expression" placeholder="" size="mini"></el-input>
|
2021-08-16 16:14:48 +08:00
|
|
|
|
</el-form-item>
|
2021-08-03 10:14:37 +08:00
|
|
|
|
<el-form-item
|
2022-10-09 11:28:00 +08:00
|
|
|
|
:label="'Source'"
|
|
|
|
|
|
:prop="'configs.1.config.'+ index +'.pipeline.' + index2 + '.source'"
|
2023-07-25 18:09:15 +08:00
|
|
|
|
:rules="[{ required: false, message: $t('validate.required'), trigger: 'blur' }]"
|
2021-08-03 10:14:37 +08:00
|
|
|
|
>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<el-input v-model="item2.source" placeholder="" size="mini"></el-input>
|
2021-08-03 10:14:37 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<div v-if="item2.type === 'json'">
|
2023-07-25 18:09:15 +08:00
|
|
|
|
<label class="module-form__label required-content">Expressions</label>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<div v-for="(expressions, eindex) in item2.expressions" :key="eindex" style="display: flex;justify-content: space-around;align-items: center;margin-bottom: 16px">
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
:prop="'configs.1.config.'+ index +'.pipeline.' + index2 + '.expressions.'+eindex+'.key'"
|
|
|
|
|
|
:rules="[{ required: true, message: $t('validate.required'), trigger: 'blur' }]"
|
|
|
|
|
|
style="width: 45%;margin: 0"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input v-model="item2.expressions[eindex].key" placeholder="key" size="mini" ></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<span class="param-box-row-eq">=</span>
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
:prop="'configs.1.config.'+ index +'.pipeline.' + index2 + '.expressions.'+eindex+'.value'"
|
|
|
|
|
|
:rules="[{ required: true, message: $t('validate.required'), trigger: 'blur' }]"
|
|
|
|
|
|
style="width: 45%;margin: 0"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input v-model="item2.expressions[eindex].value" placeholder="value" size="mini" ></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<i class="nz-icon nz-icon-plus" @click="addPipelineItem(index, index2)" :title="$t('tip.add')"></i>
|
2022-10-19 10:02:12 +08:00
|
|
|
|
<i class="nz-icon nz-icon-shanchu1" @click="delPipelineItem(index, index2, eindex)" :title="$t('overall.delete')"></i>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
</div>
|
2021-08-03 10:14:37 +08:00
|
|
|
|
<el-form-item
|
2022-10-09 11:28:00 +08:00
|
|
|
|
:label="'Source'"
|
|
|
|
|
|
:prop="'configs.1.config.'+ index +'.pipeline.' + index2 + '.source'"
|
2021-08-03 10:14:37 +08:00
|
|
|
|
:rules="[{ required: true, message: $t('validate.required'), trigger: 'blur' }]"
|
|
|
|
|
|
>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<el-input v-model="item2.source" placeholder="" size="mini"></el-input>
|
2021-08-03 10:14:37 +08:00
|
|
|
|
</el-form-item>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="item2.type === 'template'">
|
2021-08-03 10:14:37 +08:00
|
|
|
|
<el-form-item
|
2022-10-09 11:28:00 +08:00
|
|
|
|
:label="'Source'"
|
|
|
|
|
|
:prop="'configs.1.config.'+ index +'.pipeline.' + index2 + '.source'"
|
2021-08-03 10:14:37 +08:00
|
|
|
|
:rules="[{ required: true, message: $t('validate.required'), trigger: 'blur' }]"
|
|
|
|
|
|
>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<el-input v-model="item2.source" placeholder="key" size="mini"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
:label="'Template'"
|
|
|
|
|
|
:prop="'configs.1.config.'+ index +'.pipeline.' + index2 + '.template'"
|
|
|
|
|
|
:rules="[{ required: true, message: $t('validate.required'), trigger: 'blur' }]"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input v-model="item2.template" placeholder="" size="mini"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="item2.type === 'timestamp'">
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
:label="'Source'"
|
|
|
|
|
|
:prop="'configs.1.config.'+ index +'.pipeline.' + index2 + '.source'"
|
|
|
|
|
|
:rules="[{ required: true, message: $t('validate.required'), trigger: 'blur' }]"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input v-model="item2.source" placeholder="" size="mini"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
:label="'Format'"
|
|
|
|
|
|
:prop="'configs.1.config.'+ index +'.pipeline.' + index2 + '.format'"
|
2022-11-18 15:27:52 +08:00
|
|
|
|
:rules="[{ required: true, message: $t('validate.required'), trigger: 'change' }]"
|
2022-10-09 11:28:00 +08:00
|
|
|
|
>
|
|
|
|
|
|
<el-select v-model="item2.format" :id="'timestamp' + index +'-' + index2" class="right-box__select" placeholder="" popper-class="right-box-select-top prevent-clickoutside" size="small">
|
|
|
|
|
|
<el-option v-for="item in timestampList" :id="'module-timestamp-'+item" :key="item" :label="item" :value="item"></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="item2.type === 'labels'">
|
2023-07-25 18:09:15 +08:00
|
|
|
|
<label class="module-form__label required-content" style="padding-bottom: 6px;font-size: 14px;line-height: 16px;color: #666;">Key/value</label>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<div v-for="(expressions, eindex) in item2.labels" :key="eindex" style="display: flex;justify-content: space-around;align-items: center;margin-bottom: 16px">
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
:prop="'configs.1.config.'+ index +'.pipeline.' + index2 + '.labels.'+eindex+'.key'"
|
|
|
|
|
|
:rules="[{ required: true, message: $t('validate.required'), trigger: 'blur' }]"
|
|
|
|
|
|
style="width: 45%;margin: 0"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input v-model="item2.labels[eindex].key" placeholder="key" size="mini" ></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
=
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
:prop="'configs.1.config.'+ index +'.pipeline.' + index2 + '.labels.'+eindex+'.value'"
|
|
|
|
|
|
:rules="[{ required: true, message: $t('validate.required'), trigger: 'blur' }]"
|
|
|
|
|
|
style="width: 45%;margin: 0"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input v-model="item2.labels[eindex].value" placeholder="value" size="mini" ></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<i class="nz-icon nz-icon-plus" @click="addPipelineItem(index, index2)" :title="$t('tip.add')"></i>
|
2022-10-19 10:02:12 +08:00
|
|
|
|
<i class="nz-icon nz-icon-shanchu1" @click="delPipelineItem(index, index2, eindex)" :title="$t('overall.delete')"></i>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="item2.type === 'output'">
|
|
|
|
|
|
<el-form-item
|
|
|
|
|
|
:label="'Source'"
|
|
|
|
|
|
:prop="'configs.1.config.'+ index +'.pipeline.' + index2 + '.source'"
|
|
|
|
|
|
:rules="[{ required: true, message: $t('validate.required'), trigger: 'blur' }]"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-input v-model="item2.source" placeholder="" size="mini"></el-input>
|
2021-08-03 10:14:37 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
<div style="text-align: center">
|
|
|
|
|
|
<div class="value-mapping-add module-box-add" style="text-align: center;width: 30px;display: inline-block;">
|
|
|
|
|
|
<pipelineSelect :index="item.pipeline.length - 1" :father-pipeline="item.pipeline" @addPipeline="(pipelineIndex,obj)=>{addPipeline(obj,index,pipelineIndex,'push')}" :type="'push'"/>
|
|
|
|
|
|
</div>
|
2021-08-03 10:14:37 +08:00
|
|
|
|
</div>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
</el-tab-pane>
|
|
|
|
|
|
<!-- Authentication -->
|
|
|
|
|
|
<el-tab-pane v-if="item.type==='kubernetes'" :label="$t('config.mib.credential.auth')" name="Auth">
|
|
|
|
|
|
<!--authtype-->
|
|
|
|
|
|
<el-form-item :label='$t("overall.type")' prop="authtype">
|
|
|
|
|
|
<el-select id="module-box-input-auth-type" v-model="logsAuthType[index]" class="right-box__select" placeholder="" popper-class="right-box-select-top prevent-clickoutside" size="small" value-key="id" @change="logsAuthTypeChange(item)">
|
|
|
|
|
|
<el-option v-for="item in authTypeList" :id="'module-type-'+item.id" :key="item.value" :label="item.name" :value="item.value"></el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<!--authtype 1-->
|
|
|
|
|
|
<el-form-item v-if="logsAuthType[index] === 1" :label='$t("profile.username")' class="half-form-item" :prop="'configs.1.config.'+index+'.basic_auth.username'" :rules="[{ required: true, message: $t('validate.required'), trigger: 'blur' }]" key="username">
|
|
|
|
|
|
<el-input id="module-box-input-uername" v-model="item.basic_auth.username" placeholder='' size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item v-if="logsAuthType[index] === 1" :label='$t("login.pin")' class="half-form-item" :prop="'configs.1.config.'+index+'.basic_auth.password'" :rules="[{ required: true, message: $t('validate.required'), trigger: 'blur' }]" key="password">
|
2023-01-04 17:49:28 +08:00
|
|
|
|
<el-input id="module-box-input-password" v-model="item.basic_auth.password" type="password" auto-complete="new-password" autocomplete="new-password" placeholder='' size="small"></el-input>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<!--authtype 2-->
|
|
|
|
|
|
<el-form-item v-if="logsAuthType[index] === 2" :label='$t("project.endpoint.authTypeToken")' :prop="'configs.1.config.'+index+'.bearer_token'" :rules="[{ required: true, message: $t('validate.required'), trigger: 'blur' }]" key="bearer_token">
|
|
|
|
|
|
<el-input id="module-box-input-bearer_token" v-model="item.bearer_token" placeholder='' size="small"></el-input>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-tab-pane>
|
|
|
|
|
|
|
|
|
|
|
|
</el-tabs>
|
|
|
|
|
|
<span class="nz-icon-minus-medium" :title="$t('overall.delete')">
|
2022-10-11 09:39:56 +08:00
|
|
|
|
<i class="nz-icon nz-icon-minus" @click="removeLogsArr(index)"></i>
|
|
|
|
|
|
</span>
|
2022-10-09 11:28:00 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div class="value-mapping-add" style="text-align: center;margin: 10px 144px 10px 144px;" @click="logsArrAdd()" :title="$t('tip.add')">
|
|
|
|
|
|
<i class="nz-icon nz-icon-plus"></i>
|
|
|
|
|
|
</div>
|
2021-08-03 10:14:37 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</transition>
|
|
|
|
|
|
|
|
|
|
|
|
<!--Preview-->
|
|
|
|
|
|
<div class="right-box-sub-title" :style="`margin-top:${logsShow&&editModule.configs[1].enable?'0':'10px'}`">
|
|
|
|
|
|
{{$t('overall.preview')}}
|
2021-08-02 11:47:34 +08:00
|
|
|
|
</div>
|
2021-08-03 10:14:37 +08:00
|
|
|
|
<div class="right-box-line"></div>
|
|
|
|
|
|
<div id="module-box-preview" ref="previewBoxScrollbar" class="configs-copy-value" style="overflow: auto;">
|
2022-07-01 09:39:20 +08:00
|
|
|
|
<span class="copy-value-content" :title="$t('overall.duplicate')"> <i class="nz-icon nz-icon-override" @click="copyValue"></i></span>
|
2021-11-19 18:21:10 +08:00
|
|
|
|
<pre>{{configsCopyValue}}</pre>
|
2021-05-21 19:28:50 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
</div>
|
2020-12-14 20:25:24 +08:00
|
|
|
|
</div>
|
2020-07-28 19:42:25 +08:00
|
|
|
|
|
|
|
|
|
|
<!--底部按钮-->
|
2021-05-11 10:37:58 +08:00
|
|
|
|
<div class="right-box__footer">
|
|
|
|
|
|
<button v-cancel="{obj:editModule,func:esc}" id="module-box-esc" class="footer__btn footer__btn--light">
|
2020-07-28 19:42:25 +08:00
|
|
|
|
<span>{{$t('overall.cancel')}}</span>
|
|
|
|
|
|
</button>
|
2021-05-11 10:37:58 +08:00
|
|
|
|
<button :class="{'nz-btn-disabled':prevent_opt.save}" v-has="'monitor_module_add'" :disabled="prevent_opt.save" @click="save" class="footer__btn" id="module-box-save">
|
2020-07-28 19:42:25 +08:00
|
|
|
|
<span>{{$t('overall.save')}}</span>
|
|
|
|
|
|
</button>
|
2019-12-18 17:00:44 +08:00
|
|
|
|
</div>
|
2020-07-28 19:42:25 +08:00
|
|
|
|
</div>
|
2019-12-18 17:00:44 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2024-05-13 16:02:15 +08:00
|
|
|
|
import { nameValidate, port, nzNumber, arrLength } from '../js/validate'
|
2021-03-19 18:52:19 +08:00
|
|
|
|
import selectWalk from '../popBox/selectWalk'
|
2021-07-05 14:43:47 +08:00
|
|
|
|
import editRigthBox from '../mixin/editRigthBox'
|
2021-08-02 11:47:34 +08:00
|
|
|
|
import pipelineSelect from './pipelineSelect'
|
2021-04-22 10:36:29 +08:00
|
|
|
|
import VueTagsInput from '@johmun/vue-tags-input'
|
2021-03-19 18:52:19 +08:00
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: 'moduleBox',
|
|
|
|
|
|
props: {
|
|
|
|
|
|
module: Object,
|
|
|
|
|
|
currentProject: Object
|
|
|
|
|
|
},
|
|
|
|
|
|
components: {
|
2021-04-22 10:36:29 +08:00
|
|
|
|
'select-walk': selectWalk,
|
2021-08-02 11:47:34 +08:00
|
|
|
|
VueTagsInput,
|
|
|
|
|
|
pipelineSelect
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
2021-07-05 14:43:47 +08:00
|
|
|
|
mixins: [editRigthBox],
|
2021-03-19 18:52:19 +08:00
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
|
|
|
|
|
walkData: [],
|
2021-11-09 09:58:36 +08:00
|
|
|
|
requirdRelabel (rule, value, callback) {
|
|
|
|
|
|
callback()
|
|
|
|
|
|
},
|
2022-11-23 11:09:05 +08:00
|
|
|
|
dashboardList: [], // dashboard 列表数据
|
2021-04-13 19:06:34 +08:00
|
|
|
|
activeName: 'Basic',
|
2021-08-02 11:47:34 +08:00
|
|
|
|
activeNameLogs: ['Basic'],
|
|
|
|
|
|
pipelineOptionValue: '',
|
2021-03-19 18:52:19 +08:00
|
|
|
|
expandedWalkData: [],
|
2021-04-13 19:06:34 +08:00
|
|
|
|
radio: 'password',
|
2021-03-19 18:52:19 +08:00
|
|
|
|
editModule: {},
|
2021-04-13 19:06:34 +08:00
|
|
|
|
restaurants: [
|
|
|
|
|
|
{ value: '{{module.name}}-{{asset.name}}' },
|
|
|
|
|
|
{ value: '{{module.name}}-{{asset.manageIp}}' }
|
|
|
|
|
|
],
|
2022-11-23 11:09:05 +08:00
|
|
|
|
DashboardSearchShowFields: [ // DashboardSearch 下拉搜索表头
|
2021-05-20 14:07:58 +08:00
|
|
|
|
{ title: 'ID', data: 'id' },
|
2021-08-05 14:50:29 +08:00
|
|
|
|
{
|
2022-06-16 15:58:17 +08:00
|
|
|
|
title: this.$t('overall.name'),
|
2021-08-05 14:50:29 +08:00
|
|
|
|
data: function (row) {
|
|
|
|
|
|
if (row.name.length > 15) {
|
|
|
|
|
|
return row.name.substring(0, 12) + '...'
|
|
|
|
|
|
}
|
|
|
|
|
|
return row.name
|
2021-12-02 16:42:37 +08:00
|
|
|
|
},
|
2023-12-13 10:21:21 +08:00
|
|
|
|
tip: function (row) {
|
|
|
|
|
|
return row.name
|
|
|
|
|
|
}
|
2021-08-05 14:50:29 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: this.$t('overall.remark'),
|
|
|
|
|
|
data: function (row) {
|
|
|
|
|
|
if (row.remark && row.remark.length > 15) {
|
|
|
|
|
|
return row.remark.substring(0, 12) + '...'
|
|
|
|
|
|
}
|
|
|
|
|
|
return row.remark
|
2021-12-02 16:42:37 +08:00
|
|
|
|
},
|
2023-12-13 10:21:21 +08:00
|
|
|
|
tip: function (row) {
|
|
|
|
|
|
return row.remark
|
|
|
|
|
|
}
|
2021-08-05 14:50:29 +08:00
|
|
|
|
}
|
2021-05-20 14:07:58 +08:00
|
|
|
|
],
|
2021-04-13 19:06:34 +08:00
|
|
|
|
showAllBasicOption: false,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
rules: {
|
|
|
|
|
|
name: [
|
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' },
|
2024-05-13 16:02:15 +08:00
|
|
|
|
{ validator: nameValidate, trigger: 'blur' }
|
2021-03-19 18:52:19 +08:00
|
|
|
|
],
|
2021-04-13 19:06:34 +08:00
|
|
|
|
projectId: [
|
2021-03-19 18:52:19 +08:00
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'change' }
|
|
|
|
|
|
],
|
|
|
|
|
|
walk: [
|
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
|
|
|
|
|
],
|
|
|
|
|
|
username: [
|
|
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
|
|
|
|
|
],
|
2021-04-27 20:31:54 +08:00
|
|
|
|
pin: [
|
2021-03-19 18:52:19 +08:00
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
|
|
|
|
|
],
|
2021-04-27 20:31:54 +08:00
|
|
|
|
priv_pin: [
|
2021-03-19 18:52:19 +08:00
|
|
|
|
{ required: true, message: this.$t('validate.required'), trigger: 'blur' }
|
|
|
|
|
|
],
|
|
|
|
|
|
max_repetitions: [
|
|
|
|
|
|
{ validator: nzNumber, trigger: 'blur' }
|
|
|
|
|
|
],
|
|
|
|
|
|
retries: [
|
|
|
|
|
|
{ validator: nzNumber, trigger: 'blur' }
|
|
|
|
|
|
],
|
|
|
|
|
|
timeout: [
|
|
|
|
|
|
{ validator: nzNumber, trigger: 'blur' }
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
2021-04-13 19:06:34 +08:00
|
|
|
|
projectList: [],
|
|
|
|
|
|
credentialList: [],
|
2021-08-03 10:14:37 +08:00
|
|
|
|
typeList: [
|
2021-04-13 19:06:34 +08:00
|
|
|
|
{
|
|
|
|
|
|
value: 'http',
|
2021-10-18 17:06:08 +08:00
|
|
|
|
name: 'HTTP',
|
|
|
|
|
|
disabled: false
|
2021-04-13 19:06:34 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2021-10-18 17:06:08 +08:00
|
|
|
|
value: 'https',
|
|
|
|
|
|
name: 'HTTPS',
|
|
|
|
|
|
disabled: false
|
2021-10-11 10:18:45 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2021-10-18 17:06:08 +08:00
|
|
|
|
value: 'snmp',
|
|
|
|
|
|
name: 'SNMP',
|
|
|
|
|
|
disabled: true
|
2021-04-13 19:06:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
],
|
2021-08-02 11:47:34 +08:00
|
|
|
|
logsBasicList: [
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'file',
|
|
|
|
|
|
name: 'File'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'journal',
|
|
|
|
|
|
name: 'Journal'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'syslog',
|
|
|
|
|
|
name: 'Syslog'
|
2022-10-09 11:28:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'kubernetes',
|
|
|
|
|
|
name: 'Kubernetes'
|
2021-08-02 11:47:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
],
|
2021-04-13 19:06:34 +08:00
|
|
|
|
authType: 0,
|
|
|
|
|
|
authTypeList: [
|
2022-06-16 15:58:17 +08:00
|
|
|
|
{ name: this.$t('project.topology.none'), value: 0 },
|
2021-04-13 19:06:34 +08:00
|
|
|
|
{ name: this.$t('project.endpoint.authTypeWord'), value: 1 },
|
|
|
|
|
|
{ name: this.$t('project.endpoint.authTypeToken'), value: 2 }
|
2021-04-14 15:38:37 +08:00
|
|
|
|
],
|
2022-10-09 11:28:00 +08:00
|
|
|
|
|
|
|
|
|
|
logsAuthType: [0],
|
2021-08-02 11:47:34 +08:00
|
|
|
|
configsCopyValue: '',
|
|
|
|
|
|
logsCopyValue: [],
|
|
|
|
|
|
pipelineOption: [
|
|
|
|
|
|
{
|
|
|
|
|
|
label: 'Parsing stages',
|
|
|
|
|
|
pipelineOption: [
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'regex',
|
|
|
|
|
|
label: 'Regex'
|
|
|
|
|
|
}, {
|
|
|
|
|
|
value: 'json',
|
|
|
|
|
|
label: 'Json'
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
label: 'Transform stages',
|
|
|
|
|
|
pipelineOption: [
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'template',
|
|
|
|
|
|
label: 'Template'
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
label: 'Action stages',
|
|
|
|
|
|
pipelineOption: [
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'timestamp',
|
|
|
|
|
|
label: 'Timestamp'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'labels',
|
|
|
|
|
|
label: 'Labels'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'output',
|
|
|
|
|
|
label: 'Output'
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
2021-08-03 10:14:37 +08:00
|
|
|
|
}],
|
2021-08-16 16:14:48 +08:00
|
|
|
|
timestampList: ['ANSIC', 'UnixDate', 'RubyDate', 'RFC822', 'RFC822Z', 'RFC850', 'RFC1123', 'RFC1123Z', 'RFC3339', 'RFC3339Nano', 'Unix', 'UnixMs', 'UnixUs', 'UnixNs'],
|
2021-08-19 15:54:38 +08:00
|
|
|
|
actionList: [{
|
|
|
|
|
|
value: 'replace',
|
|
|
|
|
|
label: 'Replace'
|
|
|
|
|
|
}, {
|
|
|
|
|
|
value: 'keep',
|
|
|
|
|
|
label: 'Keep'
|
|
|
|
|
|
}, {
|
|
|
|
|
|
value: 'drop',
|
|
|
|
|
|
label: 'Drop'
|
|
|
|
|
|
}, {
|
|
|
|
|
|
value: 'labelmap',
|
|
|
|
|
|
label: 'Labelmap'
|
|
|
|
|
|
}, {
|
|
|
|
|
|
value: 'labeldrop',
|
|
|
|
|
|
label: 'Labeldrop'
|
|
|
|
|
|
}, {
|
|
|
|
|
|
value: 'labelkeep',
|
|
|
|
|
|
label: 'Labelkeep'
|
|
|
|
|
|
}],
|
2021-08-03 10:14:37 +08:00
|
|
|
|
metricsShow: true,
|
2022-10-09 11:28:00 +08:00
|
|
|
|
logsShow: true,
|
|
|
|
|
|
|
|
|
|
|
|
logsRoleList: [
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'endpoints',
|
|
|
|
|
|
label: 'endpoints'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'service',
|
|
|
|
|
|
label: 'service'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'pod',
|
|
|
|
|
|
label: 'pod'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'node',
|
|
|
|
|
|
label: 'node'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
value: 'ingress',
|
|
|
|
|
|
label: 'ingress'
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2021-08-02 11:47:34 +08:00
|
|
|
|
port: port,
|
2021-08-19 15:54:38 +08:00
|
|
|
|
arrLength: arrLength,
|
2021-03-19 18:52:19 +08:00
|
|
|
|
selectWalk (walk) {
|
2021-08-04 16:55:11 +08:00
|
|
|
|
if (this.editModule.configs[0].config.walk.indexOf(walk) != -1) {
|
|
|
|
|
|
this.editModule.configs[0].config.walk.splice(this.editModule.configs[0].config.walk.indexOf(walk), 1)
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} else {
|
2021-08-04 16:55:11 +08:00
|
|
|
|
this.editModule.configs[0].config.walk.push(walk)
|
2019-12-18 17:00:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// 从mibData里取得oid对应的mib名称
|
|
|
|
|
|
getMibName (walkData, walk) {
|
|
|
|
|
|
let mibName = ''
|
|
|
|
|
|
let objectName = ''
|
|
|
|
|
|
walkData.forEach((item, index) => {
|
|
|
|
|
|
if (!mibName && item.subTree && item.subTree.length > 0) {
|
|
|
|
|
|
item.subTree.forEach((item2, index2) => {
|
|
|
|
|
|
if (!mibName && getMibName(item2, walk)) {
|
|
|
|
|
|
mibName = item.name
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2020-04-04 21:10:52 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
function getMibName (tree, oid) {
|
|
|
|
|
|
if (oid.indexOf(tree.objectID) > -1) {
|
|
|
|
|
|
if (tree.objectID == oid) {
|
|
|
|
|
|
objectName = tree.name
|
|
|
|
|
|
return true
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (tree.subTree && tree.subTree.length > 0) {
|
|
|
|
|
|
let result = false
|
|
|
|
|
|
for (let i = 0; i < tree.subTree.length; i++) {
|
|
|
|
|
|
if (getMibName(tree.subTree[i], oid)) {
|
|
|
|
|
|
result = true
|
|
|
|
|
|
break
|
2020-04-06 13:06:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
return result
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return false
|
2020-04-06 13:06:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
return false
|
2020-04-06 13:06:15 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (!objectName) {
|
|
|
|
|
|
objectName = walk
|
|
|
|
|
|
}
|
|
|
|
|
|
objectName = "<span style='font-weight:bold'>" + objectName + '</span>'
|
|
|
|
|
|
return mibName ? mibName + ':' + objectName : objectName
|
|
|
|
|
|
},
|
2020-04-04 21:10:52 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
removeWalk (walk) {
|
2021-08-04 16:55:11 +08:00
|
|
|
|
this.editModule.configs[0].config.walk.splice(this.editModule.configs[0].config.walk.indexOf(walk), 1)
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$refs.selectWalk.$refs.walkTree.setChecked(walk, false)
|
|
|
|
|
|
},
|
2020-04-02 20:23:52 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
initWalk () {
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
if (this.$refs.selectWalk) {
|
|
|
|
|
|
this.$refs.selectWalk.show()
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2020-04-02 20:23:52 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
getWalkData () {
|
|
|
|
|
|
this.$get('mib/tree', { pageSize: -1, pageNo: 1 }).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
const obj = JSON.parse(response.data)
|
|
|
|
|
|
this.walkData = []
|
|
|
|
|
|
for (const item in obj) {
|
|
|
|
|
|
setAttr(obj[item], 'detailShow', false)
|
|
|
|
|
|
this.walkData.push({ name: item, detailShow: false, subTree: obj[item] })
|
2020-04-02 20:23:52 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
function setAttr (tree, name, value) {
|
|
|
|
|
|
if (tree && tree.length > 0) {
|
|
|
|
|
|
for (let i = 0; i < tree.length; i++) {
|
|
|
|
|
|
tree[i][name] = value
|
|
|
|
|
|
if (tree[i].subTree && tree[i].subTree.length > 0) {
|
|
|
|
|
|
setAttr(tree[i].subTree, name, value)
|
2020-04-06 22:11:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-04-02 20:23:52 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
/* 关闭弹框 */
|
|
|
|
|
|
esc (refresh) {
|
|
|
|
|
|
this.$emit('close', refresh)
|
|
|
|
|
|
},
|
2019-12-18 17:00:44 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
clickOutside () {
|
|
|
|
|
|
this.esc(false)
|
|
|
|
|
|
},
|
|
|
|
|
|
changeType (type) {
|
|
|
|
|
|
if (this.editModule.id) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
this.editModule.type = type
|
2021-10-11 10:18:45 +08:00
|
|
|
|
if (type == 'snmp') {
|
2021-05-21 22:15:40 +08:00
|
|
|
|
this.$refs.selectWalk.show()
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
/* 保存 */
|
|
|
|
|
|
save () {
|
2021-07-05 17:14:53 +08:00
|
|
|
|
setTimeout(() => {
|
2021-08-02 11:47:34 +08:00
|
|
|
|
this.editModule.configs[0].config.params = this.paramToJson(this.editModule.paramObj)
|
|
|
|
|
|
this.editModule.configs[0].config.labels = this.labelsToJson(this.editModule.labelModule)
|
2021-08-06 10:12:09 +08:00
|
|
|
|
const params = JSON.parse(JSON.stringify(this.editModule))
|
|
|
|
|
|
params.configs[1].config.forEach(item => {
|
2021-08-03 14:12:14 +08:00
|
|
|
|
if (item.labelModule) {
|
|
|
|
|
|
item.labels = this.labelsToJson(item.labelModule)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
item.labels = ''
|
2021-08-02 11:47:34 +08:00
|
|
|
|
}
|
2021-08-06 10:12:09 +08:00
|
|
|
|
delete item.labelModule
|
2021-08-02 11:47:34 +08:00
|
|
|
|
})
|
2021-08-06 10:12:09 +08:00
|
|
|
|
delete params.labelModule
|
|
|
|
|
|
delete params.paramObj
|
2021-08-03 14:12:14 +08:00
|
|
|
|
params.configs[1].config.forEach(item => {
|
|
|
|
|
|
item.pipeline && item.pipeline.forEach((pipeline) => {
|
|
|
|
|
|
if (pipeline.type === 'labels') {
|
|
|
|
|
|
pipeline.labels = this.labelsToJson(pipeline.labels)
|
|
|
|
|
|
}
|
2021-08-16 16:14:48 +08:00
|
|
|
|
if (pipeline.type === 'json') {
|
|
|
|
|
|
pipeline.expressions = this.labelsToJson(pipeline.expressions)
|
|
|
|
|
|
}
|
2021-08-03 14:12:14 +08:00
|
|
|
|
})
|
2022-10-09 11:28:00 +08:00
|
|
|
|
item.namespaces && delete item.namespaces.tags
|
|
|
|
|
|
item.relabel_config && item.relabel_config.forEach(subItem => {
|
|
|
|
|
|
delete subItem.tags
|
|
|
|
|
|
delete subItem.showAllRelabelOption
|
|
|
|
|
|
})
|
2021-08-03 14:12:14 +08:00
|
|
|
|
})
|
2021-08-20 14:33:59 +08:00
|
|
|
|
params.configs[0].config.relabel_config && params.configs[0].config.relabel_config.forEach(item => {
|
2021-08-19 15:54:38 +08:00
|
|
|
|
delete item.tags
|
|
|
|
|
|
delete item.showAllRelabelOption
|
|
|
|
|
|
})
|
2021-08-03 14:12:14 +08:00
|
|
|
|
params.configs = JSON.stringify(params.configs)
|
2021-08-03 10:14:37 +08:00
|
|
|
|
this.$refs.moduleForm.validate((valid, errorKey) => {
|
|
|
|
|
|
let key = Object.keys(errorKey)
|
|
|
|
|
|
if (key.length) {
|
|
|
|
|
|
key = key[0]
|
|
|
|
|
|
if (key.indexOf('configs.0') !== -1) {
|
|
|
|
|
|
const keyArr = key.split('.')
|
|
|
|
|
|
if (keyArr[3] === 'basic_auth' || keyArr[3] === 'bearer_token') {
|
|
|
|
|
|
this.activeName = 'Auth'
|
2021-08-19 15:54:38 +08:00
|
|
|
|
} else if (keyArr[3] === 'basic' || keyArr[3] === 'port' || keyArr[3] === 'host') {
|
2021-08-03 10:14:37 +08:00
|
|
|
|
this.activeName = 'Basic'
|
2021-08-19 15:54:38 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.activeName = 'Relabel'
|
2021-08-03 10:14:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
} else if (key.indexOf('configs.1') !== -1) {
|
|
|
|
|
|
const keyArr = key.split('.')
|
2021-08-05 16:11:46 +08:00
|
|
|
|
const str = keyArr[4]
|
|
|
|
|
|
if (str === 'fileName' || str === 'unit' || str === 'listenAddress' || str === 'appName') {
|
|
|
|
|
|
this.activeNameLogs[keyArr[3]] = 'Basic'
|
|
|
|
|
|
} else if (str === 'labels') {
|
|
|
|
|
|
this.activeNameLogs[keyArr[3]] = 'Labels'
|
|
|
|
|
|
} else if (str === 'pipeline') {
|
|
|
|
|
|
this.activeNameLogs[keyArr[3]] = 'Pipeline'
|
2022-10-09 11:28:00 +08:00
|
|
|
|
} else if (str === 'relabel_config') {
|
|
|
|
|
|
this.activeNameLogs[keyArr[3]] = 'Relabel'
|
|
|
|
|
|
} else if (str === 'basic_auth' || str === 'bearer_token') {
|
|
|
|
|
|
this.activeNameLogs[keyArr[3]] = 'Auth'
|
2021-08-05 16:11:46 +08:00
|
|
|
|
}
|
2021-08-03 10:14:37 +08:00
|
|
|
|
this.activeNameLogs = [...this.activeNameLogs]
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-07-05 17:14:53 +08:00
|
|
|
|
if (valid) {
|
|
|
|
|
|
this.prevent_opt.save = true
|
2023-03-15 15:39:06 +08:00
|
|
|
|
params.dashboardId = this.editModule.dashboardId !== '' ? Number(this.editModule.dashboardId) : null
|
2021-07-05 17:14:53 +08:00
|
|
|
|
if (this.editModule.id) {
|
|
|
|
|
|
this.$put('monitor/module', params).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
2022-06-14 16:12:27 +08:00
|
|
|
|
// this.$message({ duration: 1000, type: 'success', message: this.$t('tip.saveSuccess') })
|
2022-07-06 18:58:40 +08:00
|
|
|
|
this.messageShow(this.$t('tip.saveSuccess'), '/endpoint', { projectId: this.editModule.projectId, moduleId: response.data.id }, false, 'tip.endpoint')
|
2021-07-05 17:14:53 +08:00
|
|
|
|
this.$store.commit('setReloadFacade')
|
|
|
|
|
|
this.esc(true)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg)
|
|
|
|
|
|
}
|
|
|
|
|
|
this.prevent_opt.save = false
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$post('monitor/module', params).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
2022-07-06 18:58:40 +08:00
|
|
|
|
this.messageShow(this.$t('tip.saveSuccess'), '/endpoint', { projectId: this.editModule.projectId, moduleId: response.data.id }, true, 'tip.endpoint')
|
2021-07-05 17:14:53 +08:00
|
|
|
|
this.$store.commit('setReloadFacade')
|
|
|
|
|
|
this.esc(true)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg)
|
|
|
|
|
|
}
|
|
|
|
|
|
this.prevent_opt.save = false
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.prevent_opt.save = false
|
|
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}, 10)
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
/* 删除 */
|
|
|
|
|
|
del () {
|
|
|
|
|
|
this.$confirm(this.$t('tip.confirmDelete'), {
|
|
|
|
|
|
confirmButtonText: this.$t('tip.yes'),
|
|
|
|
|
|
cancelButtonText: this.$t('tip.no'),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
2021-04-13 19:06:34 +08:00
|
|
|
|
this.$delete('monitor/module?ids=' + this.editModule.id).then(response => {
|
2019-12-18 17:00:44 +08:00
|
|
|
|
if (response.code === 200) {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.$message({ duration: 1000, type: 'success', message: this.$t('tip.deleteSuccess') })
|
|
|
|
|
|
this.$store.commit('setReloadFacade')
|
|
|
|
|
|
this.esc(true)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg)
|
2019-12-18 17:00:44 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2019-12-18 17:00:44 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
/* 获取project列表 */
|
|
|
|
|
|
getProjectList () {
|
2021-04-13 19:06:34 +08:00
|
|
|
|
this.$get('monitor/project', { pageSize: -1, pageNo: 1 }).then(response => {
|
2021-03-19 18:52:19 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.projectList = response.data.list
|
2019-12-18 17:00:44 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
2019-12-18 17:00:44 +08:00
|
|
|
|
},
|
2021-04-13 19:06:34 +08:00
|
|
|
|
// get snmp
|
|
|
|
|
|
getCredential () {
|
|
|
|
|
|
this.$get('/snmp/credential', { pageSize: -1, pageNo: 1 }).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.credentialList = response.data.list
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// 清除param
|
|
|
|
|
|
clearAllParam () {
|
2021-04-14 15:38:37 +08:00
|
|
|
|
this.editModule.paramObj = []
|
2020-04-02 20:23:52 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
|
|
|
|
|
|
// 新增param
|
|
|
|
|
|
addParam () {
|
2021-04-15 11:47:44 +08:00
|
|
|
|
this.editModule.paramObj.push({ key: '', value: [], showList: false })
|
2019-12-18 17:00:44 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// 移除单个param
|
|
|
|
|
|
removeParam (index) {
|
2021-04-16 15:02:40 +08:00
|
|
|
|
if (this.editModule.paramObj.length === 1) {
|
|
|
|
|
|
this.editModule.paramObj = [{ key: '', value: [] }]
|
|
|
|
|
|
}
|
2021-04-14 15:38:37 +08:00
|
|
|
|
this.editModule.paramObj.splice(index, 1)
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 新增label
|
|
|
|
|
|
addLabel () {
|
2021-04-14 15:38:37 +08:00
|
|
|
|
this.editModule.labelModule.push({ key: '', value: '' })
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
2021-08-02 11:47:34 +08:00
|
|
|
|
addLogsLabel (index) {
|
|
|
|
|
|
this.editModule.configs[1].config[index].labelModule.push({ key: '', value: '' })
|
|
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// 移除单个Label
|
|
|
|
|
|
removeLabel (index) {
|
2021-04-14 15:38:37 +08:00
|
|
|
|
if (this.editModule.labelModule.length === 1) {
|
2021-04-16 15:02:40 +08:00
|
|
|
|
this.editModule.labelModule = [{ key: '', value: '' }]
|
2021-08-02 11:47:34 +08:00
|
|
|
|
return
|
2021-04-14 15:38:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.editModule.labelModule.splice(index, 1)
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
2021-08-02 11:47:34 +08:00
|
|
|
|
removeLogsLabel (logsIndex, i) {
|
|
|
|
|
|
if (this.editModule.configs[1].config[logsIndex].labelModule.length === 1) {
|
|
|
|
|
|
this.editModule.configs[1].config[logsIndex].labelModule = [{ key: '', value: '' }]
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
this.editModule.configs[1].config[logsIndex].labelModule.splice(i, 1)
|
|
|
|
|
|
},
|
2021-08-20 13:53:31 +08:00
|
|
|
|
actionChange (index) {
|
2021-08-19 15:54:38 +08:00
|
|
|
|
this.$refs.moduleForm.clearValidate('configs.0.config.relabel_config.' + index + '.target_label')
|
2021-08-20 13:53:31 +08:00
|
|
|
|
this.$refs.moduleForm.clearValidate('configs.0.config.relabel_config.' + index + '.source_labels')
|
|
|
|
|
|
this.$refs.moduleForm.clearValidate('configs.0.config.relabel_config.' + index + '.regex')
|
|
|
|
|
|
this.$refs.moduleForm.clearValidate('configs.0.config.relabel_config.' + index + '.replacement')
|
2021-08-19 15:54:38 +08:00
|
|
|
|
},
|
2022-10-09 11:28:00 +08:00
|
|
|
|
logsActionChange (index, subIndex) {
|
2022-10-11 09:39:56 +08:00
|
|
|
|
this.$refs.moduleForm.clearValidate('configs.1.config.' + index + '.relabel_config.' + subIndex + '.target_label')
|
|
|
|
|
|
this.$refs.moduleForm.clearValidate('configs.1.config.' + index + '.relabel_config.' + subIndex + '.source_labels')
|
|
|
|
|
|
this.$refs.moduleForm.clearValidate('configs.1.config.' + index + '.relabel_config.' + subIndex + '.regex')
|
|
|
|
|
|
this.$refs.moduleForm.clearValidate('configs.1.config.' + index + '.relabel_config.' + subIndex + '.replacement')
|
2022-10-09 11:28:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
2021-08-19 15:54:38 +08:00
|
|
|
|
addRelabel () {
|
|
|
|
|
|
this.editModule.configs[0].config.relabel_config.push({
|
|
|
|
|
|
source_labels: [],
|
|
|
|
|
|
target_label: '',
|
2022-10-18 17:04:40 +08:00
|
|
|
|
action: 'replace',
|
2021-08-19 15:54:38 +08:00
|
|
|
|
regex: '(.*)',
|
|
|
|
|
|
replacement: '$1',
|
|
|
|
|
|
showAllRelabelOption: false
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
removeRelabel (index) {
|
|
|
|
|
|
// if (this.editModule.configs[0].config.relabel_config.length === 1) {
|
|
|
|
|
|
// this.editModule.configs[0].config.relabel_config = [{
|
|
|
|
|
|
// source_labels: [],
|
|
|
|
|
|
// target_label: '',
|
|
|
|
|
|
// action: '',
|
|
|
|
|
|
// regex: '',
|
|
|
|
|
|
// replacement: '',
|
|
|
|
|
|
// showAllRelabelOption: false
|
|
|
|
|
|
// }]
|
|
|
|
|
|
// return
|
|
|
|
|
|
// }
|
|
|
|
|
|
this.editModule.configs[0].config.relabel_config.splice(index, 1)
|
2022-08-30 14:16:03 +08:00
|
|
|
|
this.$refs.moduleForm.clearValidate()
|
2021-08-19 15:54:38 +08:00
|
|
|
|
},
|
2022-10-09 11:28:00 +08:00
|
|
|
|
|
|
|
|
|
|
logsAddRelabel (index) {
|
|
|
|
|
|
this.editModule.configs[1].config[index].relabel_config.push({
|
|
|
|
|
|
source_labels: [],
|
|
|
|
|
|
target_label: '',
|
2022-10-18 17:04:40 +08:00
|
|
|
|
action: 'replace',
|
2022-10-09 11:28:00 +08:00
|
|
|
|
regex: '(.*)',
|
|
|
|
|
|
replacement: '$1',
|
|
|
|
|
|
showAllRelabelOption: false
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
logsRemoveRelabel (index, subIndex) {
|
|
|
|
|
|
this.editModule.configs[1].config[index].relabel_config.splice(subIndex, 1)
|
|
|
|
|
|
this.$refs.moduleForm.clearValidate()
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2021-04-22 10:36:29 +08:00
|
|
|
|
tagsChange (newTags, index) {
|
|
|
|
|
|
this.editModule.paramObj[index].value = newTags.map(item => item.text)
|
|
|
|
|
|
},
|
2022-10-09 11:28:00 +08:00
|
|
|
|
logsTagsChange (newTags, item) {
|
|
|
|
|
|
this.$set(item.namespaces, 'names', newTags.map(item => item.text))
|
2021-08-19 15:54:38 +08:00
|
|
|
|
},
|
2022-10-09 11:28:00 +08:00
|
|
|
|
|
2021-08-20 13:53:31 +08:00
|
|
|
|
beforeAddingTag (tag) {
|
|
|
|
|
|
const regx = /[a-zA-Z_:][a-zA-Z0-9_:]*/
|
|
|
|
|
|
if (regx.test(tag.tag.text)) {
|
|
|
|
|
|
tag.addTag()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(this.$t('tip.tagError'))
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-10-09 11:28:00 +08:00
|
|
|
|
tagsChangeRelabel (newTags, index) {
|
|
|
|
|
|
this.editModule.configs[0].config.relabel_config[index].source_labels = newTags.map(item => item.text)
|
|
|
|
|
|
this.$refs.moduleForm.clearValidate('configs.0.config.relabel_config.' + index + '.source_labels')
|
|
|
|
|
|
},
|
2021-08-20 13:53:31 +08:00
|
|
|
|
relabelTabBlur (tag) {
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs.relabelTag[0].newTag = ''
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2022-10-09 11:28:00 +08:00
|
|
|
|
|
|
|
|
|
|
logsTagsChangeRelabel (newTags, index, subIndex) {
|
|
|
|
|
|
this.editModule.configs[1].config[index].relabel_config[subIndex].source_labels = newTags.map(item => item.text)
|
|
|
|
|
|
this.$refs.moduleForm.clearValidate('configs.1.config.' + index + '.relabel_config.' + subIndex + '.source_labels')
|
|
|
|
|
|
},
|
|
|
|
|
|
logsRelabelTabBlur (index, subIndex) {
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
this.$refs['logsRelabelTag' + index + subIndex][0].newTag = ''
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// 将param转为json字符串格式
|
|
|
|
|
|
paramToJson (param) {
|
|
|
|
|
|
const tempParam = {}
|
|
|
|
|
|
for (let i = 0; i < param.length; i++) {
|
2021-04-14 15:38:37 +08:00
|
|
|
|
if (!param[i].key || !param[i].value.length) {
|
|
|
|
|
|
continue
|
|
|
|
|
|
}
|
|
|
|
|
|
tempParam[param[i].key] = param[i].value
|
2020-04-06 13:06:15 +08:00
|
|
|
|
}
|
2021-04-14 15:38:37 +08:00
|
|
|
|
return tempParam
|
2019-12-31 19:02:58 +08:00
|
|
|
|
},
|
2021-03-19 18:52:19 +08:00
|
|
|
|
// 将labels转为json字符串格式
|
|
|
|
|
|
labelsToJson (param) {
|
|
|
|
|
|
const tempParam = {}
|
|
|
|
|
|
for (let i = 0; i < param.length; i++) {
|
2021-04-14 15:38:37 +08:00
|
|
|
|
if (!param[i].key || !param[i].value) {
|
|
|
|
|
|
continue
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
eval('tempParam["' + param[i].key + '"]="' + param[i].value + '"')
|
|
|
|
|
|
}
|
2021-04-14 15:38:37 +08:00
|
|
|
|
return tempParam
|
2021-04-13 19:06:34 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 输入建议
|
|
|
|
|
|
querySearch (queryString, cb) {
|
|
|
|
|
|
const restaurants = this.restaurants
|
|
|
|
|
|
const results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants
|
|
|
|
|
|
// 调用 callback 返回建议列表的数据
|
|
|
|
|
|
cb(results)
|
|
|
|
|
|
},
|
|
|
|
|
|
createFilter (queryString) {
|
|
|
|
|
|
return (restaurant) => {
|
|
|
|
|
|
return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-10-11 09:39:56 +08:00
|
|
|
|
|
2022-10-09 11:28:00 +08:00
|
|
|
|
changeBasicType () {
|
|
|
|
|
|
if (this.editModule.configs[0].config.protocol === 'snmp') {
|
|
|
|
|
|
this.editModule.configs[0].config.metrics_path = ''
|
|
|
|
|
|
this.editModule.configs[0].config.bearer_token = ''
|
|
|
|
|
|
this.editModule.configs[0].config.basic_auth = {
|
|
|
|
|
|
username: '',
|
|
|
|
|
|
password: ''
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-04-13 19:06:34 +08:00
|
|
|
|
changeAuthType () {
|
2021-08-02 11:47:34 +08:00
|
|
|
|
this.editModule.configs[0].config.bearer_token = ''
|
|
|
|
|
|
this.editModule.configs[0].config.basic_auth = {
|
2021-04-13 19:06:34 +08:00
|
|
|
|
username: '',
|
2022-07-11 14:58:05 +08:00
|
|
|
|
password: ''
|
2021-04-13 19:06:34 +08:00
|
|
|
|
}
|
2021-04-14 15:38:37 +08:00
|
|
|
|
},
|
2022-10-09 11:28:00 +08:00
|
|
|
|
|
|
|
|
|
|
logsAuthTypeChange (item) {
|
|
|
|
|
|
this.$set(item, 'bearer_token', '')
|
|
|
|
|
|
this.$set(item, 'basic_auth', {
|
|
|
|
|
|
username: '',
|
|
|
|
|
|
password: ''
|
|
|
|
|
|
})
|
2021-08-27 16:15:05 +08:00
|
|
|
|
},
|
2022-10-09 11:28:00 +08:00
|
|
|
|
logsArrAdd () {
|
2021-08-02 11:47:34 +08:00
|
|
|
|
this.activeNameLogs.push('Basic')
|
|
|
|
|
|
this.logsCopyValue.push('')
|
2022-10-09 11:28:00 +08:00
|
|
|
|
this.logsAuthType.push(0)
|
2021-08-02 11:47:34 +08:00
|
|
|
|
this.editModule.configs[1].config.push({
|
2021-08-04 16:55:11 +08:00
|
|
|
|
type: 'file',
|
|
|
|
|
|
fileName: '',
|
2021-08-06 14:57:29 +08:00
|
|
|
|
unit: '',
|
|
|
|
|
|
appName: '',
|
|
|
|
|
|
listenAddress: '',
|
2022-10-09 11:28:00 +08:00
|
|
|
|
apiServer: '',
|
|
|
|
|
|
role: '',
|
|
|
|
|
|
namespaces: {
|
|
|
|
|
|
tags: '',
|
|
|
|
|
|
names: []
|
|
|
|
|
|
},
|
2021-08-02 11:47:34 +08:00
|
|
|
|
labels: '',
|
|
|
|
|
|
labelModule: [{ key: '', value: '' }],
|
2022-10-09 11:28:00 +08:00
|
|
|
|
pipeline: [],
|
|
|
|
|
|
basic_auth: {
|
|
|
|
|
|
username: '',
|
|
|
|
|
|
password: ''
|
|
|
|
|
|
},
|
|
|
|
|
|
bearer_token: '',
|
|
|
|
|
|
relabel_config: []
|
2021-08-02 11:47:34 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
removeLogsArr (index) {
|
|
|
|
|
|
if (this.editModule.configs[1].config.length !== 1) {
|
2022-10-09 11:28:00 +08:00
|
|
|
|
this.activeNameLogs.splice(index, 1)
|
|
|
|
|
|
this.logsCopyValue.splice(index, 1)
|
|
|
|
|
|
this.logsAuthType.splice(index, 1)
|
2021-08-02 11:47:34 +08:00
|
|
|
|
this.editModule.configs[1].config.splice(index, 1)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-10-09 11:28:00 +08:00
|
|
|
|
logsBasicTypeChange (item, val) {
|
|
|
|
|
|
item.fileName = ''
|
|
|
|
|
|
item.unit = ''
|
|
|
|
|
|
item.appName = ''
|
|
|
|
|
|
item.listenAddress = ''
|
|
|
|
|
|
item.apiServer = ''
|
|
|
|
|
|
item.role = ''
|
2022-10-11 09:39:56 +08:00
|
|
|
|
this.$set(item, 'namespaces', {
|
2022-10-09 11:28:00 +08:00
|
|
|
|
tags: '',
|
|
|
|
|
|
names: []
|
2022-10-11 09:39:56 +08:00
|
|
|
|
})
|
2022-10-09 11:28:00 +08:00
|
|
|
|
if (val === 'kubernetes') {
|
|
|
|
|
|
item.apiServer = '127.0.0.1'
|
|
|
|
|
|
item.role = 'pod'
|
|
|
|
|
|
} else {
|
|
|
|
|
|
item.bearer_token = ''
|
|
|
|
|
|
item.basic_auth = {
|
|
|
|
|
|
username: '',
|
|
|
|
|
|
password: ''
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-08-02 11:47:34 +08:00
|
|
|
|
},
|
2022-10-11 09:39:56 +08:00
|
|
|
|
|
2021-04-14 15:38:37 +08:00
|
|
|
|
copyValue () {
|
2022-11-02 14:38:28 +08:00
|
|
|
|
this.$copyText(this.configsCopyValue).then(() => {
|
|
|
|
|
|
this.$message.success({ message: this.$t('overall.copySuccess') })
|
|
|
|
|
|
})
|
2021-04-14 15:38:37 +08:00
|
|
|
|
},
|
2021-08-02 11:47:34 +08:00
|
|
|
|
copyLogsValue (index) {
|
|
|
|
|
|
const domUrl = document.createElement('input')
|
|
|
|
|
|
domUrl.value = this.logsCopyValue[index]
|
|
|
|
|
|
domUrl.id = 'creatDom'
|
|
|
|
|
|
document.body.appendChild(domUrl)
|
|
|
|
|
|
domUrl.select() // 选择对象
|
|
|
|
|
|
document.execCommand('Copy') // 执行浏览器复制命令
|
|
|
|
|
|
const creatDom = document.getElementById('creatDom')
|
|
|
|
|
|
creatDom.parentNode.removeChild(creatDom)
|
|
|
|
|
|
this.$message.success(this.$t('overall.copySuccess'))
|
|
|
|
|
|
},
|
|
|
|
|
|
tabClick (index) {
|
|
|
|
|
|
if (this.activeNameLogs[index] === 'Preview') {
|
|
|
|
|
|
const params = JSON.parse(JSON.stringify(this.editModule.configs[1].config[index]))
|
|
|
|
|
|
params.labels = this.labelsToJson(params.labelModule)
|
|
|
|
|
|
delete params.labelModule
|
|
|
|
|
|
Object.keys(params).forEach(key => {
|
|
|
|
|
|
if (!params[key]) {
|
|
|
|
|
|
delete params[key]
|
|
|
|
|
|
}
|
|
|
|
|
|
if (Array.isArray(params[key]) && !params[key].length) {
|
|
|
|
|
|
delete params[key]
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
if (params.labels && !Object.keys(params.labels).length) {
|
|
|
|
|
|
delete params.labels
|
|
|
|
|
|
}
|
|
|
|
|
|
Object.keys(params.basic).forEach(key => {
|
|
|
|
|
|
if (!params.basic[key]) {
|
|
|
|
|
|
delete params.basic[key]
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
params.pipeline && params.pipeline.forEach(item => {
|
|
|
|
|
|
if (item.type === 'labels') {
|
|
|
|
|
|
item.labels = this.labelsToJson(item.labels)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.logsCopyValue[index] = JSON.stringify(params, null, 2)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2021-04-14 15:38:37 +08:00
|
|
|
|
syntaxHighlight (json) {
|
|
|
|
|
|
if (typeof json != 'string') {
|
|
|
|
|
|
json = JSON.stringify(json, undefined, 2)
|
|
|
|
|
|
}
|
|
|
|
|
|
json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
|
|
|
|
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,
|
|
|
|
|
|
function (match) {
|
|
|
|
|
|
let cls = 'number'
|
|
|
|
|
|
if (/^"/.test(match)) {
|
|
|
|
|
|
if (/:$/.test(match)) {
|
|
|
|
|
|
cls = 'key'
|
|
|
|
|
|
} else {
|
|
|
|
|
|
cls = 'string'
|
|
|
|
|
|
}
|
|
|
|
|
|
} else if (/true|false/.test(match)) {
|
|
|
|
|
|
cls = 'boolean'
|
|
|
|
|
|
} else if (/null/.test(match)) {
|
|
|
|
|
|
cls = 'null'
|
|
|
|
|
|
}
|
|
|
|
|
|
return '<span class="' + cls + '">' + match + '</span>'
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
2021-04-21 19:29:28 +08:00
|
|
|
|
},
|
|
|
|
|
|
paramObjchange (val, index) {
|
|
|
|
|
|
this.editModule.paramObj[index].value = val.filter(item => item.trim())
|
2021-05-20 14:07:58 +08:00
|
|
|
|
},
|
|
|
|
|
|
resultFormat (resp) {
|
|
|
|
|
|
if (resp && resp.data) {
|
|
|
|
|
|
const assetData = {}
|
|
|
|
|
|
assetData.list = resp.data.list
|
|
|
|
|
|
assetData.totalRow = resp.data.total
|
|
|
|
|
|
return assetData
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2022-11-23 11:09:05 +08:00
|
|
|
|
/* 获取Dashboard列表数据 */
|
|
|
|
|
|
DashboardTemplateList () {
|
2023-03-15 15:39:06 +08:00
|
|
|
|
this.$get('visual/dashboard', { pageSize: -1, varType: 2, type: 'template' }).then(res => {
|
2022-11-23 11:09:05 +08:00
|
|
|
|
this.dashboardList = res.data.list
|
2021-05-20 14:07:58 +08:00
|
|
|
|
})
|
2021-08-02 11:47:34 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 添加pipeline
|
|
|
|
|
|
addPipeline (obj, logsIndex, pipeLineIndex, type) {
|
|
|
|
|
|
if (type == 'splice') {
|
|
|
|
|
|
this.editModule.configs[1].config[logsIndex].pipeline.splice(pipeLineIndex, 0, obj)
|
|
|
|
|
|
}
|
|
|
|
|
|
if (type == 'push') {
|
|
|
|
|
|
this.editModule.configs[1].config[logsIndex].pipeline.push(obj)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// 删除pipeline
|
|
|
|
|
|
delPipeline (logsIndex, pipeLineIndex) {
|
|
|
|
|
|
this.editModule.configs[1].config[logsIndex].pipeline.splice(pipeLineIndex, 1)
|
2022-08-30 14:16:03 +08:00
|
|
|
|
this.$refs.moduleForm.clearValidate()
|
2021-08-02 11:47:34 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 添加pipelineItem
|
|
|
|
|
|
addPipelineItem (logsIndex, pipelineIndex) {
|
|
|
|
|
|
const val = this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].type
|
|
|
|
|
|
if (val === 'regex') {
|
|
|
|
|
|
this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].expression.push('')
|
|
|
|
|
|
} else if (val === 'json') {
|
2021-08-16 16:14:48 +08:00
|
|
|
|
this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].expressions.push(
|
|
|
|
|
|
{
|
|
|
|
|
|
key: '',
|
|
|
|
|
|
value: ''
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
2021-08-02 11:47:34 +08:00
|
|
|
|
} else if (val === 'template') {
|
|
|
|
|
|
this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].expressions.push('')
|
|
|
|
|
|
} else if (val === 'timestamp') {
|
|
|
|
|
|
this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].expressions.push('')
|
|
|
|
|
|
} else if (val === 'labels') {
|
|
|
|
|
|
this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].labels.push({
|
|
|
|
|
|
key: '',
|
|
|
|
|
|
value: ''
|
|
|
|
|
|
})
|
|
|
|
|
|
} else if (val === 'output') {
|
|
|
|
|
|
this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].expressions.push('')
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
delPipelineItem (logsIndex, pipelineIndex, itemIndex) {
|
|
|
|
|
|
const val = this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].type
|
2022-10-19 10:02:12 +08:00
|
|
|
|
if (val === 'json' && this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].expressions.length > 1) {
|
2021-08-02 11:47:34 +08:00
|
|
|
|
this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].expressions.splice(itemIndex, 1)
|
2022-10-19 10:02:12 +08:00
|
|
|
|
} else if (val === 'labels' && this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].labels.length > 1) {
|
2021-08-02 11:47:34 +08:00
|
|
|
|
this.editModule.configs[1].config[logsIndex].pipeline[pipelineIndex].labels.splice(itemIndex, 1)
|
|
|
|
|
|
}
|
2022-08-30 14:16:03 +08:00
|
|
|
|
this.$refs.moduleForm.clearValidate()
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted () {
|
2021-08-03 14:12:14 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
created () {
|
|
|
|
|
|
this.getProjectList()
|
2021-04-13 19:06:34 +08:00
|
|
|
|
this.getCredential()
|
2021-08-03 14:12:14 +08:00
|
|
|
|
this.getWalkData()
|
2022-11-23 11:09:05 +08:00
|
|
|
|
this.DashboardTemplateList()
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
computed: {
|
|
|
|
|
|
mibName () {
|
|
|
|
|
|
return (value) => {
|
|
|
|
|
|
return this.getMibName(this.walkData, value)
|
|
|
|
|
|
}
|
2021-11-09 10:17:12 +08:00
|
|
|
|
},
|
|
|
|
|
|
language () { return this.$store.getters.getLanguage }
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
module: {
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
handler (n, o) {
|
2021-07-15 11:56:25 +08:00
|
|
|
|
this.isEdit = true
|
2021-03-19 18:52:19 +08:00
|
|
|
|
this.editModule = JSON.parse(JSON.stringify(n))
|
2023-03-15 15:39:06 +08:00
|
|
|
|
this.editModule.dashboardId = n.dashboardId ? n.dashboardId + '' : ''
|
2021-04-13 19:06:34 +08:00
|
|
|
|
this.activeName = 'Basic'
|
2021-08-02 11:47:34 +08:00
|
|
|
|
this.activeNameLogs = this.editModule.configs[1].config.map(() => 'Basic')
|
|
|
|
|
|
this.logsCopyValue = this.editModule.configs[1].config.map(() => '')
|
|
|
|
|
|
if (this.editModule.configs[0].config.bearer_token) {
|
2021-04-13 19:06:34 +08:00
|
|
|
|
this.authType = 2
|
2021-08-02 11:47:34 +08:00
|
|
|
|
} else if (this.editModule.configs[0].config.basic_auth.username) {
|
2021-04-13 19:06:34 +08:00
|
|
|
|
this.authType = 1
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} else {
|
2021-04-13 19:06:34 +08:00
|
|
|
|
this.authType = 0
|
|
|
|
|
|
}
|
|
|
|
|
|
if (n.type && n.type.toLowerCase() == 'snmp') {
|
|
|
|
|
|
this.$refs.selectWalk.show()
|
2021-08-04 16:55:11 +08:00
|
|
|
|
for (let i = 0; i < this.editModule.configs[0].config.walk.length; i++) {
|
2021-08-02 11:47:34 +08:00
|
|
|
|
this.expandedWalkData.push(this.editModule.configs[0].config.walk[i].substring(0, this.editModule.configs[0].config.walk[i].lastIndexOf('.')))
|
2020-08-05 20:58:24 +08:00
|
|
|
|
}
|
2019-12-18 17:00:44 +08:00
|
|
|
|
}
|
2022-10-09 11:28:00 +08:00
|
|
|
|
|
|
|
|
|
|
this.editModule.configs[1].config.forEach((item, index) => {
|
|
|
|
|
|
if (item.bearer_token) {
|
|
|
|
|
|
this.logsAuthType[index] = 2
|
|
|
|
|
|
} else if (item.basic_auth && item.basic_auth.username) {
|
|
|
|
|
|
this.logsAuthType[index] = 1
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.logsAuthType[index] = 0
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2021-04-14 15:38:37 +08:00
|
|
|
|
},
|
|
|
|
|
|
editModule: {
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler (n) {
|
|
|
|
|
|
if (n && n.configs) {
|
2021-08-03 10:14:37 +08:00
|
|
|
|
const params = JSON.parse(JSON.stringify(n.configs))
|
|
|
|
|
|
params[0].config.params = this.paramToJson(this.editModule.paramObj)
|
|
|
|
|
|
params[0].config.labels = this.labelsToJson(this.editModule.labelModule)
|
|
|
|
|
|
Object.keys(params[0].config).forEach(key => {
|
|
|
|
|
|
if (!params[0].config[key]) {
|
|
|
|
|
|
delete params[0].config[key]
|
2021-04-14 15:38:37 +08:00
|
|
|
|
}
|
2022-10-09 11:28:00 +08:00
|
|
|
|
if ((Array.isArray(params[0].config[key]) && !params[0].config[key].length) || (JSON.stringify(params[0].config[key]) == '{}')) {
|
2021-08-03 10:14:37 +08:00
|
|
|
|
delete params[0].config[key]
|
2021-04-14 15:38:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2021-08-03 10:14:37 +08:00
|
|
|
|
if (params[0].config.basic_auth && !params[0].config.basic_auth.username) {
|
|
|
|
|
|
delete params[0].config.basic_auth
|
2021-04-14 15:38:37 +08:00
|
|
|
|
}
|
2022-07-11 14:58:05 +08:00
|
|
|
|
if (params[0].config.basic_auth && !params[0].config.basic_auth.password) {
|
2021-08-03 10:14:37 +08:00
|
|
|
|
delete params[0].config.basic_auth
|
2021-04-14 15:38:37 +08:00
|
|
|
|
}
|
2021-08-03 10:14:37 +08:00
|
|
|
|
if (params[0].config.param && !Object.keys(params[0].config.param).length) {
|
|
|
|
|
|
delete params[0].config.param
|
2021-04-14 15:38:37 +08:00
|
|
|
|
}
|
2021-08-03 10:14:37 +08:00
|
|
|
|
if (params[0].config.labels && !Object.keys(params[0].config.labels).length) {
|
|
|
|
|
|
delete params[0].config.labels
|
2021-04-14 15:38:37 +08:00
|
|
|
|
}
|
2021-08-19 15:54:38 +08:00
|
|
|
|
params[0].config.relabel_config && params[0].config.relabel_config.forEach(item => {
|
|
|
|
|
|
delete item.tags
|
|
|
|
|
|
delete item.showAllRelabelOption
|
|
|
|
|
|
})
|
2022-10-09 11:28:00 +08:00
|
|
|
|
|
2021-08-03 10:14:37 +08:00
|
|
|
|
params[1].config.forEach(item => {
|
|
|
|
|
|
if (item.labelModule) {
|
|
|
|
|
|
item.labels = this.labelsToJson(item.labelModule)
|
|
|
|
|
|
delete item.labelModule
|
|
|
|
|
|
}
|
2021-08-16 16:14:48 +08:00
|
|
|
|
item.pipeline && item.pipeline.forEach((pipeline) => {
|
|
|
|
|
|
if (pipeline.type === 'labels') {
|
|
|
|
|
|
pipeline.labels = this.labelsToJson(pipeline.labels)
|
|
|
|
|
|
}
|
|
|
|
|
|
if (pipeline.type === 'json') {
|
|
|
|
|
|
pipeline.expressions = this.labelsToJson(pipeline.expressions)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2022-10-09 11:28:00 +08:00
|
|
|
|
|
|
|
|
|
|
if (item.namespaces) {
|
|
|
|
|
|
delete item.namespaces.tags
|
|
|
|
|
|
if (!item.namespaces.names.length) {
|
|
|
|
|
|
delete item.namespaces.names
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
Object.keys(item).forEach(key => {
|
|
|
|
|
|
if (!item[key]) {
|
|
|
|
|
|
delete item[key]
|
|
|
|
|
|
}
|
|
|
|
|
|
if ((Array.isArray(item[key]) && !item[key].length) || (JSON.stringify(item[key]) == '{}')) {
|
|
|
|
|
|
delete item[key]
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
if (item.basic_auth && !item.basic_auth.username) {
|
|
|
|
|
|
delete item.basic_auth
|
2021-08-06 14:57:29 +08:00
|
|
|
|
}
|
2022-10-09 11:28:00 +08:00
|
|
|
|
if (item.basic_auth && !item.basic_auth.password) {
|
|
|
|
|
|
delete item.basic_auth
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
item.relabel_config && item.relabel_config.forEach(subItem => {
|
|
|
|
|
|
delete subItem.tags
|
|
|
|
|
|
delete subItem.showAllRelabelOption
|
|
|
|
|
|
})
|
2021-08-03 10:14:37 +08:00
|
|
|
|
})
|
2021-04-14 15:38:37 +08:00
|
|
|
|
this.configsCopyValue = JSON.stringify(params, null, 2)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-12-18 17:00:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
}
|
2019-12-18 17:00:44 +08:00
|
|
|
|
</script>
|