Prometheus: Add support for cloud partners Prometheus data sources (#103482)
* wip * Add prom flavor support for data source variables and export/import dashboards (#103321) * add dashboard and data source var selection * use match plugin id instead * use updated matchpluginid * formatting * cleanup * regex anchor * update error msg * Alerting: Clean up prometheus-flavored types and functions (#103703) * clean up types and utility functions for dealing with prometheus-flavored data sources * Refactor alerting datasource types to use constants as source of truth * Alerting: Clean up prometheus-flavored types and functions on the bac… (#103716) Alerting: Clean up prometheus-flavored types and functions on the backend * add matchPluginId tests * Update matchPluginId func to bidirectional (#103746) * update matchpluginid func to bidirectional * lint * formatting * use actual isSupportedExternalRulesSourceType in test * add tests in datasource_srv * betterer * remove type assertion * remove unnecessary case * use satisifies to not have to convert tuple to an array of string * add prometheus_flavor test --------- Co-authored-by: Andrew Hackmann <5140848+bossinc@users.noreply.github.com> Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com> Co-authored-by: Alexander Akhmetov <me@alx.cx>
This commit is contained in:
co-authored by
Andrew Hackmann
Gilles De Mey
Alexander Akhmetov
parent
22a9e1b5ff
commit
fd6fd91115
@@ -11,27 +11,29 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
DS_ACCESS_DIRECT = "direct"
|
||||
DS_ACCESS_PROXY = "proxy"
|
||||
DS_ALERTMANAGER = "alertmanager"
|
||||
DS_AZURE_MONITOR = "grafana-azure-monitor-datasource"
|
||||
DS_DYNATRACE = "grafana-dynatrace-datasource"
|
||||
DS_ES = "elasticsearch"
|
||||
DS_ES_OPEN_DISTRO = "grafana-es-open-distro-datasource"
|
||||
DS_ES_OPENSEARCH = "grafana-opensearch-datasource"
|
||||
DS_GRAPHITE = "graphite"
|
||||
DS_INFLUXDB = "influxdb"
|
||||
DS_INFLUXDB_08 = "influxdb_08"
|
||||
DS_JAEGER = "jaeger"
|
||||
DS_LOKI = "loki"
|
||||
DS_MSSQL = "mssql"
|
||||
DS_MYSQL = "mysql"
|
||||
DS_OPENTSDB = "opentsdb"
|
||||
DS_POSTGRES = "grafana-postgresql-datasource"
|
||||
DS_PROMETHEUS = "prometheus"
|
||||
DS_TEMPO = "tempo"
|
||||
DS_TESTDATA = "grafana-testdata-datasource"
|
||||
DS_ZIPKIN = "zipkin"
|
||||
DS_ACCESS_DIRECT = "direct"
|
||||
DS_ACCESS_PROXY = "proxy"
|
||||
DS_ALERTMANAGER = "alertmanager"
|
||||
DS_AZURE_MONITOR = "grafana-azure-monitor-datasource"
|
||||
DS_DYNATRACE = "grafana-dynatrace-datasource"
|
||||
DS_ES = "elasticsearch"
|
||||
DS_ES_OPEN_DISTRO = "grafana-es-open-distro-datasource"
|
||||
DS_ES_OPENSEARCH = "grafana-opensearch-datasource"
|
||||
DS_GRAPHITE = "graphite"
|
||||
DS_INFLUXDB = "influxdb"
|
||||
DS_INFLUXDB_08 = "influxdb_08"
|
||||
DS_JAEGER = "jaeger"
|
||||
DS_LOKI = "loki"
|
||||
DS_MSSQL = "mssql"
|
||||
DS_MYSQL = "mysql"
|
||||
DS_OPENTSDB = "opentsdb"
|
||||
DS_POSTGRES = "grafana-postgresql-datasource"
|
||||
DS_PROMETHEUS = "prometheus"
|
||||
DS_AMAZON_PROMETHEUS = "grafana-amazonprometheus-datasource"
|
||||
DS_AZURE_PROMETHEUS = "grafana-azureprometheus-datasource"
|
||||
DS_TEMPO = "tempo"
|
||||
DS_TESTDATA = "grafana-testdata-datasource"
|
||||
DS_ZIPKIN = "zipkin"
|
||||
// CustomHeaderName is the prefix that is used to store the name of a custom header.
|
||||
CustomHeaderName = "httpHeaderName"
|
||||
// CustomHeaderValue is the prefix that is used to store the value of a custom header.
|
||||
|
||||
@@ -922,7 +922,7 @@ func awsServiceNamespace(dsType string, jsonData *simplejson.Json) string {
|
||||
} else {
|
||||
return "es"
|
||||
}
|
||||
case datasources.DS_PROMETHEUS, datasources.DS_ALERTMANAGER:
|
||||
case datasources.DS_PROMETHEUS, datasources.DS_AMAZON_PROMETHEUS, datasources.DS_ALERTMANAGER:
|
||||
return "aps"
|
||||
default:
|
||||
panic(fmt.Sprintf("Unsupported datasource %q", dsType))
|
||||
|
||||
@@ -1000,6 +1000,11 @@ func TestService_awsServiceNamespace(t *testing.T) {
|
||||
givenDs: datasources.DS_PROMETHEUS,
|
||||
givenJson: `{ "sigV4Auth": true, "serverless": true }`,
|
||||
want: "aps",
|
||||
}, {
|
||||
desc: "amazon prometheus",
|
||||
givenDs: datasources.DS_AMAZON_PROMETHEUS,
|
||||
givenJson: `{ "sigV4Auth": true }`,
|
||||
want: "aps",
|
||||
}, {
|
||||
desc: "alertmanager",
|
||||
givenDs: datasources.DS_ALERTMANAGER,
|
||||
@@ -1011,6 +1016,12 @@ func TestService_awsServiceNamespace(t *testing.T) {
|
||||
givenJson: `{ "sigV4Auth": true, "serverless": true }`,
|
||||
want: "aps",
|
||||
panic: true,
|
||||
}, {
|
||||
desc: "azure prometheus",
|
||||
givenDs: datasources.DS_AZURE_PROMETHEUS,
|
||||
givenJson: `{ "sigV4Auth": true }`,
|
||||
want: "aps",
|
||||
panic: true,
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
|
||||
Reference in New Issue
Block a user