mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Prometheus: Add Victoria metrics to Prometheus type dropdown in datasource config (#66984)
* add VictoriaMetrics to prometheus type dropdown
This commit is contained in:
parent
b6953763f4
commit
7cb4d65584
@ -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:
|
1. Set the data source's basic configuration options:
|
||||||
|
|
||||||
| Name | Description |
|
| Name | Description |
|
||||||
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `Name` | The data source name. This is how you refer to the data source in panels and queries. |
|
| `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. |
|
| `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`. |
|
| `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. |
|
| `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. |
|
| `Basic Auth` | Enable basic authentication to the Prometheus data source. |
|
||||||
| `User` | User name for basic authentication. |
|
| `User` | User name for basic authentication. |
|
||||||
| `Password` | Password for basic authentication. |
|
| `Password` | Password for basic authentication. |
|
||||||
| `Manage alerts via Alerting UI` | Toggle whether to enable Alertmanager integration for this data source. |
|
| `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. |
|
| `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. |
|
| `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. |
|
| `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. |
|
| `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. |
|
| `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 '&'. |
|
| `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** | |
|
| **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. |
|
| `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. |
|
| `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` | _(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. |
|
| `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. |
|
| `Label name` | Adds a name for the exemplar traceID property. |
|
||||||
|
|
||||||
### Provision the data source
|
### Provision the data source
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import { IconName } from '../../types';
|
|||||||
import { Icon } from '../Icon/Icon';
|
import { Icon } from '../Icon/Icon';
|
||||||
import { Tooltip } from '../Tooltip/Tooltip';
|
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<HTMLDivElement> {
|
export interface BadgeProps extends HTMLAttributes<HTMLDivElement> {
|
||||||
text: React.ReactNode;
|
text: React.ReactNode;
|
||||||
|
@ -77,4 +77,15 @@ export const PromFlavorVersions: { [index: string]: Array<{ value?: string; labe
|
|||||||
{ value: '1.13.0', label: '1.13.x' },
|
{ value: '1.13.0', label: '1.13.x' },
|
||||||
{ value: '1.14.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' },
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
@ -56,6 +56,7 @@ const prometheusFlavorSelectItems: PrometheusSelectItemsType = [
|
|||||||
{ value: PromApplication.Cortex, label: PromApplication.Cortex },
|
{ value: PromApplication.Cortex, label: PromApplication.Cortex },
|
||||||
{ value: PromApplication.Mimir, label: PromApplication.Mimir },
|
{ value: PromApplication.Mimir, label: PromApplication.Mimir },
|
||||||
{ value: PromApplication.Thanos, label: PromApplication.Thanos },
|
{ value: PromApplication.Thanos, label: PromApplication.Thanos },
|
||||||
|
{ value: PromApplication.VictoriaMetrics, label: PromApplication.VictoriaMetrics },
|
||||||
];
|
];
|
||||||
|
|
||||||
type Props = Pick<DataSourcePluginOptionsEditorProps<PromOptions>, 'options' | 'onOptionsChange'>;
|
type Props = Pick<DataSourcePluginOptionsEditorProps<PromOptions>, '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
|
// This will save the current state of the form, as the url is needed for this API call to function
|
||||||
onUpdate(options)
|
onUpdate(options)
|
||||||
.then((updatedOptions) => {
|
.then((updatedOptions) => {
|
||||||
getBackendSrv()
|
// Not seeing version info in buildinfo response from VictoriaMetrics, and Cortex doesn't support yet, users will need to manually select version
|
||||||
.get(`/api/datasources/uid/${updatedOptions.uid}/resources/version-detect`)
|
if (
|
||||||
.then((rawResponse: PromBuildInfoResponse) => {
|
updatedOptions.jsonData.prometheusType !== PromApplication.VictoriaMetrics &&
|
||||||
const rawVersionStringFromApi = rawResponse.data?.version ?? '';
|
updatedOptions.jsonData.prometheusType !== PromApplication.Cortex
|
||||||
if (rawVersionStringFromApi && semver.valid(rawVersionStringFromApi)) {
|
) {
|
||||||
const parsedVersion = getVersionString(rawVersionStringFromApi, updatedOptions.jsonData.prometheusType);
|
getBackendSrv()
|
||||||
// If we got a successful response, let's update the backend with the version right away if it's new
|
.get(`/api/datasources/uid/${updatedOptions.uid}/resources/version-detect`)
|
||||||
if (parsedVersion) {
|
.then((rawResponse: PromBuildInfoResponse) => {
|
||||||
onUpdate({
|
const rawVersionStringFromApi = rawResponse.data?.version ?? '';
|
||||||
...updatedOptions,
|
if (rawVersionStringFromApi && semver.valid(rawVersionStringFromApi)) {
|
||||||
jsonData: {
|
const parsedVersion = getVersionString(rawVersionStringFromApi, updatedOptions.jsonData.prometheusType);
|
||||||
...updatedOptions.jsonData,
|
// If we got a successful response, let's update the backend with the version right away if it's new
|
||||||
prometheusVersion: parsedVersion,
|
if (parsedVersion) {
|
||||||
},
|
onUpdate({
|
||||||
}).then((updatedUpdatedOptions) => {
|
...updatedOptions,
|
||||||
onOptionsChange(updatedUpdatedOptions);
|
jsonData: {
|
||||||
});
|
...updatedOptions.jsonData,
|
||||||
|
prometheusVersion: parsedVersion,
|
||||||
|
},
|
||||||
|
}).then((updatedUpdatedOptions) => {
|
||||||
|
onOptionsChange(updatedUpdatedOptions);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unableToDeterminePrometheusVersion();
|
||||||
}
|
}
|
||||||
} else {
|
})
|
||||||
unableToDeterminePrometheusVersion();
|
.catch(unableToDeterminePrometheusVersion);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch(unableToDeterminePrometheusVersion);
|
||||||
unableToDeterminePrometheusVersion(error);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PromSettings = (props: Props) => {
|
export const PromSettings = (props: Props) => {
|
||||||
|
@ -173,6 +173,8 @@ export class PrometheusDatasource
|
|||||||
this._isDatasourceVersionGreaterOrEqualTo('2.0.0', PromApplication.Mimir) ||
|
this._isDatasourceVersionGreaterOrEqualTo('2.0.0', PromApplication.Mimir) ||
|
||||||
// https://github.com/cortexproject/cortex/discussions/4542
|
// https://github.com/cortexproject/cortex/discussions/4542
|
||||||
this._isDatasourceVersionGreaterOrEqualTo('1.11.0', PromApplication.Cortex) ||
|
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/pull/3566
|
||||||
//https://github.com/thanos-io/thanos/releases/tag/v0.18.0
|
//https://github.com/thanos-io/thanos/releases/tag/v0.18.0
|
||||||
this._isDatasourceVersionGreaterOrEqualTo('0.18.0', PromApplication.Thanos)
|
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.Mimir]: '/public/app/plugins/datasource/prometheus/img/mimir_logo.svg',
|
||||||
[PromApplication.Prometheus]: '/public/app/plugins/datasource/prometheus/img/prometheus_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.Thanos]: '/public/app/plugins/datasource/prometheus/img/thanos_logo.svg',
|
||||||
|
[PromApplication.VictoriaMetrics]: '/public/app/plugins/datasource/prometheus/img/vm_logo.svg',
|
||||||
};
|
};
|
||||||
|
|
||||||
const COLORS: Record<PromApplication, BadgeColor> = {
|
const COLORS: Record<PromApplication, BadgeColor> = {
|
||||||
@ -999,6 +1002,7 @@ export class PrometheusDatasource
|
|||||||
[PromApplication.Mimir]: 'orange',
|
[PromApplication.Mimir]: 'orange',
|
||||||
[PromApplication.Prometheus]: 'red',
|
[PromApplication.Prometheus]: 'red',
|
||||||
[PromApplication.Thanos]: 'purple', // Purple hex taken from thanos.io
|
[PromApplication.Thanos]: 'purple', // Purple hex taken from thanos.io
|
||||||
|
[PromApplication.VictoriaMetrics]: 'black',
|
||||||
};
|
};
|
||||||
|
|
||||||
const AppDisplayNames: Record<PromApplication, string> = {
|
const AppDisplayNames: Record<PromApplication, string> = {
|
||||||
@ -1006,6 +1010,7 @@ export class PrometheusDatasource
|
|||||||
[PromApplication.Mimir]: 'Mimir',
|
[PromApplication.Mimir]: 'Mimir',
|
||||||
[PromApplication.Prometheus]: 'Prometheus',
|
[PromApplication.Prometheus]: 'Prometheus',
|
||||||
[PromApplication.Thanos]: 'Thanos',
|
[PromApplication.Thanos]: 'Thanos',
|
||||||
|
[PromApplication.VictoriaMetrics]: 'VictoriaMetrics',
|
||||||
};
|
};
|
||||||
|
|
||||||
const application = this.datasourceConfigurationPrometheusFlavor ?? buildInfo.application;
|
const application = this.datasourceConfigurationPrometheusFlavor ?? buildInfo.application;
|
||||||
|
BIN
public/app/plugins/datasource/prometheus/img/vm_logo.png
Normal file
BIN
public/app/plugins/datasource/prometheus/img/vm_logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
@ -64,6 +64,7 @@ export enum PromApplication {
|
|||||||
Mimir = 'Mimir',
|
Mimir = 'Mimir',
|
||||||
Prometheus = 'Prometheus',
|
Prometheus = 'Prometheus',
|
||||||
Thanos = 'Thanos',
|
Thanos = 'Thanos',
|
||||||
|
VictoriaMetrics = 'VictoriaMetrics',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PromBuildInfoResponse {
|
export interface PromBuildInfoResponse {
|
||||||
|
Loading…
Reference in New Issue
Block a user