Skip to content

Commit

Permalink
Better route definition for fleet_agent_details
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet committed Nov 30, 2020
1 parent 3932205 commit fed695b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export const pagePathGetters: {
`/policies/${policyId}/edit-integration/${packagePolicyId}`,
fleet: () => '/fleet',
fleet_agent_list: ({ kuery }) => `/fleet/agents${kuery ? `?kuery=${kuery}` : ''}`,
fleet_agent_details: ({ agentId, tabId }) =>
`/fleet/agents/${agentId}${tabId ? `/${tabId}` : ''}`,
fleet_agent_details: ({ agentId, tabId, logQuery }) =>
`/fleet/agents/${agentId}${tabId ? `/${tabId}` : ''}${logQuery ? `?_q=${logQuery}` : ''}`,
fleet_enrollment_tokens: () => '/fleet/enrollment-tokens',
data_streams: () => '/data-streams',
};
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,11 @@ export const AgentDetailsIntegration: React.FunctionComponent<{
render: (inputType: string) => {
return (
<EuiButtonIcon
href={`${getHref('fleet_agent_details', {
href={getHref('fleet_agent_details', {
agentId: agent.id,
tabId: 'logs',
})}?${getLogsQueryByInputType(inputType)}`}
logQuery: getLogsQueryByInputType(inputType),
})}
iconType="editorAlignLeft"
title={i18n.translate('xpack.fleet.agentDetailsIntegrations.viewLogsButton', {
defaultMessage: 'View logs',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { i18n } from '@kbn/i18n';
import {
DATASET_FIELD,
STATE_DATASET_FIELD,
AGENT_DATASET_FILEBEAT,
AGENT_DATASET_METRICBEAT,
} from '../agent_logs/constants';
Expand All @@ -33,9 +33,11 @@ export function displayInputType(inputType: string): string {

export function getLogsQueryByInputType(inputType: string) {
if (inputType === 'logfile') {
return `_q=(${DATASET_FIELD.name}:!(${AGENT_DATASET_FILEBEAT}))`;
return `(${STATE_DATASET_FIELD}:!(${AGENT_DATASET_FILEBEAT}))`;
}
if (inputType.match(/\/metrics$/)) {
return `_q=(${DATASET_FIELD.name}:!(${AGENT_DATASET_METRICBEAT}))`;
return `(${STATE_DATASET_FIELD}:!(${AGENT_DATASET_METRICBEAT}))`;
}

return '';
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export const DEFAULT_LOGS_STATE: AgentLogsState = {
query: '',
};

export const STATE_DATASET_FIELD = 'datasets';

export const AGENT_LOG_LEVELS = {
ERROR: 'error',
WARNING: 'warning',
Expand Down

0 comments on commit fed695b

Please sign in to comment.