Commit a6f2ae1f by sam Committed by GitHub

AzureMonitor: Fix Log Analytics and Application Insights for Azure China (#21803) (#22753)

Something funky going on with GitHub - the build has passed.
parent 59467d3c
...@@ -24,7 +24,23 @@ export default class AppInsightsDatasource { ...@@ -24,7 +24,23 @@ export default class AppInsightsDatasource {
constructor(instanceSettings: DataSourceInstanceSettings<AzureDataSourceJsonData>, private templateSrv: TemplateSrv) { constructor(instanceSettings: DataSourceInstanceSettings<AzureDataSourceJsonData>, private templateSrv: TemplateSrv) {
this.id = instanceSettings.id; this.id = instanceSettings.id;
this.applicationId = instanceSettings.jsonData.appInsightsAppId; this.applicationId = instanceSettings.jsonData.appInsightsAppId;
this.baseUrl = `/appinsights/${this.version}/apps/${this.applicationId}`;
switch (instanceSettings.jsonData.cloudName) {
// Azure US Government
case 'govazuremonitor':
break;
// Azure Germany
case 'germanyazuremonitor':
break;
// Azue China
case 'chinaazuremonitor':
this.baseUrl = `/chinaappinsights/${this.version}/apps/${this.applicationId}`;
break;
// Azure Global
default:
this.baseUrl = `/appinsights/${this.version}/apps/${this.applicationId}`;
}
this.url = instanceSettings.url; this.url = instanceSettings.url;
} }
......
...@@ -21,7 +21,20 @@ export default class AzureLogAnalyticsDatasource { ...@@ -21,7 +21,20 @@ export default class AzureLogAnalyticsDatasource {
private templateSrv: TemplateSrv private templateSrv: TemplateSrv
) { ) {
this.id = instanceSettings.id; this.id = instanceSettings.id;
this.baseUrl = '/loganalyticsazure';
switch (this.instanceSettings.jsonData.cloudName) {
case 'govazuremonitor': // Azure US Government
break;
case 'germanyazuremonitor': // Azure Germany
break;
case 'chinaazuremonitor': // Azue China
this.baseUrl = '/chinaloganalyticsazure';
break;
default:
// Azure Global
this.baseUrl = '/loganalyticsazure';
}
this.url = instanceSettings.url; this.url = instanceSettings.url;
this.defaultOrFirstWorkspace = this.instanceSettings.jsonData.logAnalyticsDefaultWorkspace; this.defaultOrFirstWorkspace = this.instanceSettings.jsonData.logAnalyticsDefaultWorkspace;
...@@ -43,7 +56,19 @@ export default class AzureLogAnalyticsDatasource { ...@@ -43,7 +56,19 @@ export default class AzureLogAnalyticsDatasource {
this.azureMonitorUrl = `/${azureCloud}/subscriptions`; this.azureMonitorUrl = `/${azureCloud}/subscriptions`;
} else { } else {
this.subscriptionId = this.instanceSettings.jsonData.logAnalyticsSubscriptionId; this.subscriptionId = this.instanceSettings.jsonData.logAnalyticsSubscriptionId;
this.azureMonitorUrl = `/workspacesloganalytics/subscriptions`;
switch (this.instanceSettings.jsonData.cloudName) {
case 'govazuremonitor': // Azure US Government
break;
case 'germanyazuremonitor': // Azure Germany
break;
case 'chinaazuremonitor': // Azue China
this.azureMonitorUrl = `/chinaworkspacesloganalytics/subscriptions`;
break;
default:
// Azure Global
this.azureMonitorUrl = `/workspacesloganalytics/subscriptions`;
}
} }
} }
......
...@@ -99,6 +99,15 @@ ...@@ -99,6 +99,15 @@
] ]
}, },
{ {
"path": "chinaappinsights",
"method": "GET",
"url": "https://api.applicationinsights.azure.cn",
"headers": [
{ "name": "X-API-Key", "content": "{{.SecureJsonData.appInsightsApiKey}}" },
{ "name": "x-ms-app", "content": "Grafana" }
]
},
{
"path": "workspacesloganalytics", "path": "workspacesloganalytics",
"method": "GET", "method": "GET",
"url": "https://management.azure.com", "url": "https://management.azure.com",
...@@ -114,6 +123,21 @@ ...@@ -114,6 +123,21 @@
"headers": [{ "name": "x-ms-app", "content": "Grafana" }] "headers": [{ "name": "x-ms-app", "content": "Grafana" }]
}, },
{ {
"path": "chinaworkspacesloganalytics",
"method": "GET",
"url": "https://management.chinacloudapi.cn",
"tokenAuth": {
"url": "https://login.chinacloudapi.cn/{{.JsonData.logAnalyticsTenantId}}/oauth2/token",
"params": {
"grant_type": "client_credentials",
"client_id": "{{.JsonData.logAnalyticsClientId}}",
"client_secret": "{{.SecureJsonData.logAnalyticsClientSecret}}",
"resource": "https://management.chinacloudapi.cn/"
}
},
"headers": [{ "name": "x-ms-app", "content": "Grafana" }]
},
{
"path": "loganalyticsazure", "path": "loganalyticsazure",
"method": "GET", "method": "GET",
"url": "https://api.loganalytics.io/v1/workspaces", "url": "https://api.loganalytics.io/v1/workspaces",
...@@ -131,6 +155,25 @@ ...@@ -131,6 +155,25 @@
{ "name": "Cache-Control", "content": "public, max-age=60" }, { "name": "Cache-Control", "content": "public, max-age=60" },
{ "name": "Accept-Encoding", "content": "gzip" } { "name": "Accept-Encoding", "content": "gzip" }
] ]
},
{
"path": "chinaloganalyticsazure",
"method": "GET",
"url": "https://api.loganalytics.azure.cn/v1/workspaces",
"tokenAuth": {
"url": "https://login.chinacloudapi.cn/{{.JsonData.logAnalyticsTenantId}}/oauth2/token",
"params": {
"grant_type": "client_credentials",
"client_id": "{{.JsonData.logAnalyticsClientId}}",
"client_secret": "{{.SecureJsonData.logAnalyticsClientSecret}}",
"resource": "https://api.loganalytics.azure.cn"
}
},
"headers": [
{ "name": "x-ms-app", "content": "Grafana" },
{ "name": "Cache-Control", "content": "public, max-age=60" },
{ "name": "Accept-Encoding", "content": "gzip" }
]
} }
], ],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment