Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.17] [Inventory][ECO] APM url generated with invalid environment (#200987) #201089

Merged
merged 3 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface BuiltinEntityMap {
container: InventoryEntity & { cloud?: { provider?: string[] } };
service: InventoryEntity & {
agent?: { name: AgentName[] };
service?: { environment?: string };
service?: { environment?: string | string[] | null };
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import { apm, entities, log, timerange } from '@kbn/apm-synthtrace-client';
import { generateLongIdWithSeed } from '@kbn/apm-synthtrace-client/src/lib/utils/generate_id';

const SYNTH_NODE_TRACES_LOGS_ENTITY_ID = generateLongIdWithSeed('service');
const SERVICE_LOGS_ONLY_ENTITY_ID = generateLongIdWithSeed('service-logs-only');
const HOST_SERVER_1_LOGS_ENTITY_ID = generateLongIdWithSeed('host');
const CONTAINER_ID_METRICS_ENTITY_ID = generateLongIdWithSeed('container');

const SYNTH_NODE_TRACE_LOGS = 'synth-node-trace-logs';
const SERVICE_LOGS_ONLY = 'service-logs-only';
const HOST_NAME = 'server1';
const CONTAINER_ID = 'foo';

Expand All @@ -27,6 +29,13 @@ export function generateEntities({ from, to }: { from: number; to: number }) {
entityId: SYNTH_NODE_TRACES_LOGS_ENTITY_ID,
});

const serviceLogsOnly = entities.serviceEntity({
serviceName: SERVICE_LOGS_ONLY,
agentName: ['host'],
dataStreamType: ['logs'],
entityId: SERVICE_LOGS_ONLY_ENTITY_ID,
});

const hostServer1Logs = entities.hostEntity({
hostName: HOST_NAME,
agentName: ['nodejs'],
Expand All @@ -49,6 +58,7 @@ export function generateEntities({ from, to }: { from: number; to: number }) {
.generator((timestamp) => {
return [
serviceSynthNodeTracesLogs.timestamp(timestamp),
serviceLogsOnly.timestamp(timestamp),
hostServer1Logs.timestamp(timestamp),
containerMetrics.timestamp(timestamp),
];
Expand Down Expand Up @@ -90,23 +100,43 @@ export function generateLogs({ from, to }: { from: number; to: number }) {
.interval('1m')
.rate(1)
.generator((timestamp) => {
return Array(3)
.fill(0)
.map(() => {
const index = Math.floor(Math.random() * 3);
const logMessage = MESSAGE_LOG_LEVELS[index];
return [
...Array(3)
.fill(0)
.map(() => {
const index = Math.floor(Math.random() * 3);
const logMessage = MESSAGE_LOG_LEVELS[index];

return log
.create({ isLogsDb: false })
.service(SYNTH_NODE_TRACE_LOGS)
.message(logMessage.message)
.logLevel(logMessage.level)
.setGeoLocation([1])
.setHostIp('223.72.43.22')
.defaults({
'agent.name': 'nodejs',
})
.timestamp(timestamp);
}),
...Array(3)
.fill(0)
.map(() => {
const index = Math.floor(Math.random() * 3);
const logMessage = MESSAGE_LOG_LEVELS[index];

return log
.create({ isLogsDb: false })
.service(SYNTH_NODE_TRACE_LOGS)
.message(logMessage.message)
.logLevel(logMessage.level)
.setGeoLocation([1])
.setHostIp('223.72.43.22')
.defaults({
'agent.name': 'nodejs',
})
.timestamp(timestamp);
});
return log
.create({ isLogsDb: false })
.service(SERVICE_LOGS_ONLY)
.message(logMessage.message)
.logLevel(logMessage.level)
.setGeoLocation([1])
.setHostIp('223.72.43.22')
.defaults({
'agent.name': 'nodejs',
})
.timestamp(timestamp);
}),
];
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ describe('Home page', () => {
cy.url().should('include', '/app/apm/services/synth-node-trace-logs/overview');
});

it('Navigates to apm when clicking on a logs only service', () => {
cy.intercept('GET', '/internal/entities/managed/enablement', {
fixture: 'eem_enabled.json',
}).as('getEEMStatus');
cy.visitKibana('/app/inventory');
cy.wait('@getEEMStatus');
cy.contains('service').click();
cy.contains('service-logs-only').click();
cy.url().should('include', '/app/apm/services/service-logs-only/overview');
cy.contains('Detect and resolve issues faster with deep visibility into your application');
});

it('Navigates to hosts when clicking on a host type entity', () => {
cy.intercept('GET', '/internal/entities/managed/enablement', {
fixture: 'eem_enabled.json',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export const useDetailViewRedirect = () => {
if (isBuiltinEntityOfType('service', entity)) {
return serviceOverviewLocator?.getRedirectUrl({
serviceName: identityFieldsValue[identityFields[0]],
environment: entity.service?.environment,
environment: entity.service?.environment
? castArray(entity.service?.environment)[0]
: undefined,
});
}

Expand Down