diff --git a/public/image/logos/iotdb.png b/public/image/logos/iotdb.png new file mode 100644 index 000000000..493aca932 Binary files /dev/null and b/public/image/logos/iotdb.png differ diff --git a/src/components/AdvancedWrap/utils.ts b/src/components/AdvancedWrap/utils.ts index a46d59f27..0c362975d 100644 --- a/src/components/AdvancedWrap/utils.ts +++ b/src/components/AdvancedWrap/utils.ts @@ -41,6 +41,17 @@ export const baseCates: Cate[] = [ alertPro: false, logo: '/image/logos/elasticsearch.png', }, + { + value: 'iotdb', + label: 'IoTDB', + type: ['metric'], + alertRule: true, + dashboard: true, + dashboardVariable: false, + graphPro: false, + alertPro: false, + logo: '/image/logos/iotdb.png', + }, { value: 'tdengine', label: 'TDengine', @@ -151,8 +162,6 @@ export const baseCates: Cate[] = [ }, ]; -export const allCates = [...baseCates, ...advancedCates]; - export const getCateDisplayLabel = (cate: Pick | undefined, lang?: string) => { if (!cate) return ''; if (lang && lang !== 'zh_CN') { @@ -161,6 +170,15 @@ export const getCateDisplayLabel = (cate: Pick | und return cate.label; }; +export const allCates = [...baseCates, ...advancedCates]; + +export const getCateByValue = (cate: string) => { + if (cate === 'iotdb') { + return _.find(baseCates, { value: 'iotdb' }); + } + return _.find(allCates, { value: cate }); +}; + export const getAuthorizedDatasourceCates = (feats, isPlus, filter?: (cate: any) => boolean) => { let cates = baseCates; if (feats && isPlus) { @@ -175,6 +193,6 @@ export const getAuthorizedDatasourceCates = (feats, isPlus, filter?: (cate: any) }; export const getGraphProByCate = (cate: string) => { - const currentCate = _.find(allCates, { value: cate }); + const currentCate = getCateByValue(cate); return currentCate?.graphPro; }; diff --git a/src/pages/alertRules/Form/Rule/Rule/index.tsx b/src/pages/alertRules/Form/Rule/Rule/index.tsx index 94ccfe554..35a936d6d 100644 --- a/src/pages/alertRules/Form/Rule/Rule/index.tsx +++ b/src/pages/alertRules/Form/Rule/Rule/index.tsx @@ -6,6 +6,7 @@ import _ from 'lodash'; import { DatasourceCateEnum } from '@/utils/constant'; import IntervalAndDuration from '@/pages/alertRules/Form/components/IntervalAndDuration'; +import { AlertRule as IotDB } from '@/plugins/iotdb'; import { AlertRule as TDengine } from '@/plugins/TDengine'; import { AlertRule as ClickHouse } from '@/plugins/clickHouse'; import { AlertRule as ElasticsearchSettings } from '@/plugins/elasticsearch'; @@ -36,6 +37,7 @@ export default function index() {
{cate === DatasourceCateEnum.prometheus && } + {cate === DatasourceCateEnum.iotdb && } {cate === DatasourceCateEnum.tdengine && } {cate === DatasourceCateEnum.ck && } {cate === DatasourceCateEnum.loki && } diff --git a/src/pages/alertRules/Form/utils.ts b/src/pages/alertRules/Form/utils.ts index 71847e43d..6088974dc 100644 --- a/src/pages/alertRules/Form/utils.ts +++ b/src/pages/alertRules/Form/utils.ts @@ -361,6 +361,27 @@ export function getDefaultValuesByCate(prod, cate) { ...datasourceDefaultValue, }; } + if (cate === DatasourceCateEnum.iotdb) { + return { + prod, + cate, + rule_config: { + ...defaultRuleConfig, + queries: [ + { + ref: 'A', + interval: 1, + interval_unit: 'min', + keys: { + timeKey: 'time', + timeFormat: '2006-01-02T15:04:05', + }, + }, + ], + }, + ...datasourceDefaultValue, + }; + } if (cate === DatasourceCateEnum.loki) { return { prod, diff --git a/src/pages/dashboard/Editor/QueryEditor/QueryBuilder.tsx b/src/pages/dashboard/Editor/QueryEditor/QueryBuilder.tsx index 892cc3379..3398b2d0a 100644 --- a/src/pages/dashboard/Editor/QueryEditor/QueryBuilder.tsx +++ b/src/pages/dashboard/Editor/QueryEditor/QueryBuilder.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { DatasourceCateEnum } from '@/utils/constant'; +import { QueryBuilder as IotDB } from '@/plugins/iotdb'; import { QueryBuilder as TDengine } from '@/plugins/TDengine'; import { QueryBuilder as CK } from '@/plugins/clickHouse'; import { IRawTimeRange } from '@/components/TimeRangePicker/types'; @@ -30,6 +31,9 @@ export default function QueryBuilder(props: Props) { if (cate === DatasourceCateEnum.elasticsearch) { return ; } + if (cate === DatasourceCateEnum.iotdb) { + return ; + } if (cate === DatasourceCateEnum.tdengine) { return ; } diff --git a/src/pages/dashboard/Renderer/datasource/useQuery.tsx b/src/pages/dashboard/Renderer/datasource/useQuery.tsx index e429c64f6..036c3bb34 100644 --- a/src/pages/dashboard/Renderer/datasource/useQuery.tsx +++ b/src/pages/dashboard/Renderer/datasource/useQuery.tsx @@ -20,6 +20,7 @@ import { Form } from 'antd'; import { useDebounceFn } from 'ahooks'; import { IRawTimeRange } from '@/components/TimeRangePicker'; +import { datasource as iotdbQuery } from '@/plugins/iotdb'; import { datasource as tdengineQuery } from '@/plugins/TDengine'; import { datasource as ckQuery } from '@/plugins/clickHouse'; import flatten from '@/utils/flatten'; @@ -71,6 +72,7 @@ export default function useQuery(props: IProps) { const fetchQueryMap = { prometheus: prometheusQuery, elasticsearch: elasticsearchQuery, + iotdb: iotdbQuery, tdengine: tdengineQuery, ck: ckQuery, ...plusDatasource, diff --git a/src/pages/datasource/Datasources/Detail.tsx b/src/pages/datasource/Datasources/Detail.tsx index b9182e410..0c8f1ecb9 100644 --- a/src/pages/datasource/Datasources/Detail.tsx +++ b/src/pages/datasource/Datasources/Detail.tsx @@ -11,6 +11,7 @@ import Victorialogs from '@/plugins/victorialogs/Datasource/Detail'; import Prometheus from './Prometheus/Detail'; import ElasticSearch from './ElasticSearch/Detail'; import Jaeger from './Jaeger/Detail'; +import IotDB from './iotdb/Detail'; import TDengine from './TDengine/Detail'; import Loki from './Loki/Detail'; @@ -30,6 +31,9 @@ export default function Form(props) { if (props.data.plugin_type === 'jaeger') { return ; } + if (props.data.plugin_type === DatasourceCateEnum.iotdb) { + return ; + } if (props.data.plugin_type === DatasourceCateEnum.tdengine) { return ; } diff --git a/src/pages/datasource/Datasources/Form.tsx b/src/pages/datasource/Datasources/Form.tsx index 51bb8db76..1c3cd6fdd 100644 --- a/src/pages/datasource/Datasources/Form.tsx +++ b/src/pages/datasource/Datasources/Form.tsx @@ -12,6 +12,7 @@ import Victorialogs from '@/plugins/victorialogs/Datasource/Form'; import Prometheus from './Prometheus/Form'; import ElasticSearch from './ElasticSearch/Form'; import Jaeger from './Jaeger/Form'; +import IotDB from './iotdb/Form'; import TDengine from './TDengine/Form'; import Loki from './Loki/Form'; // @ts-ignore @@ -31,6 +32,9 @@ export default function Form(props) { if (params.type === 'jaeger') { return ; } + if (params.type === DatasourceCateEnum.iotdb) { + return ; + } if (params.type === DatasourceCateEnum.tdengine) { return ; } diff --git a/src/pages/datasource/Datasources/iotdb/Detail.tsx b/src/pages/datasource/Datasources/iotdb/Detail.tsx new file mode 100644 index 000000000..e9dda7f80 --- /dev/null +++ b/src/pages/datasource/Datasources/iotdb/Detail.tsx @@ -0,0 +1,60 @@ +import React from 'react'; +import { Row, Col } from 'antd'; +import _ from 'lodash'; +import { useTranslation } from 'react-i18next'; + +interface Props { + data: any; +} + +export default function Index(props: Props) { + const { t } = useTranslation('datasourceManage'); + const { data } = props; + + return ( +
+
HTTP
+
+ + URL: + + {data?.http?.url} + + +
+
{t('form.auth')}
+
+ + {t('form.username')}: + {t('form.password')}: + {t('form.skip_ssl_verify')}: + + {data?.auth?.basic_auth_user || '-'} + + + {data?.auth?.basic_auth_password ? '******' : '-'} + + + {data?.http?.tls?.skip_tls_verify ? t('form.yes') : t('form.no')} + + +
+ {!_.isEmpty(data?.http?.headers) && ( + <> +
{t('form.headers')}
+
+ + {_.map(data?.http?.headers, (val, key) => { + return ( + + {key + ' : ' + val} + + ); + })} + +
+ + )} +
+ ); +} diff --git a/src/pages/datasource/Datasources/iotdb/Form.tsx b/src/pages/datasource/Datasources/iotdb/Form.tsx new file mode 100644 index 000000000..29b749e67 --- /dev/null +++ b/src/pages/datasource/Datasources/iotdb/Form.tsx @@ -0,0 +1,49 @@ +import React, { useRef } from 'react'; +import { Form, Card } from 'antd'; +import { useTranslation } from 'react-i18next'; +import { scrollToFirstError } from '@/utils'; +import Name from '../../components/items/Name'; +import HTTP from '../../components/items/HTTP'; +import BasicAuth from '../../components/items/BasicAuth'; +import SkipTLSVerify from '../../components/items/SkipTLSVerify'; +import Headers from '../../components/items/Headers'; +import Description from '../../components/items/Description'; +import Footer from '../../components/items/Footer'; +import Cluster from '../../components/items/Cluster'; + +export default function FormCpt({ action, data, onFinish, submitLoading }: any) { + const { t } = useTranslation('datasourceManage'); + const [form] = Form.useForm(); + const clusterRef = useRef(); + + return ( +
{ + onFinish(values, clusterRef.current); + }} + onFinishFailed={() => { + scrollToFirstError(); + }} + initialValues={{ + http: { + url: 'http://localhost:18080', + }, + ...data, + }} + className='settings-source-form' + > + + + + + + + + + +