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 00000000000..bf9f8e33df0 Binary files /dev/null and b/public/app/plugins/datasource/prometheus/img/vm_logo.png differ 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 {