Skip to content

Error creating panels with alerts #215

Description

@DavidTan0527

When trying to create panels with alerts, Client.SetDashboard returns
HTTP error 422: returns alert validation error: Panel id is not correct...

Below is how I created the Alert, I have filled in all the fields available.

	resultAlert := sdk.Alert{
		AlertRuleTags:       map[string]string{},
		Conditions:          []sdk.AlertCondition{alertCondition},
		ExecutionErrorState: panel.ExecutionErrorState,
		Frequency:           DefaultAlert.Frequency,
		Handler:             1,
		Name:                alertName,
		NoDataState:         panel.NoDataState,
		Notifications:       []sdk.AlertNotification{alertNotification},
		Message:             panel.AlertMessage,
		For:                 panel.ForDuration,
	}

Let me know if you require details regarding each of the variables.

I found this line in Grafana: https://github.com/grafana/grafana/blob/0124dc8e6b0fb6cd881bb51c98391f2efe203b78/pkg/models/alert.go#L93
Through some testing, I found that adding a PanelID field to Alert in panel.go, then assigning a value to it fixes the problem.

May I know if this is indeed what should be added to the Alert struct or am I using it wrong?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions