Prometheus: Create Prometheus library (#81641)

* Move to the library

* copy from library

* move them in src

* have additional files

* add unmigrated/dulicated code and files

* migrate from brendan's pr
module.ts, query_hints.ts, tracking.ts, and remove plugin.json

* migrate from brendan's pr
metric_find_query.test.ts

* migrate from brendan's pr
language_utils.test.ts

* migrate from brendan's pr
index.ts in root and in configuration

* migrate from brendan's pr
datasource.test.ts

* migrate from brendan's pr
typings folder

* migrate from brendan's pr
querycache folder

* migrate from brendan's pr
monaco-query-field folder

* migrate from brendan's pr
components folder without monaco-query-field folder

* migrate from brendan's pr
configuration/overhaul folder

* migrate from brendan's pr
AlertingSettingsOverhaul.tsx

* Remove azure related code

* migrate from brendan's pr
ConfigEditor.tsx, DataSourceHttpSettingsOverhaul.tsx, ExemplarSetting.tsx, configuration/mocks.ts, PromSettings.test.tsx, PromSettings.tsx

* migrate from brendan's pr
useFlag.ts

* migrate from brendan's pr
metrics-modal folder

* migrate from brendan's pr
files inside components folder

* migrate from brendan's pr
LabelFilters* files because they are now under components folder

* migrate from brendan's pr
files under querybuilder/shared folder

* migrate from brendan's pr
aggregations.ts, QueryPattern.tsx, QueryPatternsModal.tsx, state.ts, testUtils.ts under querybuilder folder

* Apply Ivana's PR https://github.com/grafana/grafana/pull/81656

* Apply jack's suggestions in this PR https://github.com/grafana/grafana/pull/77762

* Apply Ivana's PR https://github.com/grafana/grafana/pull/81656

* Fix type import

* add monaco-promql to transformIgnorePatterns to run prometheus frontend library tests

* remove Loki specific tests because we removed Loki code to decouple Loki

* add prometheus specific references

* We are moving these betterer issues from core Prometheus to the Library and we promise to remove all issues in the future, thank you

* include prometheus library in package.json

* add yarn lock with prometheus frontend library

* decouple final core import from metric_find_query.test.ts

* run prettier

* fix core imports in promqail

* fix lint errors

* run prettier

* add grafana-ui to devdeps to fix lint errors

* update yarn.lock

* grafana-ui fix

* trying to fix grafana-ui type errors with lerna drone check

* trying to fix grafana-ui type errors with lerna drone check

* trying to fix grafana-ui type errors with lerna drone check

* trying to fix grafana-ui type errors with lerna drone check

* try to pass typecheck

---------

Co-authored-by: Brendan O'Handley <brendan.ohandley@grafana.com>
This commit is contained in:
ismail simsek
2024-02-02 15:30:14 +01:00
committed by GitHub
parent 89271df647
commit 75c2d39f79
183 changed files with 33356 additions and 3 deletions

View File

@ -0,0 +1,150 @@
import React, { useState } from 'react';
import { DataSourceInstanceSettings } from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors';
import { DataSourcePicker } from '@grafana/runtime';
import { Button, InlineField, Input, Switch, useTheme2 } from '@grafana/ui';
import { ExemplarTraceIdDestination } from '../types';
import { docsTip, overhaulStyles, PROM_CONFIG_LABEL_WIDTH } from './ConfigEditor';
type Props = {
value: ExemplarTraceIdDestination;
onChange: (value: ExemplarTraceIdDestination) => void;
onDelete: () => void;
disabled?: boolean;
};
export default function ExemplarSetting({ value, onChange, onDelete, disabled }: Props) {
const [isInternalLink, setIsInternalLink] = useState(Boolean(value.datasourceUid));
const theme = useTheme2();
const styles = overhaulStyles(theme);
return (
<div className="gf-form-group">
<InlineField
label="Internal link"
labelWidth={PROM_CONFIG_LABEL_WIDTH}
disabled={disabled}
tooltip={
<>
Enable this option if you have an internal link. When enabled, this reveals the data source selector. Select
the backend tracing data store for your exemplar data. {docsTip()}
</>
}
interactive={true}
className={styles.switchField}
>
<>
<Switch
value={isInternalLink}
data-testid={selectors.components.DataSource.Prometheus.configPage.internalLinkSwitch}
onChange={(ev) => setIsInternalLink(ev.currentTarget.checked)}
/>
</>
</InlineField>
{isInternalLink ? (
<InlineField
label="Data source"
labelWidth={PROM_CONFIG_LABEL_WIDTH}
tooltip={<>The data source the exemplar is going to navigate to. {docsTip()}</>}
disabled={disabled}
interactive={true}
>
<DataSourcePicker
tracing={true}
current={value.datasourceUid}
noDefault={true}
width={40}
onChange={(ds: DataSourceInstanceSettings) =>
onChange({
...value,
datasourceUid: ds.uid,
url: undefined,
})
}
/>
</InlineField>
) : (
<InlineField
label="URL"
labelWidth={PROM_CONFIG_LABEL_WIDTH}
tooltip={<>The URL of the trace backend the user would go to see its trace. {docsTip()}</>}
disabled={disabled}
interactive={true}
>
<Input
placeholder="https://example.com/${__value.raw}"
spellCheck={false}
width={40}
value={value.url}
onChange={(event) =>
onChange({
...value,
datasourceUid: undefined,
url: event.currentTarget.value,
})
}
/>
</InlineField>
)}
<InlineField
label="URL Label"
labelWidth={PROM_CONFIG_LABEL_WIDTH}
tooltip={<>Use to override the button label on the exemplar traceID field. {docsTip()}</>}
disabled={disabled}
interactive={true}
>
<Input
placeholder="Go to example.com"
spellCheck={false}
width={40}
value={value.urlDisplayLabel}
onChange={(event) =>
onChange({
...value,
urlDisplayLabel: event.currentTarget.value,
})
}
/>
</InlineField>
<InlineField
label="Label name"
labelWidth={PROM_CONFIG_LABEL_WIDTH}
tooltip={<>The name of the field in the labels object that should be used to get the traceID. {docsTip()}</>}
disabled={disabled}
interactive={true}
>
<Input
placeholder="traceID"
spellCheck={false}
width={40}
value={value.name}
onChange={(event) =>
onChange({
...value,
name: event.currentTarget.value,
})
}
/>
</InlineField>
{!disabled && (
<InlineField label="Remove exemplar link" labelWidth={PROM_CONFIG_LABEL_WIDTH} disabled={disabled}>
<Button
variant="destructive"
title="Remove exemplar link"
icon="times"
onClick={(event) => {
event.preventDefault();
onDelete();
}}
/>
</InlineField>
)}
</div>
);
}