[INLONG-9963][Dashboard][Agent] Add agentIp fields to Kafka and Pulsar source (#9964)
diff --git a/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sources/KafkaSource.java b/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sources/KafkaSource.java
index 62aa874..fe31730 100644
--- a/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sources/KafkaSource.java
+++ b/inlong-agent/agent-plugins/src/main/java/org/apache/inlong/agent/plugin/sources/KafkaSource.java
@@ -145,7 +145,7 @@
props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, profile.get(TASK_KAFKA_AUTO_COMMIT_OFFSET_RESET));
props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, false);
- allPartitionOffsets = profile.get(TASK_KAFKA_OFFSET);
+ allPartitionOffsets = profile.get(TASK_KAFKA_OFFSET, null);
isRestoreFromDB = profile.getBoolean(RESTORE_FROM_DB, false);
if (!isRestoreFromDB && StringUtils.isNotBlank(allPartitionOffsets)) {
// example:0#110_1#666_2#222
diff --git a/inlong-dashboard/src/plugins/sources/defaults/Kafka.ts b/inlong-dashboard/src/plugins/sources/defaults/Kafka.ts
index da0ff9d..1c11b35 100644
--- a/inlong-dashboard/src/plugins/sources/defaults/Kafka.ts
+++ b/inlong-dashboard/src/plugins/sources/defaults/Kafka.ts
@@ -22,6 +22,7 @@
import { RenderList } from '@/plugins/RenderList';
import { SourceInfo } from '../common/SourceInfo';
import i18n from '@/i18n';
+import rulesPattern from '@/core/utils/pattern';
const { I18n } = DataWithBackend;
const { FieldDecorator, SyncField, IngestionField } = RenderRow;
@@ -32,6 +33,97 @@
implements DataWithBackend, RenderRow, RenderList
{
@FieldDecorator({
+ type: 'select',
+ rules: [{ required: true }],
+ props: values => ({
+ disabled: Boolean(values.id),
+ showSearch: true,
+ allowClear: true,
+ filterOption: false,
+ options: {
+ requestTrigger: ['onOpen', 'onSearch'],
+ requestService: keyword => ({
+ url: '/cluster/list',
+ method: 'POST',
+ data: {
+ keyword,
+ type: 'AGENT',
+ pageNum: 1,
+ pageSize: 10,
+ },
+ }),
+ requestParams: {
+ formatResult: result =>
+ result?.list?.map(item => ({
+ ...item,
+ label: item.displayName,
+ value: item.name,
+ })),
+ },
+ },
+ onChange: (value, option) => {
+ return {
+ clusterId: option.id,
+ };
+ },
+ }),
+ })
+ @ColumnDecorator()
+ @IngestionField()
+ @I18n('meta.Sources.File.ClusterName')
+ inlongClusterName: string;
+
+ @FieldDecorator({
+ type: 'text',
+ hidden: true,
+ })
+ @I18n('clusterId')
+ @IngestionField()
+ clusterId: number;
+
+ @FieldDecorator({
+ type: 'select',
+ rules: [
+ {
+ pattern: rulesPattern.ip,
+ message: i18n.t('meta.Sources.File.IpRule'),
+ required: true,
+ },
+ ],
+ props: values => ({
+ disabled: Boolean(values.id),
+ showSearch: true,
+ allowClear: true,
+ filterOption: false,
+ options: {
+ requestTrigger: ['onOpen', 'onSearch'],
+ requestService: keyword => ({
+ url: '/cluster/node/list',
+ method: 'POST',
+ data: {
+ keyword,
+ parentId: values.clusterId,
+ pageNum: 1,
+ pageSize: 10,
+ },
+ }),
+ requestParams: {
+ formatResult: result =>
+ result?.list?.map(item => ({
+ ...item,
+ label: item.ip,
+ value: item.ip,
+ })),
+ },
+ },
+ }),
+ })
+ @ColumnDecorator()
+ @IngestionField()
+ @I18n('meta.Sources.File.DataSourceIP')
+ agentIp: string;
+
+ @FieldDecorator({
type: 'input',
rules: [{ required: true }],
props: values => ({
@@ -60,7 +152,7 @@
@FieldDecorator({
type: 'select',
- initialValue: 'Latest',
+ initialValue: 'latest',
rules: [{ required: true }],
props: values => ({
disabled: values?.status === 101,
diff --git a/inlong-dashboard/src/plugins/sources/defaults/Pulsar.ts b/inlong-dashboard/src/plugins/sources/defaults/Pulsar.ts
index 0d6c1c9..3f3f0bf 100644
--- a/inlong-dashboard/src/plugins/sources/defaults/Pulsar.ts
+++ b/inlong-dashboard/src/plugins/sources/defaults/Pulsar.ts
@@ -23,6 +23,7 @@
import { SourceInfo } from '../common/SourceInfo';
import dayjs from 'dayjs';
import i18n from '@/i18n';
+import rulesPattern from '@/core/utils/pattern';
const { I18n } = DataWithBackend;
const { FieldDecorator, SyncField, IngestionField } = RenderRow;
@@ -33,6 +34,97 @@
implements DataWithBackend, RenderRow, RenderList
{
@FieldDecorator({
+ type: 'select',
+ rules: [{ required: true }],
+ props: values => ({
+ disabled: Boolean(values.id),
+ showSearch: true,
+ allowClear: true,
+ filterOption: false,
+ options: {
+ requestTrigger: ['onOpen', 'onSearch'],
+ requestService: keyword => ({
+ url: '/cluster/list',
+ method: 'POST',
+ data: {
+ keyword,
+ type: 'AGENT',
+ pageNum: 1,
+ pageSize: 10,
+ },
+ }),
+ requestParams: {
+ formatResult: result =>
+ result?.list?.map(item => ({
+ ...item,
+ label: item.displayName,
+ value: item.name,
+ })),
+ },
+ },
+ onChange: (value, option) => {
+ return {
+ clusterId: option.id,
+ };
+ },
+ }),
+ })
+ @ColumnDecorator()
+ @IngestionField()
+ @I18n('meta.Sources.File.ClusterName')
+ inlongClusterName: string;
+
+ @FieldDecorator({
+ type: 'text',
+ hidden: true,
+ })
+ @I18n('clusterId')
+ @IngestionField()
+ clusterId: number;
+
+ @FieldDecorator({
+ type: 'select',
+ rules: [
+ {
+ pattern: rulesPattern.ip,
+ message: i18n.t('meta.Sources.File.IpRule'),
+ required: true,
+ },
+ ],
+ props: values => ({
+ disabled: Boolean(values.id),
+ showSearch: true,
+ allowClear: true,
+ filterOption: false,
+ options: {
+ requestTrigger: ['onOpen', 'onSearch'],
+ requestService: keyword => ({
+ url: '/cluster/node/list',
+ method: 'POST',
+ data: {
+ keyword,
+ parentId: values.clusterId,
+ pageNum: 1,
+ pageSize: 10,
+ },
+ }),
+ requestParams: {
+ formatResult: result =>
+ result?.list?.map(item => ({
+ ...item,
+ label: item.ip,
+ value: item.ip,
+ })),
+ },
+ },
+ }),
+ })
+ @ColumnDecorator()
+ @IngestionField()
+ @I18n('meta.Sources.File.DataSourceIP')
+ agentIp: string;
+
+ @FieldDecorator({
type: 'input',
rules: [{ required: true }],
props: values => ({
diff --git a/inlong-dashboard/src/ui/locales/en.json b/inlong-dashboard/src/ui/locales/en.json
index 87198b1..57bae06 100644
--- a/inlong-dashboard/src/ui/locales/en.json
+++ b/inlong-dashboard/src/ui/locales/en.json
@@ -27,7 +27,7 @@
"meta.Sources.NameRule": "Only English letters, numbers, dots(.), minus(-), and underscores(_)",
"meta.Sources.Type": "Type",
"meta.Sources.File.SerializationType": "File type",
- "meta.Sources.File.DataSourceIP": "Data source IP",
+ "meta.Sources.File.DataSourceIP": "Source IP",
"meta.Sources.File.ClusterName": "Cluster name",
"meta.Sources.File.FilePath": "File path",
"meta.Sources.File.FilePathHelp": "Must be an absolute path and support regular expressions, such as: /data/.*log",