mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
AzureMonitor: Set Logs portal URL from resource URI (#60583)
Set URL based off of resource URI
This commit is contained in:
@@ -202,8 +202,7 @@ func (e *AzureLogAnalyticsDatasource) executeQuery(ctx context.Context, logger l
|
||||
|
||||
err = setAdditionalFrameMeta(frame,
|
||||
query.Params.Get("query"),
|
||||
model.Get("subscriptionId").MustString(),
|
||||
model.Get("azureLogAnalytics").Get("workspace").MustString())
|
||||
model.Get("azureLogAnalytics").Get("resource").MustString())
|
||||
if err != nil {
|
||||
frame.AppendNotices(data.Notice{Severity: data.NoticeSeverityWarning, Text: "could not add custom metadata: " + err.Error()})
|
||||
logger.Warn("failed to add custom metadata to azure log analytics response", err)
|
||||
@@ -317,12 +316,11 @@ func (e *AzureLogAnalyticsDatasource) unmarshalResponse(logger log.Logger, res *
|
||||
// LogAnalyticsMeta is a type for the a Frame's Meta's Custom property.
|
||||
type LogAnalyticsMeta struct {
|
||||
ColumnTypes []string `json:"azureColumnTypes"`
|
||||
Subscription string `json:"subscription"`
|
||||
Workspace string `json:"workspace"`
|
||||
EncodedQuery []byte `json:"encodedQuery"` // EncodedQuery is used for deep links.
|
||||
Resource string `json:"resource"`
|
||||
}
|
||||
|
||||
func setAdditionalFrameMeta(frame *data.Frame, query, subscriptionID, workspace string) error {
|
||||
func setAdditionalFrameMeta(frame *data.Frame, query, resource string) error {
|
||||
if frame.Meta == nil || frame.Meta.Custom == nil {
|
||||
// empty response
|
||||
return nil
|
||||
@@ -332,8 +330,7 @@ func setAdditionalFrameMeta(frame *data.Frame, query, subscriptionID, workspace
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type found for frame's custom metadata")
|
||||
}
|
||||
la.Subscription = subscriptionID
|
||||
la.Workspace = workspace
|
||||
la.Resource = resource
|
||||
encodedQuery, err := encodeQuery(query)
|
||||
if err == nil {
|
||||
la.EncodedQuery = encodedQuery
|
||||
|
||||
@@ -247,7 +247,7 @@ func Test_executeQueryErrorWithDifferentLogAnalyticsCreds(t *testing.T) {
|
||||
func Test_setAdditionalFrameMeta(t *testing.T) {
|
||||
t.Run("it should not error with an empty response", func(t *testing.T) {
|
||||
frame := data.NewFrame("test")
|
||||
err := setAdditionalFrameMeta(frame, "", "", "")
|
||||
err := setAdditionalFrameMeta(frame, "", "")
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user