From 7cb4d655845b8062b7fcf680d24e902c7ea11407 Mon Sep 17 00:00:00 2001 From: Galen Kistler <109082771+gtk-grafana@users.noreply.github.com> Date: Fri, 21 Apr 2023 09:12:28 -0500 Subject: [PATCH] Prometheus: Add Victoria metrics to Prometheus type dropdown in datasource config (#66984) * add VictoriaMetrics to prometheus type dropdown --- docs/sources/datasources/prometheus/_index.md | 44 +++++++------- .../grafana-ui/src/components/Badge/Badge.tsx | 2 +- .../configuration/PromFlavorVersions.ts | 11 ++++ .../prometheus/configuration/PromSettings.tsx | 54 ++++++++++-------- .../datasource/prometheus/datasource.tsx | 5 ++ .../datasource/prometheus/img/vm_logo.png | Bin 0 -> 4595 bytes public/app/types/unified-alerting-dto.ts | 1 + 7 files changed, 70 insertions(+), 47 deletions(-) create mode 100644 public/app/plugins/datasource/prometheus/img/vm_logo.png diff --git a/docs/sources/datasources/prometheus/_index.md b/docs/sources/datasources/prometheus/_index.md index 2a95f1ba839..205c5aa6bc3 100644 --- a/docs/sources/datasources/prometheus/_index.md +++ b/docs/sources/datasources/prometheus/_index.md @@ -45,28 +45,28 @@ To configure basic settings for the data source, complete the following steps: 1. Set the data source's basic configuration options: - | Name | Description | - | ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - | `Name` | The data source name. This is how you refer to the data source in panels and queries. | - | `Default` | Default data source that is pre-selected for new panels. | - | `URL` | The URL of your Prometheus server, for example, `http://prometheus.example.org:9090`. | - | `Access` | Only Server access mode is functional. If Server mode is already selected this option is hidden. Otherwise change to Server mode to prevent errors. | - | `Basic Auth` | Enable basic authentication to the Prometheus data source. | - | `User` | User name for basic authentication. | - | `Password` | Password for basic authentication. | - | `Manage alerts via Alerting UI` | Toggle whether to enable Alertmanager integration for this data source. | - | `Scrape interval` | Set this to the typical scrape and evaluation interval configured in Prometheus. Defaults to 15s. | - | `HTTP method` | Use either POST or GET HTTP method to query your data source. POST is the recommended and pre-selected method as it allows bigger queries. Change this to GET if you have a Prometheus version older than 2.1 or if POST requests are restricted in your network. | - | `Type` | The type of your Prometheus server; `Prometheus`, `Cortex`, `Thanos`, `Mimir`. When selected, the **Version** field attempts to populate automatically using the Prometheus [buildinfo](https://semver.org/) API. Some Prometheus types, such as Cortex, don't support this API and must be manually populated. | - | `Version` | The version of your Prometheus server, note that this field is not visible until the Prometheus type is selected. | - | `Disable metrics lookup` | Checking this option will disable the metrics chooser and metric/label support in the query field's autocomplete. This helps if you have performance issues with bigger Prometheus instances. | - | `Custom query parameters` | Add custom parameters to the Prometheus query URL. For example `timeout`, `partial_response`, `dedup`, or `max_source_resolution`. Multiple parameters should be concatenated together with an '&'. | - | **Exemplars configuration** | | - | `Internal link` | 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. | - | `Data source` | _(Visible only if you enable `Internal link`)_ Selects the backend tracing data store for your exemplar data. | - | `URL` | _(Visible only if you disable `Internal link`)_ Defines the external link's full URL. You can interpolate the value from the field by using the [`${__value.raw}` macro]({{< relref "../..//panels-visualizations/configure-data-links/#value-variables" >}}). | - | `URL Label` | _(Optional)_ Adds a custom display label to override the value of the `Label name` field. | - | `Label name` | Adds a name for the exemplar traceID property. | + | Name | Description | + | ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | + | `Name` | The data source name. This is how you refer to the data source in panels and queries. | + | `Default` | Default data source that is pre-selected for new panels. | + | `URL` | The URL of your Prometheus server, for example, `http://prometheus.example.org:9090`. | + | `Access` | Only Server access mode is functional. If Server mode is already selected this option is hidden. Otherwise change to Server mode to prevent errors. | + | `Basic Auth` | Enable basic authentication to the Prometheus data source. | + | `User` | User name for basic authentication. | + | `Password` | Password for basic authentication. | + | `Manage alerts via Alerting UI` | Toggle whether to enable Alertmanager integration for this data source. | + | `Scrape interval` | Set this to the typical scrape and evaluation interval configured in Prometheus. Defaults to 15s. | + | `HTTP method` | Use either POST or GET HTTP method to query your data source. POST is the recommended and pre-selected method as it allows bigger queries. Change this to GET if you have a Prometheus version older than 2.1 or if POST requests are restricted in your network. | + | `Type` | The type of your Prometheus server; `Prometheus`, `Cortex`, `Thanos`, `Mimir`. When selected, the **Version** field attempts to populate automatically using the Prometheus [buildinfo](https://prometheus.io/docs/prometheus/latest/querying/api/#build-information) API. Some Prometheus types, such as Cortex or VictoriaMetrics, don't support this API or provide version info, and must be manually populated. | + | `Version` | The version of your Prometheus server, note that this field is not visible until the Prometheus type is selected. | + | `Disable metrics lookup` | Checking this option will disable the metrics chooser and metric/label support in the query field's autocomplete. This helps if you have performance issues with bigger Prometheus instances. | + | `Custom query parameters` | Add custom parameters to the Prometheus query URL. For example `timeout`, `partial_response`, `dedup`, or `max_source_resolution`. Multiple parameters should be concatenated together with an '&'. | + | **Exemplars configuration** | | + | `Internal link` | 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. | + | `Data source` | _(Visible only if you enable `Internal link`)_ Selects the backend tracing data store for your exemplar data. | + | `URL` | _(Visible only if you disable `Internal link`)_ Defines the external link's full URL. You can interpolate the value from the field by using the [`${__value.raw}` macro]({{< relref "../..//panels-visualizations/configure-data-links/#value-variables" >}}). | + | `URL Label` | _(Optional)_ Adds a custom display label to override the value of the `Label name` field. | + | `Label name` | Adds a name for the exemplar traceID property. | ### Provision the data source diff --git a/packages/grafana-ui/src/components/Badge/Badge.tsx b/packages/grafana-ui/src/components/Badge/Badge.tsx index e97bcd10526..faf9e5f7125 100644 --- a/packages/grafana-ui/src/components/Badge/Badge.tsx +++ b/packages/grafana-ui/src/components/Badge/Badge.tsx @@ -9,7 +9,7 @@ import { IconName } from '../../types'; import { Icon } from '../Icon/Icon'; import { Tooltip } from '../Tooltip/Tooltip'; -export type BadgeColor = 'blue' | 'red' | 'green' | 'orange' | 'purple'; +export type BadgeColor = 'blue' | 'red' | 'green' | 'orange' | 'purple' | 'black'; export interface BadgeProps extends HTMLAttributes { text: React.ReactNode; diff --git a/public/app/plugins/datasource/prometheus/configuration/PromFlavorVersions.ts b/public/app/plugins/datasource/prometheus/configuration/PromFlavorVersions.ts index eb113762df4..457b857d77d 100644 --- a/public/app/plugins/datasource/prometheus/configuration/PromFlavorVersions.ts +++ b/public/app/plugins/datasource/prometheus/configuration/PromFlavorVersions.ts @@ -77,4 +77,15 @@ export const PromFlavorVersions: { [index: string]: Array<{ value?: string; labe { value: '1.13.0', label: '1.13.x' }, { value: '1.14.0', label: '> 1.13.x' }, ], + VictoriaMetrics: [ + { value: '1.23.0', label: '< 1.24.0' }, + { value: '1.24.0', label: '>= 1.24.x' }, + { value: '1.30.0', label: '1.3x' }, + { value: '1.40.0', label: '1.4x' }, + { value: '1.50.0', label: '1.5x' }, + { value: '1.60.0', label: '1.6x' }, + { value: '1.70.0', label: '1.7x' }, + { value: '1.80.0', label: '1.8x' }, + { value: '1.90.0', label: '>= 1.9x' }, + ], }; diff --git a/public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx b/public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx index b6594c2738c..77d064c35f0 100644 --- a/public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx +++ b/public/app/plugins/datasource/prometheus/configuration/PromSettings.tsx @@ -56,6 +56,7 @@ const prometheusFlavorSelectItems: PrometheusSelectItemsType = [ { value: PromApplication.Cortex, label: PromApplication.Cortex }, { value: PromApplication.Mimir, label: PromApplication.Mimir }, { value: PromApplication.Thanos, label: PromApplication.Thanos }, + { value: PromApplication.VictoriaMetrics, label: PromApplication.VictoriaMetrics }, ]; type Props = Pick, 'options' | 'onOptionsChange'>; @@ -118,32 +119,37 @@ const setPrometheusVersion = ( // This will save the current state of the form, as the url is needed for this API call to function onUpdate(options) .then((updatedOptions) => { - getBackendSrv() - .get(`/api/datasources/uid/${updatedOptions.uid}/resources/version-detect`) - .then((rawResponse: PromBuildInfoResponse) => { - const rawVersionStringFromApi = rawResponse.data?.version ?? ''; - if (rawVersionStringFromApi && semver.valid(rawVersionStringFromApi)) { - const parsedVersion = getVersionString(rawVersionStringFromApi, updatedOptions.jsonData.prometheusType); - // If we got a successful response, let's update the backend with the version right away if it's new - if (parsedVersion) { - onUpdate({ - ...updatedOptions, - jsonData: { - ...updatedOptions.jsonData, - prometheusVersion: parsedVersion, - }, - }).then((updatedUpdatedOptions) => { - onOptionsChange(updatedUpdatedOptions); - }); + // Not seeing version info in buildinfo response from VictoriaMetrics, and Cortex doesn't support yet, users will need to manually select version + if ( + updatedOptions.jsonData.prometheusType !== PromApplication.VictoriaMetrics && + updatedOptions.jsonData.prometheusType !== PromApplication.Cortex + ) { + getBackendSrv() + .get(`/api/datasources/uid/${updatedOptions.uid}/resources/version-detect`) + .then((rawResponse: PromBuildInfoResponse) => { + const rawVersionStringFromApi = rawResponse.data?.version ?? ''; + if (rawVersionStringFromApi && semver.valid(rawVersionStringFromApi)) { + const parsedVersion = getVersionString(rawVersionStringFromApi, updatedOptions.jsonData.prometheusType); + // If we got a successful response, let's update the backend with the version right away if it's new + if (parsedVersion) { + onUpdate({ + ...updatedOptions, + jsonData: { + ...updatedOptions.jsonData, + prometheusVersion: parsedVersion, + }, + }).then((updatedUpdatedOptions) => { + onOptionsChange(updatedUpdatedOptions); + }); + } + } else { + unableToDeterminePrometheusVersion(); } - } else { - unableToDeterminePrometheusVersion(); - } - }); + }) + .catch(unableToDeterminePrometheusVersion); + } }) - .catch((error) => { - unableToDeterminePrometheusVersion(error); - }); + .catch(unableToDeterminePrometheusVersion); }; export const PromSettings = (props: Props) => { diff --git a/public/app/plugins/datasource/prometheus/datasource.tsx b/public/app/plugins/datasource/prometheus/datasource.tsx index 7546ff3af29..cd003fc7b6e 100644 --- a/public/app/plugins/datasource/prometheus/datasource.tsx +++ b/public/app/plugins/datasource/prometheus/datasource.tsx @@ -173,6 +173,8 @@ export class PrometheusDatasource this._isDatasourceVersionGreaterOrEqualTo('2.0.0', PromApplication.Mimir) || // https://github.com/cortexproject/cortex/discussions/4542 this._isDatasourceVersionGreaterOrEqualTo('1.11.0', PromApplication.Cortex) || + //https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.24.0 + this._isDatasourceVersionGreaterOrEqualTo('1.24.0', PromApplication.VictoriaMetrics) || // https://github.com/thanos-io/thanos/pull/3566 //https://github.com/thanos-io/thanos/releases/tag/v0.18.0 this._isDatasourceVersionGreaterOrEqualTo('0.18.0', PromApplication.Thanos) @@ -992,6 +994,7 @@ export class PrometheusDatasource [PromApplication.Mimir]: '/public/app/plugins/datasource/prometheus/img/mimir_logo.svg', [PromApplication.Prometheus]: '/public/app/plugins/datasource/prometheus/img/prometheus_logo.svg', [PromApplication.Thanos]: '/public/app/plugins/datasource/prometheus/img/thanos_logo.svg', + [PromApplication.VictoriaMetrics]: '/public/app/plugins/datasource/prometheus/img/vm_logo.svg', }; const COLORS: Record = { @@ -999,6 +1002,7 @@ export class PrometheusDatasource [PromApplication.Mimir]: 'orange', [PromApplication.Prometheus]: 'red', [PromApplication.Thanos]: 'purple', // Purple hex taken from thanos.io + [PromApplication.VictoriaMetrics]: 'black', }; const AppDisplayNames: Record = { @@ -1006,6 +1010,7 @@ export class PrometheusDatasource [PromApplication.Mimir]: 'Mimir', [PromApplication.Prometheus]: 'Prometheus', [PromApplication.Thanos]: 'Thanos', + [PromApplication.VictoriaMetrics]: 'VictoriaMetrics', }; const application = this.datasourceConfigurationPrometheusFlavor ?? buildInfo.application; diff --git a/public/app/plugins/datasource/prometheus/img/vm_logo.png b/public/app/plugins/datasource/prometheus/img/vm_logo.png new file mode 100644 index 0000000000000000000000000000000000000000..bf9f8e33df0ceaa1d3114612fa4e0859b2708b7a GIT binary patch literal 4595 zcmb_gX*kqv)c?<7PsXkx##l=s#n_h`lU;^~7^0F4Gugsqof+GZHKgoe>}zGu7EvU5 z?AgjLWed@W*YkdSKffRDbALGJ{+;VO*YDitT)*fWX4g5{;p_kaa2gt*u_rhAzr)IW zVmq~O_W=NRlObBqij?`oA-G&*>>r)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|CLMXO5Ck@|BQq0M3Rw`KW} zLb)9#e~S&eUu`0mZ2Q6KltfgGRg)JUze*!ElHqkc0MEIbC&TAE8@5_>m#V8ED5IbL zS`$3&mfZ8ixKS=Tx01nxeiKaPtA*qaFU9gHyE|P5wKr@np71Q1hU(@cBhnszBH)Q>v)8>@4wK2z0e z?${b1>|#fP&uvsXwjKGVV(|md)Q*Y;V`xVmT-3?rx=Hp77m%$Gn^Mr-=#`;Ee&(9Po6wdO@mrQ!E|oqWK52& zK0HmAq{WAQ`a1EpLmaG{VpiacT=8(0q}n~U6$hRfiWF&NP4BwxHWv?9oH2)uR8&!c zjhwQPTk8*-8N3^N#+@t5zNS5myr5RX(^OUe9rTTuytB7phc!uND!$SF*pECQlN62V z^|pZ#HwAF}+3sd0Q=ZuD^D#!#)>R|SdHjhrIya=0LUtfo+Ek;zbP;1-lC>y1n`iUb zgJV++vUvAd1VWLcDPtxU?Wj*?rx#HYRFZkx=gIrH?B%m2a@7-rTWsi18n7YyYT{K@ zl|F4_CpfgKf9TDKVjmQ!80_Ik4YLa<6}mb*3+Y|>1JmLFs@^Yq09|X8m4FXIy0{YT0WC# zys-8>6Xp4B=YH>X_jh(kKoXkoz}6xAM>J(XQG9bs!yP$kHj z6aF)Ug`~boIoUggZ23si@9bhgPlV{i50e-_L;sn}XasLkNSlH=B*`^nYc%0?Fta<@ z{W$Zmj*lJgM%|P*uB$o`a{xnqGj!!uC+hzI DYdMIW literal 0 HcmV?d00001 diff --git a/public/app/types/unified-alerting-dto.ts b/public/app/types/unified-alerting-dto.ts index 487d8cda0a3..e01a9af3404 100644 --- a/public/app/types/unified-alerting-dto.ts +++ b/public/app/types/unified-alerting-dto.ts @@ -64,6 +64,7 @@ export enum PromApplication { Mimir = 'Mimir', Prometheus = 'Prometheus', Thanos = 'Thanos', + VictoriaMetrics = 'VictoriaMetrics', } export interface PromBuildInfoResponse {