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

Anomaly score annotations #522

Closed
1 of 3 tasks
formgeist opened this issue Jan 23, 2020 · 4 comments
Closed
1 of 3 tasks

Anomaly score annotations #522

formgeist opened this issue Jan 23, 2020 · 4 comments
Labels
:annotation Annotation (line, rect, text) related issue enhancement New feature or request

Comments

@formgeist
Copy link

Describe the solution you'd like
In Observability, we have a number of new machine learning anomaly jobs that will be showing anomaly results in various chart types in Observability. On top of this, we have just implemented time-series annotations that use a similar feature like the annotation functionality in Elastic Charts.

deployment-annotation

Example of deployment annotation in APM

We have a design concept where we want to annotate the highest anomaly score per bucket of time in the chart, but filter so we only show when the score is larger than X. The concept shows the annotation without a vertical line but adjacent to the bottom of the chart.

anomaly-annotations-barchart

Describe alternatives you've considered
Initially, we have considered using a vertical highlighting of the anomalies, similar to the existing implementation of anomaly detection in APM. But because we have several lines, annotations and colors all at once, the anomaly scores can very easily clutter on top of the actual data.

Screenshot 2020-01-21 at 10 35 38

Additional context
We're mentioning an APM use case, but there's also an existing use case in Logs within Observability and we'll only see more annotations throughout Observability solutions in the near-term.

Kibana Cross Issues

Checklist

  • this request is checked against already exist requests
  • every related Kibana issue is listed under Kibana Cross Issues list
  • kibana cross issue tag is associated to the issue if any kibana cross issue is present
@formgeist formgeist added enhancement New feature or request :annotation Annotation (line, rect, text) related issue labels Jan 23, 2020
@formgeist
Copy link
Author

@elastic/elastic-charts We're happy to do a meeting to discuss the scope and requirements on this if anyone wants to participate?

@markov00
Copy link
Member

Sure @formgeist, can you invite me, @rshen91 @monfera and @nickofthyme

@markov00
Copy link
Member

markov00 commented Feb 18, 2020

This is a possible first workaround to make this work with the current implementation of the LineAnnotation :

Screenshot 2020-02-18 at 16 34 00

import React from 'react';
import {
  Chart,
  ScaleType,
  Position,
  Axis,
  getAxisId,
  timeFormatter,
  getSpecId,
  Settings,
  LineAnnotation,
  BarSeries,
} from '../src';
import { KIBANA_METRICS } from '../src/utils/data_samples/test_dataset_kibana';
export class Playground extends React.Component {
  chartRef: React.RefObject<Chart> = React.createRef();
  onBrushEnd = (min: number, max: number) => {
    // eslint-disable-next-line no-console
    console.log({ min, max });
  };

  render() {
    return (
      <>
        <div className="chart">
          <Chart className={'story-chart'}>
            <Settings showLegend={true} theme={{}} />
            <Axis
              id={getAxisId('bottom')}
              title={'timestamp per 1 minute'}
              position={Position.Bottom}
              showOverlappingTicks={true}
              tickFormat={timeFormatter('HH:mm')}
            />
            <Axis
              id={getAxisId('left')}
              title={KIBANA_METRICS.metrics.kibana_os_load[0].metric.title}
              position={Position.Left}
              tickFormat={(d) => Number(d).toFixed(2)}
            />

            <BarSeries
              id={getSpecId('area')}
              xScaleType={ScaleType.Time}
              yScaleType={ScaleType.Linear}
              xAccessor={0}
              yAccessors={[1]}
              data={KIBANA_METRICS.metrics.kibana_os_load[0].data.slice(0, 50).map((d) => {
                return [...d, d[1] - 10];
              })}
            />
            <LineAnnotation
              id={'line'}
              style={{
                line: {
                  opacity: 0, // this will hide the line
                },
              }}
              dataValues={[
                { dataValue: KIBANA_METRICS.metrics.kibana_os_load[0].data[3][0], details: 'anomaly 1' },
                { dataValue: KIBANA_METRICS.metrics.kibana_os_load[0].data[7][0], details: 'anomaly 2' },
                { dataValue: KIBANA_METRICS.metrics.kibana_os_load[0].data[10][0], details: 'anomaly 3' },
                { dataValue: KIBANA_METRICS.metrics.kibana_os_load[0].data[11][0], details: 'anomaly 4' },
              ]}
              domainType={'xDomain'}
              marker={
                <div
                  style={{
                    marginTop: '2px',
                    width: '10px', // the width is statically confiured, see #556
                    height: '4px',
                    background: 'red',
                  }}
                />
              }
            />
          </Chart>
        </div>
      </>
    );
  }
}

The linked issues, #555 and #556 will take care of adding the annotation to the legend and a valid marker width

@formgeist
Copy link
Author

@markov00 Thanks for the example and for opening those new issues to help with the legend and marker widths. I think we can close this issue as it's resolved by your example and we'll follow the progress of the open issues, as we don't have a requirement right now to have this available in Elastic Charts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:annotation Annotation (line, rect, text) related issue enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants