mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
AzureMonitor: Set timespan in Logs Portal URL link (#71841)
Set timespan in Logs Portal URL link
This commit is contained in:
parent
f75a3d04cf
commit
116e971af3
@ -357,7 +357,7 @@ func (e *AzureLogAnalyticsDatasource) executeQuery(ctx context.Context, logger l
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
queryUrl, err := getQueryUrl(query.Query, query.Resources, azurePortalBaseUrl)
|
queryUrl, err := getQueryUrl(query.Query, query.Resources, azurePortalBaseUrl, query.TimeRange)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dataResponse.Error = err
|
dataResponse.Error = err
|
||||||
return dataResponse
|
return dataResponse
|
||||||
@ -493,7 +493,7 @@ type AzureLogAnalyticsURLResource struct {
|
|||||||
ResourceID string `json:"resourceId"`
|
ResourceID string `json:"resourceId"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func getQueryUrl(query string, resources []string, azurePortalUrl string) (string, error) {
|
func getQueryUrl(query string, resources []string, azurePortalUrl string, timeRange backend.TimeRange) (string, error) {
|
||||||
encodedQuery, err := encodeQuery(query)
|
encodedQuery, err := encodeQuery(query)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to encode the query: %s", err)
|
return "", fmt.Errorf("failed to encode the query: %s", err)
|
||||||
@ -517,8 +517,11 @@ func getQueryUrl(query string, resources []string, azurePortalUrl string) (strin
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to marshal log analytics resources: %s", err)
|
return "", fmt.Errorf("failed to marshal log analytics resources: %s", err)
|
||||||
}
|
}
|
||||||
|
from := timeRange.From.Format(time.RFC3339)
|
||||||
|
to := timeRange.To.Format(time.RFC3339)
|
||||||
|
timespan := url.QueryEscape(fmt.Sprintf("%s/%s", from, to))
|
||||||
portalUrl += url.QueryEscape(string(resourcesMarshalled))
|
portalUrl += url.QueryEscape(string(resourcesMarshalled))
|
||||||
portalUrl += "/query/" + url.PathEscape(encodedQuery) + "/isQueryBase64Compressed/true/timespanInIsoFormat/P1D"
|
portalUrl += "/query/" + url.PathEscape(encodedQuery) + "/isQueryBase64Compressed/true/timespan/" + timespan
|
||||||
return portalUrl, nil
|
return portalUrl, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user