The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/plugins/datasource/loki/components/LokiQueryField.tsx

30 lines
1.1 KiB

import React, { FunctionComponent } from 'react';
import { LokiQueryFieldForm, LokiQueryFieldFormProps } from './LokiQueryFieldForm';
import { useLokiSyntax } from './useLokiSyntax';
import LokiLanguageProvider from '../language_provider';
export const LokiQueryField: FunctionComponent<LokiQueryFieldFormProps> = ({ datasource, ...otherProps }) => {
const { isSyntaxReady, setActiveOption, refreshLabels, ...syntaxProps } = useLokiSyntax(
datasource.languageProvider as LokiLanguageProvider,
otherProps.absoluteRange
);
return (
<LokiQueryFieldForm
datasource={datasource}
syntaxLoaded={isSyntaxReady}
/**
* setActiveOption name is intentional. Because of the way rc-cascader requests additional data
* https://github.com/react-component/cascader/blob/master/src/Cascader.jsx#L165
* we are notyfing useLokiSyntax hook, what the active option is, and then it's up to the hook logic
* to fetch data of options that aren't fetched yet
*/
onLoadOptions={setActiveOption}
onLabelsRefresh={refreshLabels}
{...syntaxProps}
{...otherProps}
/>
);
};
export default LokiQueryField;