diff --git a/.nais/alerting-dolly.yml b/.nais/alerting-dolly.yml index d5d026258a9..9257397ab68 100644 --- a/.nais/alerting-dolly.yml +++ b/.nais/alerting-dolly.yml @@ -6,6 +6,10 @@ metadata: labels: team: dolly spec: + receivers: + slack: + channel: "#dolly-alerts" + icon_emoji: ':dolly-panic:' groups: - name: dolly-alerts rules: @@ -14,53 +18,49 @@ spec: expr: 'kube_deployment_status_replicas_available{namespace = "dolly"} == 0' for: 5m annotations: - summary: 'Applikasjonen *{{ $labels.deployment }}* har hatt 0 replicas i >5min og er ikke tilgjengelig.' + summary: 'Applikasjonen {{ $labels.deployment }} har hatt 0 replicas i >5min og er ikke tilgjengelig.' action: | - Alertmanager: - Events: `kubectl describe pod -l app={{ $labels.deployment }}` - Logger: `kubectl logs -l app={{ $labels.deployment }}` - labels: - namespace: 'dolly' - severity: 'critical' + 'Events: `kubectl describe pod -l app={{ $labels.deployment }}`\n + Logger: `kubectl logs -l app={{ $labels.deployment }}`' + + - action: 'action' + alert: 'dolly-log-errors-test' + description: 'description' + documentation: 'https://www.nav.no' + expr: sum by (app) (increase(log_messages_errors{namespace="dolly",level="Error"}[15m] offset 30m) > 1) + for: 1m + severity: 'danger' + sla: 'sla'' + annotations: + summary: 'En applikasjon har hatt mer enn 1 ERRORs i loggen i løpet av de siste 15 minuttene.' + - alert: 'dolly-log-errors' - expr: 'sum by (app,namespace) (increase(log_messages_errors{namespace="dolly",level="Error"}[15m]) > 1)' + expr: 'sum by (app) (increase(log_messages_errors{namespace="dolly",level="Error"}[15m]) > 1)' for: 1m annotations: - summary: 'Applikasjonen *{{ $labels.app }}* har hatt mer enn 1 ERRORs i loggen i løpet av de siste 15 minuttene.' + summary: 'Applikasjonen {{ $labels.app }} har hatt mer enn 1 ERRORs i loggen i løpet av de siste 15 minuttene.' action: | - Alertmanager: - Events: `kubectl describe pod -l app={{ $labels.app }}` - Logger: `kubectl logs -l app={{ $labels.app }}` - Kibana: - labels: - namespace: 'dolly' - severity: 'warning' + 'Events: `kubectl describe pod -l app={{ $labels.app }}`\n + Logger: `kubectl logs -l app={{ $labels.app }}`\n + Kibana: ``' - alert: 'dolly-server-http-5xx' - expr: 'sum by (app,namespace) (increase(http_server_requests_seconds_count{namespace="dolly",status=~"^5.."}[15m]) > 5)' + expr: 'sum by (app) (increase(http_server_requests_seconds_count{namespace="dolly",status=~"^5.."}[15m]) > 5)' for: 1m annotations: - summary: 'Applikasjonen *{{ $labels.app }}* har gitt mer enn 5 HTTP 5xx-responser i løpet av de siste 15 minuttene.' + summary: 'Applikasjonen {{ $labels.app }} har gitt mer enn 5 HTTP 5xx-responser i løpet av de siste 15 minuttene.' action: | - Alertmanager: - Events: `kubectl describe pod -l app={{ $labels.app }}` - Logger: `kubectl logs -l app={{ $labels.app }}` - Kibana: - labels: - namespace: 'dolly' - severity: 'warning' + 'Events: `kubectl describe pod -l app={{ $labels.app }}`\n + Logger: `kubectl logs -l app={{ $labels.app }}`\n + Kibana: ``' - alert: 'dolly-client-http-4xx' - expr: 'sum by (app,namespace) (increase(http_client_requests_seconds_count{namespace="dolly",status=~"^4.."}[15m]) > 5)' + expr: 'sum by (app) (increase(http_client_requests_seconds_count{namespace="dolly",http_status_code=~"^4.."}[15m]) > 5)' for: 1m annotations: - summary: 'Applikasjonen *{{ $labels.app }}* har fått mer enn 5 HTTP 4xx-responser i løpet av de siste 15 minuttene.' + summary: 'Applikasjonen {{ $labels.app }} har fått mer enn 5 HTTP 4xx-responser i løpet av de siste 15 minuttene.' action: | - Alertmanager: - Events: `kubectl describe pod -l app={{ $labels.app }}` - Logger: `kubectl logs -l app={{ $labels.app }}` - Kibana: - labels: - namespace: 'dolly' - severity: 'warning' + 'Events: `kubectl describe pod -l app={{ $labels.app }}`\n + Logger: `kubectl logs -l app={{ $labels.app }}`\n + Kibana: ``' diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/domain/jpa/BestillingMal.java b/apps/dolly-backend/src/main/java/no/nav/dolly/domain/jpa/BestillingMal.java index 8341288aa0d..61fb545a0fa 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/domain/jpa/BestillingMal.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/domain/jpa/BestillingMal.java @@ -45,7 +45,7 @@ public class BestillingMal implements Serializable { private String malNavn; @ManyToOne - @JoinColumn(name = "bruker_id") + @JoinColumn(name = "BRUKER_ID") private Bruker bruker; @Column(name = "SIST_OPPDATERT", nullable = false) diff --git a/apps/dolly-backend/src/main/java/no/nav/dolly/repository/BrukerRepository.java b/apps/dolly-backend/src/main/java/no/nav/dolly/repository/BrukerRepository.java index 3d878b3346e..8154ecd97dd 100644 --- a/apps/dolly-backend/src/main/java/no/nav/dolly/repository/BrukerRepository.java +++ b/apps/dolly-backend/src/main/java/no/nav/dolly/repository/BrukerRepository.java @@ -1,15 +1,15 @@ package no.nav.dolly.repository; import no.nav.dolly.domain.jpa.Bruker; -import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.Repository; import org.springframework.data.repository.query.Param; import java.util.List; import java.util.Optional; -public interface BrukerRepository extends JpaRepository { +public interface BrukerRepository extends Repository { void deleteByBrukerId(String brukerId); Bruker save(Bruker bruker); diff --git a/apps/dolly-backend/src/test/java/no/nav/dolly/service/BestillingMalServiceTest.java b/apps/dolly-backend/src/test/java/no/nav/dolly/service/BestillingMalServiceTest.java index ccafd6279b4..456e7747d66 100644 --- a/apps/dolly-backend/src/test/java/no/nav/dolly/service/BestillingMalServiceTest.java +++ b/apps/dolly-backend/src/test/java/no/nav/dolly/service/BestillingMalServiceTest.java @@ -222,8 +222,8 @@ void saveDummyBruker(Bruker bruker) { void deleteAllDatabaseContent() { bestillingMalRepository.deleteAll(); - bestillingRepository.deleteAll(); identRepository.deleteAll(); + bestillingRepository.deleteAll(); brukerFavoritterRepository.deleteAll(); testgruppeRepository.findAll(Sort.unsorted()).forEach(gruppe -> testgruppeRepository.deleteTestgruppeById(gruppe.getId())); brukerRepository.deleteByBrukerId(DUMMY_EN.getBrukerId());