diff --git a/public/app/percona/add-instance/components/AddRemoteInstance/AddRemoteInstance.service.test.tsx b/public/app/percona/add-instance/components/AddRemoteInstance/AddRemoteInstance.service.test.tsx
index ed5183d5e4e35..3d7a430cc1185 100644
--- a/public/app/percona/add-instance/components/AddRemoteInstance/AddRemoteInstance.service.test.tsx
+++ b/public/app/percona/add-instance/components/AddRemoteInstance/AddRemoteInstance.service.test.tsx
@@ -65,6 +65,13 @@ describe('AddRemoteInstanceService:: ', () => {
replication_set: 'test',
cluster: 'test',
custom_labels: 'test:test',
+ pmm_agent_id: {
+ value: 'pmm-server',
+ },
+ node: {
+ value: 'node1',
+ label: 'node1',
+ },
};
const payload = {
@@ -84,16 +91,12 @@ describe('AddRemoteInstanceService:: ', () => {
custom_labels: {
test: 'test',
},
- add_node: {
- node_name: 'localhost',
- node_type: 'NODE_TYPE_REMOTE_NODE',
- },
pmm_agent_id: 'pmm-server',
port: '80',
qan_postgresql_pgstatements_agent: true,
metrics_mode: 1,
+ node_id: 'node1',
};
-
expect(toPayload(data)).toStrictEqual(payload);
});
});
diff --git a/public/app/percona/add-instance/components/AddRemoteInstance/AddRemoteInstance.service.tsx b/public/app/percona/add-instance/components/AddRemoteInstance/AddRemoteInstance.service.tsx
index 01b755575a7fb..5d48b4f9cec81 100644
--- a/public/app/percona/add-instance/components/AddRemoteInstance/AddRemoteInstance.service.tsx
+++ b/public/app/percona/add-instance/components/AddRemoteInstance/AddRemoteInstance.service.tsx
@@ -1,5 +1,6 @@
import { CancelToken } from 'axios';
+import { PMM_SERVER_NODE_AGENT_ID } from 'app/percona/add-instance/components/AddRemoteInstance/FormParts/NodesAgents/NodesAgents.constants';
import { Databases } from 'app/percona/shared/core';
import { apiManagement } from 'app/percona/shared/helpers/api';
@@ -142,7 +143,9 @@ export const toPayload = (values: any, discoverName?: string, type?: InstanceAva
data.service_name = data.address;
}
- if (!values.isAzure && data.add_node === undefined) {
+ if (data.address === '127.0.0.1' || data.address === 'localhost') {
+ data.node_id = data.node.value;
+ } else if (!values.isAzure && data.add_node === undefined) {
data.add_node = {
node_name: data.service_name,
node_type: 'NODE_TYPE_REMOTE_NODE',
@@ -179,8 +182,15 @@ export const toPayload = (values: any, discoverName?: string, type?: InstanceAva
}
}
- data.metrics_mode = 1;
+ data.pmm_agent_id = values.pmm_agent_id.value;
+
+ if (data.pmm_agent_id === PMM_SERVER_NODE_AGENT_ID) {
+ data.metrics_mode = 1;
+ } else {
+ data.metrics_mode = 2;
+ }
delete data.tracking;
+ delete data.node;
return data;
};
diff --git a/public/app/percona/add-instance/components/AddRemoteInstance/AddRemoteInstance.test.tsx b/public/app/percona/add-instance/components/AddRemoteInstance/AddRemoteInstance.test.tsx
index 93dd7c141af00..9cef7b6233ea8 100644
--- a/public/app/percona/add-instance/components/AddRemoteInstance/AddRemoteInstance.test.tsx
+++ b/public/app/percona/add-instance/components/AddRemoteInstance/AddRemoteInstance.test.tsx
@@ -1,7 +1,9 @@
import { fireEvent, render, screen } from '@testing-library/react';
import React from 'react';
+import { Provider } from 'react-redux';
import { Databases } from 'app/percona/shared/core';
+import { configureStore } from 'app/store/configureStore';
import { InstanceTypesExtra } from '../../panel.types';
@@ -20,7 +22,11 @@ jest.mock('app/percona/shared/helpers/logger', () => {
describe('Add remote instance:: ', () => {
it('should render correct for mysql and postgres and highlight empty mandatory fields on submit', async () => {
const type = Databases.mysql;
- render(