Skip to content

Commit

Permalink
Merge branch 'master' into search-session-enhanced
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasolson committed Dec 3, 2020
2 parents ea14d29 + 726424a commit 4ce9fef
Show file tree
Hide file tree
Showing 23 changed files with 651 additions and 64 deletions.
14 changes: 10 additions & 4 deletions packages/kbn-apm-config-loader/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,27 @@ import { ApmAgentConfig } from './types';

const getDefaultConfig = (isDistributable: boolean): ApmAgentConfig => {
// https://www.elastic.co/guide/en/apm/agent/nodejs/current/configuration.html

return {
active: process.env.ELASTIC_APM_ACTIVE || false,
active: process.env.ELASTIC_APM_ACTIVE === 'true' || false,
environment: process.env.ELASTIC_APM_ENVIRONMENT || process.env.NODE_ENV || 'development',

serverUrl: 'https://b1e3b4b4233e44cdad468c127d0af8d8.apm.europe-west1.gcp.cloud.es.io:443',
serverUrl: 'https://38b80fbd79fb4c91bae06b4642d4d093.apm.us-east-1.aws.cloud.es.io',

// The secretToken below is intended to be hardcoded in this file even though
// it makes it public. This is not a security/privacy issue. Normally we'd
// instead disable the need for a secretToken in the APM Server config where
// the data is transmitted to, but due to how it's being hosted, it's easier,
// for now, to simply leave it in.
secretToken: '2OyjjaI6RVkzx2O5CV',
secretToken: 'ZQHYvrmXEx04ozge8F',

logUncaughtExceptions: true,
globalLabels: {},
centralConfig: false,
metricsInterval: isDistributable ? '120s' : '30s',
transactionSampleRate: process.env.ELASTIC_APM_TRANSACTION_SAMPLE_RATE
? parseFloat(process.env.ELASTIC_APM_TRANSACTION_SAMPLE_RATE)
: 1.0,

// Can be performance intensive, disabling by default
breakdownMetrics: isDistributable ? false : true,
Expand Down Expand Up @@ -150,8 +155,9 @@ export class ApmConfiguration {
globalLabels: {
branch: process.env.ghprbSourceBranch || '',
targetBranch: process.env.ghprbTargetBranch || '',
ciJobName: process.env.JOB_NAME || '',
ciBuildNumber: process.env.BUILD_NUMBER || '',
isPr: process.env.GITHUB_PR_NUMBER ? true : false,
prId: process.env.GITHUB_PR_NUMBER || '',
},
};
}
Expand Down
5 changes: 4 additions & 1 deletion vars/kibanaPipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def withFunctionalTestEnv(List additionalEnvs = [], Closure closure) {
def esTransportPort = "61${parallelId}3"
def fleetPackageRegistryPort = "61${parallelId}4"
def alertingProxyPort = "61${parallelId}5"
def apmActive = githubPr.isPr() ? "false" : "true"

withEnv([
"CI_GROUP=${parallelId}",
Expand All @@ -101,7 +102,9 @@ def withFunctionalTestEnv(List additionalEnvs = [], Closure closure) {
"TEST_ES_TRANSPORT_PORT=${esTransportPort}",
"KBN_NP_PLUGINS_BUILT=true",
"FLEET_PACKAGE_REGISTRY_PORT=${fleetPackageRegistryPort}",
"ALERTING_PROXY_PORT=${alertingProxyPort}"
"ALERTING_PROXY_PORT=${alertingProxyPort}",
"ELASTIC_APM_ACTIVE=${apmActive}",
"ELASTIC_APM_TRANSACTION_SAMPLE_RATE=0.1",
] + additionalEnvs) {
closure()
}
Expand Down
20 changes: 20 additions & 0 deletions x-pack/plugins/infra/common/http_api/metadata_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ export const InfraMetadataOSRT = rt.partial({
name: rt.string,
platform: rt.string,
version: rt.string,
build: rt.string,
});

export const InfraMetadataHostRT = rt.partial({
name: rt.string,
hostname: rt.string,
id: rt.string,
ip: rt.array(rt.string),
mac: rt.array(rt.string),
os: InfraMetadataOSRT,
architecture: rt.string,
containerized: rt.boolean,
Expand All @@ -43,25 +48,40 @@ export const InfraMetadataInstanceRT = rt.partial({
name: rt.string,
});

export const InfraMetadataAccountRT = rt.partial({
id: rt.string,
name: rt.string,
});

export const InfraMetadataProjectRT = rt.partial({
id: rt.string,
});

export const InfraMetadataMachineRT = rt.partial({
interface: rt.string,
type: rt.string,
});

export const InfraMetadataCloudRT = rt.partial({
instance: InfraMetadataInstanceRT,
provider: rt.string,
account: InfraMetadataAccountRT,
availability_zone: rt.string,
project: InfraMetadataProjectRT,
machine: InfraMetadataMachineRT,
region: rt.string,
});

export const InfraMetadataAgentRT = rt.partial({
id: rt.string,
version: rt.string,
policy: rt.string,
});

export const InfraMetadataInfoRT = rt.partial({
cloud: InfraMetadataCloudRT,
host: InfraMetadataHostRT,
agent: InfraMetadataAgentRT,
});

const InfraMetadataRequiredRT = rt.type({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ import { InventoryItemType } from '../../../../../../common/inventory_models/typ
import { MetricsTab } from './tabs/metrics/metrics';
import { LogsTab } from './tabs/logs';
import { ProcessesTab } from './tabs/processes';
import { PropertiesTab } from './tabs/properties';
import { PropertiesTab } from './tabs/properties/index';
import { OVERLAY_Y_START, OVERLAY_BOTTOM_MARGIN, OVERLAY_HEADER_SIZE } from './tabs/shared';
import { useLinkProps } from '../../../../../hooks/use_link_props';
import { getNodeDetailUrl } from '../../../../link_to';
import { findInventoryModel } from '../../../../../../common/inventory_models';

interface Props {
isOpen: boolean;
Expand All @@ -35,6 +38,8 @@ export const NodeContextPopover = ({
}: Props) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
const tabConfigs = [MetricsTab, LogsTab, ProcessesTab, PropertiesTab];
const inventoryModel = findInventoryModel(nodeType);
const nodeDetailFrom = currentTime - inventoryModel.metrics.defaultTimeRangeInSeconds * 1000;

const tabs = useMemo(() => {
return tabConfigs.map((m) => {
Expand All @@ -50,6 +55,15 @@ export const NodeContextPopover = ({

const [selectedTab, setSelectedTab] = useState(0);

const nodeDetailMenuItemLinkProps = useLinkProps({
...getNodeDetailUrl({
nodeType,
nodeId: node.id,
from: nodeDetailFrom,
to: currentTime,
}),
});

if (!isOpen) {
return null;
}
Expand All @@ -65,9 +79,28 @@ export const NodeContextPopover = ({
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonEmpty onClick={onClose} iconType={'cross'}>
<FormattedMessage id="xpack.infra.infra.nodeDetails.close" defaultMessage="Close" />
</EuiButtonEmpty>
<EuiFlexGroup gutterSize={'xs'} alignItems={'flexEnd'}>
<EuiFlexItem grow={false}>
<EuiButtonEmpty
iconSide={'left'}
iconType={'popout'}
href={nodeDetailMenuItemLinkProps.href}
>
<FormattedMessage
id="xpack.infra.infra.nodeDetails.openAsPage"
defaultMessage="Open as page"
/>
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonEmpty onClick={onClose} iconType={'cross'}>
<FormattedMessage
id="xpack.infra.infra.nodeDetails.close"
defaultMessage="Close"
/>
</EuiButtonEmpty>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
</OverlayHeaderTitleWrapper>
<EuiTabs>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
PointerEvent,
} from '@elastic/charts';
import moment from 'moment';
import { EuiLoadingChart } from '@elastic/eui';
import { TabContent, TabProps } from '../shared';
import { useSnapshot } from '../../../../hooks/use_snaphot';
import { useWaffleOptionsContext } from '../../../../hooks/use_waffle_options';
Expand Down Expand Up @@ -82,9 +83,9 @@ const TabComponent = (props: TabProps) => {
}

const buildCustomMetric = useCallback(
(field: string, id: string) => ({
(field: string, id: string, aggregation: string = 'avg') => ({
type: 'custom' as SnapshotMetricType,
aggregation: 'avg',
aggregation,
field,
id,
}),
Expand All @@ -110,6 +111,7 @@ const TabComponent = (props: TabProps) => {
buildCustomMetric('system.load.15', 'load15m'),
buildCustomMetric('system.memory.actual.used.bytes', 'usedMemory'),
buildCustomMetric('system.memory.actual.free', 'freeMemory'),
buildCustomMetric('system.cpu.cores', 'cores', 'max'),
],
[],
nodeType,
Expand Down Expand Up @@ -223,6 +225,7 @@ const TabComponent = (props: TabProps) => {
const load15mMetricsTs = useMemo(() => getTimeseries('load15m'), [getTimeseries]);
const usedMemoryMetricsTs = useMemo(() => getTimeseries('usedMemory'), [getTimeseries]);
const freeMemoryMetricsTs = useMemo(() => getTimeseries('freeMemory'), [getTimeseries]);
const coresMetricsTs = useMemo(() => getTimeseries('cores'), [getTimeseries]);

useEffect(() => {
reload();
Expand All @@ -239,7 +242,7 @@ const TabComponent = (props: TabProps) => {
!usedMemoryMetricsTs ||
!freeMemoryMetricsTs
) {
return <div />;
return <LoadingPlaceholder />;
}

const cpuChartMetrics = buildChartMetricLabels([SYSTEM_METRIC_NAME, USER_METRIC_NAME], 'avg');
Expand All @@ -253,6 +256,23 @@ const TabComponent = (props: TabProps) => {
'rate'
);

systemMetricsTs.rows = systemMetricsTs.rows.slice().map((r, idx) => {
const metric = r.metric_0 as number | undefined;
const cores = coresMetricsTs!.rows[idx].metric_0 as number | undefined;
if (metric && cores) {
r.metric_0 = metric / cores;
}
return r;
});

userMetricsTs.rows = userMetricsTs.rows.slice().map((r, idx) => {
const metric = r.metric_0 as number | undefined;
const cores = coresMetricsTs!.rows[idx].metric_0 as number | undefined;
if (metric && cores) {
r.metric_0 = metric / cores;
}
return r;
});
const cpuTimeseries = mergeTimeseries(systemMetricsTs, userMetricsTs);
const networkTimeseries = mergeTimeseries(rxMetricsTs, txMetricsTs);
const loadTimeseries = mergeTimeseries(load1mMetricsTs, load5mMetricsTs, load15mMetricsTs);
Expand Down Expand Up @@ -467,6 +487,23 @@ const ChartContainer: React.FC = ({ children }) => (
</div>
);

const LoadingPlaceholder = () => {
return (
<div
style={{
width: '100%',
height: '100%',
padding: '16px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<EuiLoadingChart size="xl" />
</div>
);
};

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

This file was deleted.

Loading

0 comments on commit 4ce9fef

Please sign in to comment.