Grafana Advisor: Add links to suggested actions (#99764)

Grafana Advisor: Add links to proposed actions
pull/99807/head
Andres Martinez Gotor 5 months ago committed by GitHub
parent f637ea225a
commit 1e3783cc11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      apps/advisor/pkg/app/checks/datasourcecheck/check.go
  2. 4
      apps/advisor/pkg/app/checks/datasourcecheck/check_test.go
  3. 8
      apps/advisor/pkg/app/checks/plugincheck/check.go
  4. 10
      apps/advisor/pkg/app/checks/plugincheck/check_test.go

@ -56,8 +56,8 @@ func (c *check) Run(ctx context.Context, obj *advisor.CheckSpec) (*advisor.Check
if err != nil {
dsErrs = append(dsErrs, advisor.CheckV0alpha1StatusReportErrors{
Severity: advisor.CheckStatusSeverityLow,
Reason: fmt.Sprintf("Invalid UID: %s", ds.UID),
Action: "Change UID",
Reason: fmt.Sprintf("Invalid UID '%s' for data source %s", ds.UID, ds.Name),
Action: "Check the <a href='https://grafana.com/docs/grafana/latest/upgrade-guide/upgrade-v11.2/#grafana-data-source-uid-format-enforcement' target=_blank>documentation</a> for more information.",
})
}
@ -83,8 +83,10 @@ func (c *check) Run(ctx context.Context, obj *advisor.CheckSpec) (*advisor.Check
if resp.Status != backend.HealthStatusOk {
dsErrs = append(dsErrs, advisor.CheckV0alpha1StatusReportErrors{
Severity: advisor.CheckStatusSeverityHigh,
Reason: fmt.Sprintf("Health check failed: %s", ds.Name),
Action: "Check datasource",
Reason: fmt.Sprintf("Health check failed for %s", ds.Name),
Action: fmt.Sprintf(
"Go to the <a href='/connections/datasources/edit/%s'>data source configuration</a>"+
" and address the issues reported.", ds.UID),
})
}
}

@ -56,7 +56,7 @@ func TestCheck_Run(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, int64(1), report.Count)
assert.Len(t, report.Errors, 1)
assert.Equal(t, "Invalid UID: invalid uid", report.Errors[0].Reason)
assert.Equal(t, "Invalid UID 'invalid uid' for data source Prometheus", report.Errors[0].Reason)
})
t.Run("should return errors when datasource health check fails", func(t *testing.T) {
@ -79,7 +79,7 @@ func TestCheck_Run(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, int64(1), report.Count)
assert.Len(t, report.Errors, 1)
assert.Equal(t, "Health check failed: Prometheus", report.Errors[0].Reason)
assert.Equal(t, "Health check failed for Prometheus", report.Errors[0].Reason)
})
}

@ -59,7 +59,7 @@ func (c *check) Run(ctx context.Context, _ *advisor.CheckSpec) (*advisor.CheckV0
errs = append(errs, advisor.CheckV0alpha1StatusReportErrors{
Severity: advisor.CheckStatusSeverityHigh,
Reason: fmt.Sprintf("Plugin deprecated: %s", p.ID),
Action: "Look for alternatives",
Action: "Check the <a href='https://grafana.com/legal/plugin-deprecation/#a-plugin-i-use-is-deprecated-what-should-i-do' target=_blank>documentation</a> for recommended steps.",
})
}
@ -75,8 +75,10 @@ func (c *check) Run(ctx context.Context, _ *advisor.CheckSpec) (*advisor.CheckV0
if hasUpdate(p, info) {
errs = append(errs, advisor.CheckV0alpha1StatusReportErrors{
Severity: advisor.CheckStatusSeverityLow,
Reason: fmt.Sprintf("New version available: %s", p.ID),
Action: "Update plugin",
Reason: fmt.Sprintf("New version available for %s", p.ID),
Action: fmt.Sprintf(
"Go to the <a href='/plugins/%s?page=version-history'>plugin admin page</a>"+
" and upgrade to the latest version.", p.ID),
})
}
}

@ -43,7 +43,7 @@ func TestRun(t *testing.T) {
{
Severity: advisor.CheckStatusSeverityHigh,
Reason: "Plugin deprecated: plugin1",
Action: "Look for alternatives",
Action: "Check the <a href='https://grafana.com/legal/plugin-deprecation/#a-plugin-i-use-is-deprecated-what-should-i-do' target=_blank>documentation</a> for recommended steps.",
},
},
},
@ -61,8 +61,8 @@ func TestRun(t *testing.T) {
expectedErrors: []advisor.CheckV0alpha1StatusReportErrors{
{
Severity: advisor.CheckStatusSeverityLow,
Reason: "New version available: plugin2",
Action: "Update plugin",
Reason: "New version available for plugin2",
Action: "Go to the <a href='/plugins/plugin2?page=version-history'>plugin admin page</a> and upgrade to the latest version.",
},
},
},
@ -80,8 +80,8 @@ func TestRun(t *testing.T) {
expectedErrors: []advisor.CheckV0alpha1StatusReportErrors{
{
Severity: advisor.CheckStatusSeverityLow,
Reason: "New version available: plugin2",
Action: "Update plugin",
Reason: "New version available for plugin2",
Action: "Go to the <a href='/plugins/plugin2?page=version-history'>plugin admin page</a> and upgrade to the latest version.",
},
},
},

Loading…
Cancel
Save