Skip to content

Commit

Permalink
feat: The analysis field supports any type of original data conversio…
Browse files Browse the repository at this point in the history
…n string
  • Loading branch information
kl7sn committed Jan 13, 2023
1 parent 0ec6882 commit f32d4c1
Show file tree
Hide file tree
Showing 17 changed files with 112 additions and 124 deletions.
2 changes: 1 addition & 1 deletion api/internal/api/apiv2/alert/alertmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func Webhook(c *core.Context) {
c.JSONE(1, "invalid parameter", err)
return
}
elog.Debug("alarm", elog.Any("notification", notification))
elog.Info("alarm", elog.Any("notification", notification))
err = service.Alert.HandlerAlertManager(notification.CommonLabels["uuid"], notification.CommonLabels["filterId"], notification)
if err != nil {
c.JSONE(1, "message send failed: "+err.Error(), err)
Expand Down
4 changes: 1 addition & 3 deletions api/internal/api/apiv2/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"strings"

"github.com/ego-component/egorm"
"github.com/gotomicro/ego/core/elog"
"github.com/spf13/cast"

"github.com/clickvisual/clickvisual/api/internal/invoker"
Expand Down Expand Up @@ -79,7 +78,7 @@ func Create(c *core.Context) {
}
_, err = service.StorageCreate(c.Uid(), databaseInfo, param)
if err != nil {
c.JSONE(core.CodeErr, err.Error(), nil)
c.JSONE(core.CodeErr, err.Error(), err)
return
}
event.Event.InquiryCMDB(c.User(), db.OpnTablesCreate, map[string]interface{}{"param": param})
Expand Down Expand Up @@ -164,7 +163,6 @@ func Update(c *core.Context) {
c.JSONE(1, "permission verification failed", err)
return
}
elog.Debug("storage", elog.String("step", "update"), elog.Any("database", tableInfo.Database))
op, err := service.InstanceManager.Load(tableInfo.Database.Iid)
if err != nil {
c.JSONE(1, "update failed 01: "+err.Error(), nil)
Expand Down
12 changes: 6 additions & 6 deletions api/internal/service/inquiry/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -1446,13 +1446,13 @@ func (c *ClickHouse) jsonExtractSQL(indexes map[string]*db.BaseIndex, rawLogFiel
if hashFieldName, ok := obj.GetHashFieldName(); ok {
switch obj.HashTyp {
case db.HashTypeSip:
jsonExtractSQL += fmt.Sprintf("sipHash64(toString(%s) AS `%s`,\n", rawVal, hashFieldName)
jsonExtractSQL += fmt.Sprintf("sipHash64(toString(%s)) AS `%s`,\n", rawVal, hashFieldName)
case db.HashTypeURL:
jsonExtractSQL += fmt.Sprintf("URLHash(toString(%s) AS `%s`,\n", rawVal, hashFieldName)
jsonExtractSQL += fmt.Sprintf("URLHash(toString(%s)) AS `%s`,\n", rawVal, hashFieldName)
}
}
if obj.Typ == db.IndexTypeString {
jsonExtractSQL += fmt.Sprintf("toNullable(toString(%s) AS `%s`,\n", rawVal, obj.GetFieldName())
jsonExtractSQL += fmt.Sprintf("toNullable(toString(%s)) AS `%s`,\n", rawVal, obj.GetFieldName())
continue
}
if obj.Typ == db.IndexTypeRaw {
Expand All @@ -1465,14 +1465,14 @@ func (c *ClickHouse) jsonExtractSQL(indexes map[string]*db.BaseIndex, rawLogFiel
if hashFieldName, ok := obj.GetHashFieldName(); ok {
switch obj.HashTyp {
case db.HashTypeSip:
jsonExtractSQL += fmt.Sprintf("sipHash64(%s) AS `%s`,\n", rawVal, hashFieldName)
jsonExtractSQL += fmt.Sprintf("sipHash64(toString(%s)) AS `%s`,\n", rawVal, hashFieldName)
case db.HashTypeURL:
jsonExtractSQL += fmt.Sprintf("URLHash(%s) AS `%s`,\n", rawVal, hashFieldName)
jsonExtractSQL += fmt.Sprintf("URLHash(toString(%s)) AS `%s`,\n", rawVal, hashFieldName)
}
}
// 在 version 21.11 后使用 JSON_VALUE(_raw_log_, '$._log_') 代替
if obj.Typ == db.IndexTypeString {
jsonExtractSQL += fmt.Sprintf("toNullable(toString(%s) AS `%s`,\n", rawVal, obj.GetFieldName())
jsonExtractSQL += fmt.Sprintf("toNullable(toString(%s)) AS `%s`,\n", rawVal, obj.GetFieldName())
continue
}
if obj.Typ == db.IndexTypeRaw {
Expand Down
12 changes: 6 additions & 6 deletions ui/src/locales/en-US.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default {
"global.database.add": "Create/Access Database",

operation: "Operation",
create: "Create",
add: "Add",
Expand All @@ -8,7 +10,7 @@ export default {
submit: "Submit",
name: "Name",
description: "Description",
DescAsAlias: "Alias",
descAsAlias: "Alias",
loading: "loading",
loadingDone: "Loading successful",
noData: "no data",
Expand Down Expand Up @@ -125,7 +127,7 @@ export default {
// Instance Management
"instance.role.tip": "Modify the permissions",
"instance.button.add": "Add instance",
"instance.instanceName": "Instance Name",
"instance.name": "Instance Name",
"instance.datasource": "Datasource",
"instance.storagePah": "Storage Path",
"instance.delete.confirmTip": "Confirm deleting instance: {name} ?",
Expand Down Expand Up @@ -159,15 +161,13 @@ export default {
"instance.form.test.fail": "Test to fail",
"instance.form.test.tip":
"Please test the connection before submitting the form",
"instance.operation.addDatabase": "Adding a database",
"instance.success.created": "Created instance succeeded",
"instance.success.updated": "Updated instance succeeded",
"instance.success.deleted": "Deleted instance succeeded",

// Database Management
"database.form.title": "Create Database",
"database.form.label.name": "Database Name",
"database.form.placeholder.name": "Please enter a database name",
"database.form.label.name": "Database",
"database.form.placeholder.name": "Please enter database name",
"database.form.reg.name":
"Support only _, lowercase letters or Numbers, and begin with a letter",
"database.success.created": "Created database succeeded",
Expand Down
16 changes: 8 additions & 8 deletions ui/src/locales/zh-CN.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default {
"global.database.add": "新增/接入数据库",

operation: "操作",
create: "新建",
add: "添加",
Expand All @@ -8,7 +10,7 @@ export default {
submit: "提交",
name: "名称",
description: "描述",
DescAsAlias: "备注",
descAsAlias: "备注",
loading: "正在加载",
loadingDone: "加载成功",
noData: "没有数据",
Expand Down Expand Up @@ -41,9 +43,9 @@ export default {
count: "总量",
status: "状态",
dingTalk: "钉钉",
WeCom: "企业微信",
Feishu: "飞书",
Slack: "Slack",
weCom: "企业微信",
feishu: "飞书",
slack: "Slack",

user: "用户",
utime: "更新时间",
Expand Down Expand Up @@ -125,7 +127,7 @@ export default {
// Instance Management
"instance.role.tip": "修改权限",
"instance.button.add": "新增实例",
"instance.instanceName": "实例名称",
"instance.name": "实例名称",
"instance.datasource": "数据源",
"instance.storagePah": "存储路径",
"instance.delete.confirmTip": "确认删除实例:{name} 吗?",
Expand Down Expand Up @@ -158,14 +160,12 @@ export default {
"instance.form.test.success": "测试成功",
"instance.form.test.fail": "测试失败",
"instance.form.test.tip": "请先进行连接测试后再提交表单",
"instance.operation.addDatabase": "新增数据库",
"instance.success.created": "新增实例成功",
"instance.success.updated": "更新实例成功",
"instance.success.deleted": "删除实例成功",

// Database Management
"database.form.title": "新增数据库",
"database.form.label.name": "数据库名称",
"database.form.label.name": "数据库",
"database.form.placeholder.name": "请输入数据库名称",
"database.form.reg.name": "仅支持_、小写字母或数字,且以字母开头",
"database.success.created": "新增数据库成功",
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/Alarm/Environment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const Environment = () => {

const column: any[] = [
{
title: i18n.formatMessage({ id: "instance.instanceName" }),
title: i18n.formatMessage({ id: "instance.name" }),
dataIndex: "instanceName",
align: "left",
render: (instanceName: string) => {
Expand Down
8 changes: 4 additions & 4 deletions ui/src/pages/Alarm/hooks/useAlarmEnums.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useIntl } from "umi";
import {useIntl} from "umi";

const useAlarmEnums = () => {
const i18n = useIntl();
const ChannelTypes = [
{ name: i18n.formatMessage({ id: "dingTalk" }), value: 1 },
{ name: i18n.formatMessage({ id: "WeCom" }), value: 2 },
{ name: i18n.formatMessage({ id: "Feishu" }), value: 3 },
{ name: i18n.formatMessage({ id: "Slack" }), value: 4 },
{ name: i18n.formatMessage({ id: "weCom" }), value: 2 },
{ name: i18n.formatMessage({ id: "feishu" }), value: 3 },
{ name: i18n.formatMessage({ id: "slack" }), value: 4 },
];
const AlarmStatus = [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import databaseModalStyles from "./index.less";
import { Button, Form, FormInstance, Input, Select } from "antd";
import { useIntl } from "umi";
import { useEffect, useRef, useState } from "react";
import {Button, Form, FormInstance, Input, Select} from "antd";
import {useIntl} from "umi";
import {useEffect, useRef, useState} from "react";
import CustomModal from "@/components/CustomModal";
import { useModel } from "@@/plugin-model/useModel";
import { SaveOutlined } from "@ant-design/icons";
import { useDebounceFn } from "ahooks";
import { DEBOUNCE_WAIT } from "@/config/config";
import { InstanceType } from "@/services/systemSetting";
import {useModel} from "@@/plugin-model/useModel";
import {SaveOutlined} from "@ant-design/icons";
import {useDebounceFn} from "ahooks";
import {DEBOUNCE_WAIT} from "@/config/config";
import {InstanceType} from "@/services/systemSetting";

const { Option } = Select;

Expand Down Expand Up @@ -81,7 +81,7 @@ const CreatedDatabaseModal = (props: { onGetList: any }) => {
return (
<CustomModal
title={i18n.formatMessage({
id: "database.form.title",
id: "global.database.add",
})}
visible={visibleCreatedDatabaseModal}
onCancel={onCancel}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Form, FormInstance, Input, message, Modal, Select } from "antd";
import { useEffect, useRef, useState } from "react";
import { useModel, useIntl } from "umi";
import {Form, FormInstance, Input, message, Modal, Select} from "antd";
import {useEffect, useRef, useState} from "react";
import {useIntl, useModel} from "umi";

const { Option } = Select;

Expand Down Expand Up @@ -134,7 +134,7 @@ const EditDatabaseModel = (props: {
</Form.Item>
<Form.Item
label={i18n.formatMessage({
id: "DescAsAlias",
id: "descAsAlias",
})}
name={"desc"}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import deletedModal from "@/components/DeletedModal";
import IconFont from "@/components/IconFont";
import logLibraryListStyles from "@/pages/DataLogs/components/DataSourceMenu/LogLibraryList/index.less";
import { PlusSquareOutlined } from "@ant-design/icons";
import { Dropdown, Menu, message, Tooltip } from "antd";
import { useIntl, useModel } from "umi";
import {PlusSquareOutlined} from "@ant-design/icons";
import {Dropdown, Menu, message, Tooltip} from "antd";
import {useIntl, useModel} from "umi";

const DatabaseItem = (props: { databasesItem: any; onGetList: any }) => {
const { databasesItem, onGetList } = props;
Expand Down Expand Up @@ -105,7 +105,7 @@ const DatabaseItem = (props: { databasesItem: any; onGetList: any }) => {
</div>
<div>
<div className={logLibraryListStyles.logTipTitle}>
{i18n.formatMessage({ id: "DescAsAlias" })}
{i18n.formatMessage({ id: "descAsAlias" })}
:&nbsp; {!databasesItem?.desc ? "" : databasesItem.desc}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
import {
Form,
FormInstance,
Input,
InputNumber,
message,
Modal,
Spin,
Switch,
} from "antd";
import { useEffect, useMemo, useRef } from "react";
import { useIntl, useModel } from "umi";
import {Form, FormInstance, Input, InputNumber, message, Modal, Spin, Switch,} from "antd";
import {useEffect, useMemo, useRef} from "react";
import {useIntl, useModel} from "umi";
import style from "./index.less";

const EditLogLibraryModal = (props: { onGetList: any }) => {
Expand Down Expand Up @@ -177,7 +168,7 @@ const EditLogLibraryModal = (props: { onGetList: any }) => {
</Form.Item>
<Form.Item
label={i18n.formatMessage({
id: "DescAsAlias",
id: "descAsAlias",
})}
name={"desc"}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Dropdown, Menu, Tooltip } from "antd";
import { useIntl, useModel } from "umi";
import {Dropdown, Menu, Tooltip} from "antd";
import {useIntl, useModel} from "umi";
import logLibraryListStyles from "@/pages/DataLogs/components/DataSourceMenu/LogLibraryList/index.less";
import { PlusSquareOutlined } from "@ant-design/icons";
import {PlusSquareOutlined} from "@ant-design/icons";
import IconFont from "@/components/IconFont";

const InstanceItem = (props: { instanceItem: any }) => {
Expand All @@ -22,13 +22,13 @@ const InstanceItem = (props: { instanceItem: any }) => {
<div>
<div className={logLibraryListStyles.logTipTitle}>
<span>
{i18n.formatMessage({ id: "instance.instanceName" })}:&nbsp;
{i18n.formatMessage({ id: "instance.name" })}:&nbsp;
{instanceItem.instanceName}
</span>
</div>
<div>
<div className={logLibraryListStyles.logTipTitle}>
{i18n.formatMessage({ id: "DescAsAlias" })}
{i18n.formatMessage({ id: "descAsAlias" })}
:&nbsp; {!instanceItem?.desc ? "" : instanceItem.desc}
</div>
</div>
Expand All @@ -37,7 +37,7 @@ const InstanceItem = (props: { instanceItem: any }) => {

const menuList = [
{
label: i18n.formatMessage({ id: "instance.operation.addDatabase" }),
label: i18n.formatMessage({ id: "global.database.add" }),
key: "database-create",
onClick: () => {
onChangeCreatedDatabaseModal(true);
Expand Down Expand Up @@ -78,7 +78,7 @@ const InstanceItem = (props: { instanceItem: any }) => {
}}
>
<IconFont type="icon-instance" style={{ marginRight: "4px" }} />
{instanceItem.instanceName}
{instanceItem.instanceName} {instanceItem.desc}
</div>
</Tooltip>
</Dropdown>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import infoStyles from "@/pages/DataLogs/components/DataSourceMenu/LogLibraryList/LogLibraryInfoDraw/index.less";
import { TableInfoResponse, TablesResponse } from "@/services/dataLogs";
import { useEffect, useState } from "react";
import { useModel } from "@@/plugin-model/useModel";
import { Drawer, Select, Tooltip } from "antd";
import {TableInfoResponse, TablesResponse} from "@/services/dataLogs";
import {useEffect, useState} from "react";
import {useModel} from "@@/plugin-model/useModel";
import {Drawer, Select, Tooltip} from "antd";
import MonacoEditor from "react-monaco-editor";
import { useIntl } from "umi";
import { logLibraryTypes } from "@/pages/DataLogs/components/DataSourceMenu/ModalCreatedLogLibrary";
import {useIntl} from "umi";
import {logLibraryTypes} from "@/pages/DataLogs/components/DataSourceMenu/ModalCreatedLogLibrary";
import classNames from "classnames";

const { Option } = Select;
Expand Down Expand Up @@ -80,7 +80,7 @@ const LogLibraryInfoDraw = (props: LogLibraryInfoDrawProps) => {
},
{
id: 107,
title: i18n.formatMessage({ id: "DescAsAlias" }),
title: i18n.formatMessage({ id: "descAsAlias" }),
content: libraryInfo?.desc,
tooltip: false,
// Desc: (
Expand Down
Loading

0 comments on commit f32d4c1

Please sign in to comment.