From baa12d7dce288906e678ac7e8a4816694ce2e455 Mon Sep 17 00:00:00 2001 From: Kevin Yu Date: Wed, 14 Jan 2026 11:32:18 -0800 Subject: [PATCH] Prometheus: Allow hiding prom type/version and exemplar settings --- .../src/configuration/PromSettings.tsx | 234 +++++++++--------- packages/grafana-prometheus/src/index.ts | 2 +- 2 files changed, 124 insertions(+), 112 deletions(-) diff --git a/packages/grafana-prometheus/src/configuration/PromSettings.tsx b/packages/grafana-prometheus/src/configuration/PromSettings.tsx index 48f7c00e46f..3ec4fc8bf20 100644 --- a/packages/grafana-prometheus/src/configuration/PromSettings.tsx +++ b/packages/grafana-prometheus/src/configuration/PromSettings.tsx @@ -30,7 +30,12 @@ import { ExemplarsSettings } from './ExemplarsSettings'; import { PromFlavorVersions } from './PromFlavorVersions'; import { docsTip, overhaulStyles, validateInput } from './shared/utils'; -type Props = Pick, 'options' | 'onOptionsChange'>; +type Props = Pick, 'options' | 'onOptionsChange'> & { + /** Hide the Prometheus type and version dropdowns */ + hidePrometheusTypeVersion?: boolean; + /** Hide the Exemplars settings section */ + hideExemplars?: boolean; +}; const httpOptions = [ { value: 'POST', label: 'POST' }, @@ -72,7 +77,7 @@ const getOptionsWithDefaults = (options: DataSourceSettings) => { export const PromSettings = (props: Props) => { const theme = useTheme2(); const styles = overhaulStyles(theme); - const { onOptionsChange } = props; + const { onOptionsChange, hidePrometheusTypeVersion, hideExemplars } = props; const editorOptions = [ { @@ -259,106 +264,111 @@ export const PromSettings = (props: Props) => { title={t('grafana-prometheus.configuration.prom-settings.title-performance', 'Performance')} className={styles.container} > - {!optionsWithDefaults.jsonData.prometheusType && - !optionsWithDefaults.jsonData.prometheusVersion && - optionsWithDefaults.readOnly && ( -
- - For more information on configuring prometheus type and version in data sources, see the{' '} - - provisioning documentation - - . - -
- )} -
-
-
- - {/* , and attempt to detect the version */} - - Set this to the type of your prometheus database, e.g. Prometheus, Cortex, Mimir or Thanos. - Changing this field will save your current settings. Certain types of Prometheus supports or does - not support various APIs. For example, some types support regex matching for label queries to - improve performance. Some types have an API for metadata. If you set this incorrectly you may - experience odd behavior when querying metrics and labels. Please check your Prometheus - documentation to ensure you enter the correct type. - {' '} - {docsTip()} - - } - interactive={true} - disabled={optionsWithDefaults.readOnly} - > - o.value === optionsWithDefaults.jsonData.prometheusVersion - )} - onChange={onChangeHandler('prometheusVersion', optionsWithDefaults, onOptionsChange)} - width={40} - data-testid={selectors.components.DataSource.Prometheus.configPage.prometheusVersion} - /> - + interactive={true} + disabled={optionsWithDefaults.readOnly} + > + o.value === optionsWithDefaults.jsonData.prometheusVersion + )} + onChange={onChangeHandler('prometheusVersion', optionsWithDefaults, onOptionsChange)} + width={40} + data-testid={selectors.components.DataSource.Prometheus.configPage.prometheusVersion} + /> + +
+ )} +
+
+ + )} +
{
- - updateDatasourcePluginJsonDataOption( - { onOptionsChange, options: optionsWithDefaults }, - 'exemplarTraceIdDestinations', - exemplarOptions - ) - } - disabled={optionsWithDefaults.readOnly} - /> + {!hideExemplars && ( + + updateDatasourcePluginJsonDataOption( + { onOptionsChange, options: optionsWithDefaults }, + 'exemplarTraceIdDestinations', + exemplarOptions + ) + } + disabled={optionsWithDefaults.readOnly} + /> + )} ); }; diff --git a/packages/grafana-prometheus/src/index.ts b/packages/grafana-prometheus/src/index.ts index f6950cc9fb7..5d617d5fcb5 100644 --- a/packages/grafana-prometheus/src/index.ts +++ b/packages/grafana-prometheus/src/index.ts @@ -67,7 +67,7 @@ export { transformV2, transformDFToTable, parseSampleValue, sortSeriesByLabel } export { type PromQuery, type PrometheusCacheLevel, - type PromApplication, + PromApplication, type PromOptions, type ExemplarTraceIdDestination, type PromQueryRequest,