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

[Metrics UI] Add logs to node details #83433

Merged
merged 20 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
59fe4b0
Add charts to the metrics tab
phillipb Nov 12, 2020
5fde0b5
Add timepicker, i18n, polish
phillipb Nov 12, 2020
157bb10
Fix copyrite
phillipb Nov 12, 2020
26e1e69
Merge branch 'master' into add-metrics-to-node-details
kibanamachine Nov 13, 2020
1a44d83
Merge branch 'master' of github.com:elastic/kibana into add-metrics-t…
phillipb Nov 13, 2020
ebb02c6
Add log stream component to node details
phillipb Nov 13, 2020
f2a7980
Add logs tab with ability to search
phillipb Nov 16, 2020
006f986
Merge branch 'master' into add-logs-to-node-details
kibanamachine Nov 16, 2020
4dcc04f
Update i18n
phillipb Nov 16, 2020
b58ece4
Merge branch 'add-logs-to-node-details' of github.com:phillipb/kibana…
phillipb Nov 16, 2020
2b1a2be
Merge branch 'master' of github.com:elastic/kibana into add-logs-to-n…
phillipb Nov 16, 2020
1c640fa
Apply suggestions from code review
phillipb Nov 17, 2020
9d9af6c
Update comment
phillipb Nov 18, 2020
8ee6970
Merge branch 'master' into add-logs-to-node-details
phillipb Nov 18, 2020
627617b
Merge branch 'master' into add-logs-to-node-details
kibanamachine Nov 18, 2020
2249140
Merge branch 'add-logs-to-node-details' of github.com:phillipb/kibana…
phillipb Nov 19, 2020
6290c27
Merge branch 'master' of github.com:elastic/kibana into add-logs-to-n…
phillipb Nov 19, 2020
b01d290
Fix lint
phillipb Nov 19, 2020
544f500
Merge branch 'master' into add-logs-to-node-details
phillipb Nov 19, 2020
af700a3
Fix eslint
phillipb Nov 19, 2020
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 @@ -11,7 +11,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiButtonEmpty } from '@elastic/eui';
import { euiStyled } from '../../../../../../../observability/public';
import { InfraWaffleMapNode, InfraWaffleMapOptions } from '../../../../../lib/lib';
import { InventoryItemType } from '../../../../../../common/inventory_models/types';
import { MetricsTab } from './tabs/metrics';
import { MetricsTab } from './tabs/metrics/metrics';
import { LogsTab } from './tabs/logs';
import { ProcessesTab } from './tabs/processes';
import { PropertiesTab } from './tabs/properties';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,86 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import React, { useCallback, useMemo, useState } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { EuiFieldSearch } from '@elastic/eui';
import { EuiFlexGroup } from '@elastic/eui';
import { EuiFlexItem } from '@elastic/eui';
import { EuiButtonEmpty } from '@elastic/eui';
import { TabContent, TabProps } from './shared';
import { LogStream } from '../../../../../../components/log_stream';
import { useWaffleOptionsContext } from '../../../hooks/use_waffle_options';
import { findInventoryFields } from '../../../../../../../common/inventory_models';
import { euiStyled } from '../../../../../../../../observability/public';
import { useLinkProps } from '../../../../../../hooks/use_link_props';
import { getNodeLogsUrl } from '../../../../../link_to';

const TabComponent = (props: TabProps) => {
return <TabContent>Logs Placeholder</TabContent>;
const [textQuery, setTextQuery] = useState('');
const endTimestamp = props.currentTime;
const startTimestamp = endTimestamp - 60 * 60 * 1000; // 60 minutes
const { nodeType } = useWaffleOptionsContext();
const { options, node } = props;

const filter = useMemo(() => {
let query = options.fields
? `${findInventoryFields(nodeType, options.fields).id}: "${node.id}"`
: ``;

if (textQuery) {
query += ` and message: ${textQuery}`;
}
return query;
}, [options, nodeType, node.id, textQuery]);

const onQueryChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
setTextQuery(e.target.value);
}, []);

const nodeLogsMenuItemLinkProps = useLinkProps(
getNodeLogsUrl({
nodeType,
nodeId: node.id,
time: startTimestamp,
})
);

return (
<TabContent>
<EuiFlexGroup gutterSize={'none'} alignItems="center">
<EuiFlexItem>
<QueryWrapper>
<EuiFieldSearch
fullWidth
placeholder={i18n.translate('xpack.infra.nodeDetails.logs.textFieldPlaceholder', {
defaultMessage: 'Search for log entries...',
})}
value={textQuery}
isClearable
onChange={onQueryChange}
/>
</QueryWrapper>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonEmpty iconType={'popout'} {...nodeLogsMenuItemLinkProps}>
<FormattedMessage
id="xpack.infra.nodeDetails.logs.openLogsLink"
defaultMessage="Open in Logs"
/>
</EuiButtonEmpty>
</EuiFlexItem>
</EuiFlexGroup>
<LogStream startTimestamp={startTimestamp} endTimestamp={endTimestamp} query={filter} />
</TabContent>
);
};

const QueryWrapper = euiStyled.div`
padding: ${(props) => props.theme.eui.paddingSizes.m};
padding-right: 0;
`;

export const LogsTab = {
id: 'logs',
name: i18n.translate('xpack.infra.nodeDetails.tabs.logs', {
Expand Down