diff --git a/internal/notifier/grafana.go b/internal/notifier/grafana.go index 899c97d5d..7753f8a21 100644 --- a/internal/notifier/grafana.go +++ b/internal/notifier/grafana.go @@ -73,6 +73,8 @@ func (g *Grafana) Post(ctx context.Context, event events.Event) error { for k, v := range event.Metadata { sfields = append(sfields, fmt.Sprintf("%s: %s", k, v)) } + sfields = append(sfields, fmt.Sprintf("name: %s", event.InvolvedObject.Name)) + sfields = append(sfields, fmt.Sprintf("namespace: %s", event.InvolvedObject.Namespace)) payload := GraphitePayload{ When: event.Timestamp.Unix(), Text: fmt.Sprintf("%s/%s.%s", strings.ToLower(event.InvolvedObject.Kind), event.InvolvedObject.Name, event.InvolvedObject.Namespace), diff --git a/internal/notifier/grafana_test.go b/internal/notifier/grafana_test.go index 6675cd907..37df5c680 100644 --- a/internal/notifier/grafana_test.go +++ b/internal/notifier/grafana_test.go @@ -41,6 +41,8 @@ func TestGrafana_Post(t *testing.T) { require.Equal(t, "flux", payload.Tags[0]) require.Equal(t, "source-controller", payload.Tags[1]) require.Equal(t, "test: metadata", payload.Tags[2]) + require.Equal(t, "name: webapp", payload.Tags[3]) + require.Equal(t, "namespace: gitops-system", payload.Tags[4]) })) defer ts.Close()