keikoproj / alert-manager

alert-manager provides CRD implementation for wavefront alerts, splunk alerts etc.,
10 stars 10 forks source link

updating with timestamp and alert version/generation #35

Closed mnkg561 closed 3 years ago

mnkg561 commented 3 years ago

Signed-off-by: mnkg561 mnkg561@gmail.com

close https://github.com/keikoproj/alert-manager/issues/33

Could you share the solution in high level?

  1. Added LastUpdatedTimestamp in the AlertStatus struct for the time
  2. Added Generation field as part of AssociatedAlertConfig

Could you share the test results?

Sample Response:

intuitdepb18a8:kubernetes nmogulla$ k get wfalerts wavefrontalert-sample4 -o yaml
apiVersion: alertmanager.keikoproj.io/v1alpha1
kind: WavefrontAlert
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"alertmanager.keikoproj.io/v1alpha1","kind":"WavefrontAlert","metadata":{"annotations":{},"name":"wavefrontalert-sample4","namespace":"alert-manager-system"},"spec":{"alertName":"test-alert-sample4","alertType":"CLASSIC","condition":"ts({{ .foo}})","displayExpression":"ts({{ .zzz }})","exportedParams":["foo","bar","zzz"],"exportedParamsDefaultValues":{"bar":"warn","foo":"status.health","zzz":"status.health"},"minutes":50,"resolveAfterMinutes":5,"severity":"{{.bar}}","tags":["test-alert","something-weird"]}}
  creationTimestamp: "2021-09-10T06:02:39Z"
  finalizers:
  - wavefrontalert.finalizers.alertmanager.keikoproj.io
  generation: 3
  name: wavefrontalert-sample4
  namespace: alert-manager-system
  resourceVersion: "1404872"
  uid: 724ff8ef-02a6-41bd-a95a-941e492c1f83
spec:
  alertName: test-alert-sample4
  alertType: CLASSIC
  condition: ts({{ .foo}})
  displayExpression: ts({{ .zzz }})
  exportedParams:
  - foo
  - bar
  - zzz
  exportedParamsDefaultValues:
    bar: warn
    foo: status.health
    zzz: status.health
  minutes: 50
  resolveAfterMinutes: 5
  severity: '{{.bar}}'
  tags:
  - test-alert
  - something-weird
status:
  alertsStatus:
    alertsconfig-sample:
      alertName: test-alert-sample4
      associatedAlert:
        CR: wavefrontalert-sample4
        generation: 3
      associatedAlertsConfig:
        CR: alertsconfig-sample
      id: "1631254514086"
      lastChangeChecksum: 4c985b0d3523d0b4c2ad6e42a1d788ff
      lastUpdatedTimestamp: "2021-10-04T20:54:07Z"
      link: https://try.wavefront.com/alerts/1631254514086
      state: Ready
  exportParamsChecksum: fff4342a6b1f427031199068ce4f0b2a
  lastChangeChecksum: 27904111c0356261f4ea4d46b49ae835
  observedGeneration: 3
  retryCount: 0
  state: Ready
intuitdepb18a8:kubernetes nmogulla$ 

AlertsConfig sample:

intuitdepb18a8:kubernetes nmogulla$ k get alertsconfig alertsconfig-sample -o yaml
apiVersion: alertmanager.keikoproj.io/v1alpha1
kind: AlertsConfig
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"alertmanager.keikoproj.io/v1alpha1","kind":"AlertsConfig","metadata":{"annotations":{},"name":"alertsconfig-sample","namespace":"alert-manager-system"},"spec":{"alerts":{"wavefrontalert-sample2":{"params":{"bar":"severe","foo":"status.health"}},"wavefrontalert-sample4":{"params":{"bar":"severe"}}},"globalGVK":{"group":"alertmanager.keikoproj.io","kind":"WavefrontAlert","version":"v1alpha1"}}}
  creationTimestamp: "2021-08-26T19:29:40Z"
  finalizers:
  - alertsconfig.finalizers.alertmanager.keikoproj.io
  generation: 21
  name: alertsconfig-sample
  namespace: alert-manager-system
  resourceVersion: "1404871"
  uid: 8c961aaf-49f2-49da-a25f-e21cf4223b24
spec:
  alerts:
    wavefrontalert-sample2:
      params:
        bar: severe
        foo: status.health
    wavefrontalert-sample4:
      params:
        bar: severe
  globalGVK:
    group: alertmanager.keikoproj.io
    kind: WavefrontAlert
    version: v1alpha1
status:
  alertsCount: 2
  alertsStatus:
    wavefrontalert-sample2:
      alertName: test-alert3
      associatedAlert:
        CR: wavefrontalert-sample2
      associatedAlertsConfig:
        CR: alertsconfig-sample
      id: "1631125175174"
      lastChangeChecksum: 19e06797d94da803a290e066d8910dcf
      link: https://try.wavefront.com/alerts/1631125175174
      state: Ready
    wavefrontalert-sample4:
      alertName: test-alert-sample4
      associatedAlert:
        CR: wavefrontalert-sample4
        generation: 3
      associatedAlertsConfig:
        CR: alertsconfig-sample
      id: "1631254514086"
      lastChangeChecksum: 4c985b0d3523d0b4c2ad6e42a1d788ff
      lastUpdatedTimestamp: "2021-10-04T20:54:07Z"
      link: https://try.wavefront.com/alerts/1631254514086
      state: Ready
  retryCount: 0
  state: Ready