mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Prometheus: Add series endpoint configuration (#94443)
* add series endpoint configuration * gf-form is unnecessary and deprecated
This commit is contained in:
parent
ace177f20a
commit
748bfff601
@ -112,5 +112,12 @@ describe('PromSettings', () => {
|
||||
fireEvent.blur(input);
|
||||
expect(queryByText(countError)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should have a series endpoint configuration element', () => {
|
||||
const options = defaultProps;
|
||||
|
||||
render(<PromSettings onOptionsChange={() => {}} options={options} />);
|
||||
expect(screen.getByText('Use series endpoint')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -492,6 +492,26 @@ export const PromSettings = (props: Props) => {
|
||||
</InlineField>
|
||||
</div>
|
||||
</div>
|
||||
<InlineField
|
||||
labelWidth={PROM_CONFIG_LABEL_WIDTH}
|
||||
label="Use series endpoint"
|
||||
tooltip={
|
||||
<>
|
||||
Checking this option will favor the series endpoint with match[] parameter over the label values
|
||||
endpoint with match[] parameter. While the label values endpoint is considered more performant, some
|
||||
users may prefer the series because it has a POST method while the label values endpoint only has a GET
|
||||
method. {docsTip()}
|
||||
</>
|
||||
}
|
||||
interactive={true}
|
||||
disabled={options.readOnly}
|
||||
className={styles.switchField}
|
||||
>
|
||||
<Switch
|
||||
value={options.jsonData.seriesEndpoint ?? false}
|
||||
onChange={onUpdateDatasourceJsonDataOptionChecked(props, 'seriesEndpoint')}
|
||||
/>
|
||||
</InlineField>
|
||||
</div>
|
||||
</ConfigSubSection>
|
||||
|
||||
|
@ -111,6 +111,7 @@ export class PrometheusDatasource
|
||||
cacheLevel: PrometheusCacheLevel;
|
||||
cache: QueryCache<PromQuery>;
|
||||
metricNamesAutocompleteSuggestionLimit: number;
|
||||
seriesEndpoint: boolean;
|
||||
|
||||
constructor(
|
||||
instanceSettings: DataSourceInstanceSettings<PromOptions>,
|
||||
@ -136,6 +137,7 @@ export class PrometheusDatasource
|
||||
this.customQueryParameters = new URLSearchParams(instanceSettings.jsonData.customQueryParameters);
|
||||
this.datasourceConfigurationPrometheusFlavor = instanceSettings.jsonData.prometheusType;
|
||||
this.datasourceConfigurationPrometheusVersion = instanceSettings.jsonData.prometheusVersion;
|
||||
this.seriesEndpoint = instanceSettings.jsonData.seriesEndpoint ?? false;
|
||||
this.defaultEditor = instanceSettings.jsonData.defaultEditor;
|
||||
this.disableRecordingRules = instanceSettings.jsonData.disableRecordingRules ?? false;
|
||||
this.variables = new PrometheusVariableSupport(this, this.templateSrv);
|
||||
@ -183,6 +185,12 @@ export class PrometheusDatasource
|
||||
}
|
||||
|
||||
hasLabelsMatchAPISupport(): boolean {
|
||||
// users may choose the series endpoint as it has a POST method
|
||||
// while the label values is only GET
|
||||
if (this.seriesEndpoint) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (
|
||||
// https://github.com/prometheus/prometheus/releases/tag/v2.24.0
|
||||
this._isDatasourceVersionGreaterOrEqualTo('2.24.0', PromApplication.Prometheus) ||
|
||||
|
@ -53,6 +53,7 @@ export interface PromOptions extends DataSourceJsonData {
|
||||
sigV4Auth?: boolean;
|
||||
oauthPassThru?: boolean;
|
||||
codeModeMetricNamesSuggestionLimit?: number;
|
||||
seriesEndpoint?: boolean;
|
||||
}
|
||||
|
||||
export type ExemplarTraceIdDestination = {
|
||||
|
Loading…
Reference in New Issue
Block a user