Skip to content

Commit

Permalink
Adding technical preview badge
Browse files Browse the repository at this point in the history
  • Loading branch information
kobelb committed Jul 21, 2022
1 parent 0bf0a2d commit 07a945b
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { chain } from 'lodash';

/*
* Chart titles are taken from `metric.title` or `metric.label` fields in the series data.
* Use title if found, otherwise use label
*/
export function getTechnicalPreview(series = []) {
return chain(
series.map((s) => {
return Boolean(s.metric.technicalPreview);
})
)
.first()
.value();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import expect from '@kbn/expect';
import { getTechnicalPreview } from './get_technical_preview';

describe('getTechnicalPreview', function () {
it('with metric.technicalPreview undefined', () => {
const series = [{ metric: {} }, { metric: { technicalPreview: true } }];
expect(getTechnicalPreview(series)).to.be(false);
});

it('with metric.technicalPreview false', () => {
const series = [
{ metric: { technicalPreview: false } },
{ metric: { technicalPreview: true } },
];
expect(getTechnicalPreview(series)).to.be(false);
});

it('with metric.technicalPreview true', () => {
const series = [
{ metric: { technicalPreview: true } },
{ metric: { technicalPreview: false } },
];
expect(getTechnicalPreview(series)).to.be(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@

import React, { Fragment } from 'react';
import { get, first } from 'lodash';
import { getTechnicalPreview } from './get_technical_preview';
import { getTitle } from './get_title';
import { getUnits } from './get_units';
import { MonitoringTimeseries } from './monitoring_timeseries';
import { InfoTooltip } from './info_tooltip';
import './monitoring_timeseries_container.scss';

import {
EuiBadge,
EuiIconTip,
EuiFlexGroup,
EuiFlexItem,
Expand Down Expand Up @@ -50,12 +52,30 @@ const zoomOutBtn = (zoomInfo) => {
);
};

const technicalPreviewBadge = (technicalPreview) => {
if (!technicalPreview) {
return null;
}

return (
<EuiFlexItem>
<EuiBadge color="hollow" iconType="cheer">
<FormattedMessage
id="xpack.monitoring.chart.timeSeries.technicalPreview"
defaultMessage="Technical Preview"
/>
</EuiBadge>
</EuiFlexItem>
);
};

export function MonitoringTimeseriesContainer({ series, onBrush, zoomInfo }) {
if (series === undefined) {
return null; // still loading
}

const title = getTitle(series);
const technicalPreview = getTechnicalPreview(series);
const titleForAriaIds = title.replace(/\s+/, '--');
const units = getUnits(series);
const bucketSize = get(first(series), 'bucket_size'); // bucket size will be the same for all metrics in all series
Expand Down Expand Up @@ -115,6 +135,7 @@ export function MonitoringTimeseriesContainer({ series, onBrush, zoomInfo }) {
</EuiScreenReaderOnly>
</Fragment>
</EuiFlexItem>
{technicalPreviewBadge(technicalPreview)}
{zoomOutBtn(zoomInfo)}
</EuiFlexGroup>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ interface OptionalMetricOptions {
mbField?: string;
type?: string;
isNotSupportedInInternalCollection?: boolean;
technicalPreview?: boolean;
}

interface DefaultMetricOptions {
Expand Down Expand Up @@ -60,6 +61,7 @@ export class Metric {
public periodsField?: string;
public quotaField?: string;
public isNotSupportedInInternalCollection?: boolean;
public technicalPreview?: boolean;

constructor(opts: MetricOptions) {
const props: Required<DefaultMetricOptions> = {
Expand Down Expand Up @@ -99,6 +101,7 @@ export class Metric {
'description',
'units',
'format',
'technicalPreview',
];

const metric = Object.create(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type KibanaClusterMetricOptions = Pick<
| 'derivative'
| 'derivativeNormalizedUnits'
| 'isNotSupportedInInternalCollection'
| 'technicalPreview'
> &
Partial<Pick<MetricOptions, 'title'>>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ export const metrics = {
metricAgg: 'max',
units: '',
isNotSupportedInInternalCollection: true,
technicalPreview: true,
}),
kibana_instance_rule_executions: new KibanaInstanceRuleMetric({
derivative: true,
Expand All @@ -307,6 +308,7 @@ export const metrics = {
metricAgg: 'max',
units: '',
isNotSupportedInInternalCollection: true,
technicalPreview: true,
}),
kibana_instance_action_failures: new KibanaInstanceActionMetric({
derivative: true,
Expand All @@ -325,6 +327,7 @@ export const metrics = {
metricAgg: 'max',
units: '',
isNotSupportedInInternalCollection: true,
technicalPreview: true,
}),
kibana_instance_action_executions: new KibanaInstanceActionMetric({
derivative: true,
Expand All @@ -343,6 +346,7 @@ export const metrics = {
metricAgg: 'max',
units: '',
isNotSupportedInInternalCollection: true,
technicalPreview: true,
}),

kibana_cluster_rule_overdue_count: new KibanaClusterRuleMetric({
Expand All @@ -360,6 +364,7 @@ export const metrics = {
metricAgg: 'max',
units: '',
isNotSupportedInInternalCollection: true,
technicalPreview: true,
}),
kibana_cluster_rule_overdue_p50: new KibanaClusterRuleMetric({
title: ruleQueueDurationTitle,
Expand All @@ -377,6 +382,7 @@ export const metrics = {
metricAgg: 'max',
units: msTimeUnitLabel,
isNotSupportedInInternalCollection: true,
technicalPreview: true,
}),
kibana_cluster_rule_overdue_p99: new KibanaClusterRuleMetric({
title: ruleQueueDurationTitle,
Expand Down Expand Up @@ -413,6 +419,7 @@ export const metrics = {
metricAgg: 'max',
units: '',
isNotSupportedInInternalCollection: true,
technicalPreview: true,
}),
kibana_cluster_action_overdue_p50: new KibanaClusterActionMetric({
title: actionQueueDurationTitle,
Expand All @@ -430,6 +437,7 @@ export const metrics = {
metricAgg: 'max',
units: msTimeUnitLabel,
isNotSupportedInInternalCollection: true,
technicalPreview: true,
}),
kibana_cluster_action_overdue_p99: new KibanaClusterActionMetric({
title: actionQueueDurationTitle,
Expand All @@ -447,5 +455,6 @@ export const metrics = {
metricAgg: 'max',
units: msTimeUnitLabel,
isNotSupportedInInternalCollection: true,
technicalPreview: true,
}),
};

0 comments on commit 07a945b

Please sign in to comment.