Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error creating panels with alerts #215

Open
DavidTan0527 opened this issue Jun 28, 2022 · 0 comments
Open

Error creating panels with alerts #215

DavidTan0527 opened this issue Jun 28, 2022 · 0 comments

Comments

@DavidTan0527
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant