grafana/public/app/plugins/datasource/loki/components/AnnotationsQueryEditor.tsx
David 091e3cf4f8
Loki: Label browser (#30351)
* Loki: Label browser

- replaces stream cascader widget which made it hard to find relevant streams
- multi-step selection allows for selecting a couple of labels first, then find the relevant values
- supports facetting which makes impossible label combinations hard to choose

* Remove unused label hook

* Remove unused label styles

* Use global time range for metadata requests

* Preselect labels if not many exist

* Status and error messages

* Status fixes

* Remove unused import

* Added logs rate button

* Close popup when clicked outside (not working for timepicker :( )

* Change button label

* Get rid of popup and render browser inline

* Review feedback

* Wrap label values and prevent empty lists

Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
2021-03-02 16:58:14 +01:00

45 lines
1.0 KiB
TypeScript

// Libraries
import React, { memo } from 'react';
// Types
import { LokiQuery } from '../types';
import { LokiQueryFieldForm } from './LokiQueryFieldForm';
import LokiDatasource from '../datasource';
interface Props {
expr: string;
maxLines?: number;
instant?: boolean;
datasource: LokiDatasource;
onChange: (query: LokiQuery) => void;
}
export const LokiAnnotationsQueryEditor = memo(function LokiAnnotationQueryEditor(props: Props) {
const { expr, maxLines, instant, datasource, onChange } = props;
// Timerange to get existing labels from. Hard coding like this seems to be good enough right now.
const absolute = {
from: Date.now() - 10000,
to: Date.now(),
};
const queryWithRefId: LokiQuery = {
refId: '',
expr,
maxLines,
instant,
};
return (
<div className="gf-form-group">
<LokiQueryFieldForm
datasource={datasource}
query={queryWithRefId}
onChange={onChange}
onRunQuery={() => {}}
history={[]}
absoluteRange={absolute}
/>
</div>
);
});