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

feature. add & update default snr #337

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
997 changes: 721 additions & 276 deletions api/swagger/docs.go

Large diffs are not rendered by default.

997 changes: 721 additions & 276 deletions api/swagger/swagger.json

Large diffs are not rendered by default.

614 changes: 451 additions & 163 deletions api/swagger/swagger.yaml

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions internal/delivery/http/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,9 @@ func (h RoleHandler) Admin_GetTksRole(w http.ResponseWriter, r *http.Request) {
// @Summary Check whether the role name exists
// @Description Check whether the role name exists
// @Produce json
// @Param organizationId path string true "Organization ID"
// @Param roleName path string true "Role Name"
// @Success 200 {object} domain.CheckRoleNameResponse
// @Param organizationId path string true "Organization ID"
// @Param roleName path string true "Role Name"
// @Success 200 {object} domain.CheckRoleNameResponse
// @Router /organizations/{organizationId}/roles/{roleName}/existence [get]
// @Security JWT
func (h RoleHandler) IsRoleNameExisted(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -558,8 +558,8 @@ func (h RoleHandler) IsRoleNameExisted(w http.ResponseWriter, r *http.Request) {
// @Description Append Users To Role
// @Accept json
// @Produce json
// @Param organizationId path string true "Organization ID"
// @Param roleId path string true "Role ID"
// @Param organizationId path string true "Organization ID"
// @Param roleId path string true "Role ID"
// @Param body body domain.AppendUsersToRoleRequest true "Append Users To Role Request"
// @Success 200
// @Router /organizations/{organizationId}/roles/{roleId}/users [post]
Expand Down Expand Up @@ -621,8 +621,8 @@ func (h RoleHandler) AppendUsersToRole(w http.ResponseWriter, r *http.Request) {
// @Description Remove Users From Role
// @Accept json
// @Produce json
// @Param organizationId path string true "Organization ID"
// @Param roleId path string true "Role ID"
// @Param organizationId path string true "Organization ID"
// @Param roleId path string true "Role ID"
// @Param body body domain.RemoveUsersFromRoleRequest true "Remove Users From Role Request"
// @Success 200
// @Router /organizations/{organizationId}/roles/{roleId}/users [delete]
Expand Down Expand Up @@ -688,14 +688,14 @@ func (h RoleHandler) RemoveUsersFromRole(w http.ResponseWriter, r *http.Request)
// @Summary Get Users By Role ID
// @Description Get Users By Role ID
// @Produce json
// @Param organizationId path string true "Organization ID"
// @Param roleId path string true "Role ID"
// @Param organizationId path string true "Organization ID"
// @Param roleId path string true "Role ID"
// @Param pageSize query string false "pageSize"
// @Param pageNumber query string false "pageNumber"
// @Param soertColumn query string false "sortColumn"
// @Param sortOrder query string false "sortOrder"
// @Param filters query []string false "filters"
// @Success 200 {object} domain.GetUsersInRoleIdResponse
// @Success 200 {object} domain.GetUsersInRoleIdResponse
// @Router /organizations/{organizationId}/roles/{roleId}/users [get]
// @Security JWT
func (h RoleHandler) GetUsersInRoleId(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion internal/delivery/http/system-notification-rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ func (h *SystemNotificationRuleHandler) CheckSystemNotificationRuleName(w http.R
}
}

// [TEST]
/*
// [TEST]
err = h.usecase.MakeDefaultSystemNotificationRules(r.Context(), "oolw6roj6", nil)
if err != nil {
ErrorJSON(w, r, err)
Expand Down
10 changes: 5 additions & 5 deletions internal/delivery/http/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ func (u UserHandler) Update(w http.ResponseWriter, r *http.Request) {
// @Description Update multiple users
// @Accept json
// @Produce json
// @Param organizationId path string true "organizationId"
// @Param body body []domain.UpdateUsersRequest true "input"
// @Param organizationId path string true "organizationId"
// @Param body body []domain.UpdateUsersRequest true "input"
// @Success 200
// @Router /organizations/{organizationId}/users [put]
// @Security JWT
Expand Down Expand Up @@ -932,9 +932,9 @@ func (u UserHandler) Admin_Create(w http.ResponseWriter, r *http.Request) {
// @Description Delete user by admin in Admin Portal
// @Accept json
// @Produce json
// @Param body body domain.DeleteUserRequest true "input"
// @Param organizationId path string true "organizationId"
// @Param accountId path string true "accountId"
// @Param body body domain.DeleteUserRequest true "input"
// @Param organizationId path string true "organizationId"
// @Param accountId path string true "accountId"
// @Success 200
// @Router /admin/organizations/{organizationId}/users/{accountId} [delete]
// @Security JWT
Expand Down
6 changes: 3 additions & 3 deletions internal/usecase/system-notification-rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func (u *SystemNotificationRuleUsecase) MakeDefaultSystemNotificationRules(ctx c
EnablePortal: true,
},
TargetUsers: []model.User{organizationAdmin},
MessageTitle: "스택 (<<STACK>>)의 노드(<<INSTANCE>>)의 idle process의 cpu 점유율이 3분 동안 0% 입니다. (현재 사용률 {{$VALUE}})",
MessageTitle: "스택 (<<STACK>>)의 노드(<<INSTANCE>>)의 idle process의 cpu 점유율이 3분 동안 0% 입니다. (현재 사용률 {{$value}})",
MessageContent: "워커 노드 CPU가 과부하 상태입니다. 일시적인 서비스 Traffic 증가, Workload의 SW 오류, Server HW Fan Fail등 다양한 원인으로 인해 발생할 수 있습니다.",
MessageActionProposal: "일시적인 Service Traffic의 증가가 관측되지 않았다면, Alert발생 노드에서 실행 되는 pod중 CPU 자원을 많이 점유하는 pod의 설정을 점검해 보시길 제안드립니다. 예를 들어 pod spec의 limit 설정으로 과도한 CPU자원 점유을 막을 수 있습니다.",
Status: domain.SystemNotificationRuleStatus_PENDING,
Expand All @@ -218,7 +218,7 @@ func (u *SystemNotificationRuleUsecase) MakeDefaultSystemNotificationRules(ctx c
EnablePortal: true,
},
TargetUsers: []model.User{organizationAdmin},
MessageTitle: "스택 (<<STACK>>)의 노드(<<INSTANCE>>)의 Memory 사용량이 3분동안 80% 를 넘어서고 있습니다. (현재 사용률 <<VALUE>>)",
MessageTitle: "스택 (<<STACK>>)의 노드(<<INSTANCE>>)의 Memory 사용량이 3분동안 80% 를 넘어서고 있습니다. (현재 사용률 {{$value}})",
MessageContent: "워커 노드의 Memory 사용량이 80%를 넘었습니다. 일시적인 서비스 증가 및 SW 오류등 다양한 원인으로 발생할 수 있습니다.",
MessageActionProposal: "일시적인 Service Traffic의 증가가 관측되지 않았다면, Alert발생 노드에서 실행되는 pod중 Memory 사용량이 높은 pod들에 대한 점검을 제안드립니다.",
Status: domain.SystemNotificationRuleStatus_PENDING,
Expand Down Expand Up @@ -293,7 +293,7 @@ func (u *SystemNotificationRuleUsecase) MakeDefaultSystemNotificationRules(ctx c
EnablePortal: true,
},
TargetUsers: []model.User{organizationAdmin},
MessageTitle: "스택 (<<STACK>>)의 파드(<<POD>>)가 30분 동안 5회 이상 재기동 (<<VALUE>> 회)",
MessageTitle: "스택 (<<STACK>>)의 파드(<<POD>>)가 30분 동안 5회 이상 재기동 ({{$value}} 회)",
MessageContent: "특정 Pod가 빈번하게 재기동 되고 있습니다. 점검이 필요합니다. (<<STACK>> 스택, <<POD>> 파드)",
MessageActionProposal: "pod spec. 에 대한 점검이 필요합니다. pod의 log 및 status를 확인해 주세요.",
Status: domain.SystemNotificationRuleStatus_PENDING,
Expand Down
2 changes: 1 addition & 1 deletion pkg/domain/system-notification-template.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
const SN_TYPE_NODE_CPU_HIGH_LOAD = "node-cpu-high-load"
const SN_TYPE_NODE_MEMORY_HIGH_UTILIZATION = "node-memory-high-utilization"
const SN_TYPE_NODE_DISK_FULL = "node-disk-full"
const SN_TYPE_PVC_FULL = "pvc_full"
const SN_TYPE_PVC_FULL = "pvc-full"
const SN_TYPE_POD_RESTART_FREQUENTLY = "pod-restart-frequently"

type SystemNotificationTemplateResponse struct {
Expand Down
12 changes: 6 additions & 6 deletions scripts/init_postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ insert into project_roles ( id, name, description, created_at, updated_at ) valu

## SystemNotificationTemplates
insert into system_notification_templates ( id, name, description, is_system, metric_query, creator_id, updator_id, created_at, updated_at )
values ('d42d716f-dd2e-429b-897d-b602f6382790', 'node-cpu-high-load', 'node-cpu-high-load', true, '(avg by (taco_cluster, instance) (rate(node_cpu_seconds_total{mode="idle"}[60s]))) < 0', null, null, now(), now() );
values ('d42d716f-dd2e-429b-897d-b602f6382790', 'node-cpu-high-load', 'node-cpu-high-load', true, '(avg by (taco_cluster, instance) (rate(node_cpu_seconds_total{mode="idle"}[60s])))', null, null, now(), now() );
insert into system_notification_templates ( id, name, description, is_system, metric_query, creator_id, updator_id, created_at, updated_at )
values ('f11eefa4-5a16-44fc-8dae-4662e7fba023', 'node-memory-high-utilization', true, 'node-memory-high-utilization', '(node_memory_MemAvailable_bytes/node_memory_MemTotal_bytes) < 0.2', null, null, now(), now() );
values ('f11eefa4-5a16-44fc-8dae-4662e7fba023', 'node-memory-high-utilization', true, 'node-memory-high-utilization', '(node_memory_MemAvailable_bytes/node_memory_MemTotal_bytes)', null, null, now(), now() );
insert into system_notification_templates ( id, name, description, is_system, metric_query, creator_id, updator_id, created_at, updated_at )
values ('1ec08b58-2fe1-49c5-bbab-3544ec8ce330', 'node-disk-full', 'node-disk-full', true, 'predict_linear(node_filesystem_free_bytes{mountpoint="/"}[6h], 24*3600) < 0', null, null, now(), now() );
values ('1ec08b58-2fe1-49c5-bbab-3544ec8ce330', 'node-disk-full', 'node-disk-full', true, 'predict_linear(node_filesystem_free_bytes{mountpoint="/"}[6h], 24*3600)', null, null, now(), now() );
insert into system_notification_templates ( id, name, description, is_system, metric_query, creator_id, updator_id, created_at, updated_at )
values ('68dcb92d-91cc-47d0-9b2f-2285d74f157f', 'pvc-full', 'pvc-full', true, 'predict_linear(kubelet_volume_stats_available_bytes[6h], 24*3600) < 0', null, null, now(), now() );
values ('68dcb92d-91cc-47d0-9b2f-2285d74f157f', 'pvc-full', 'pvc-full', true, 'predict_linear(kubelet_volume_stats_available_bytes[6h], 24*3600)', null, null, now(), now() );
insert into system_notification_templates ( id, name, description, is_system, metric_query, creator_id, updator_id, created_at, updated_at )
values ('46e9e216-364a-4a3f-9182-85b2c4c34f77', 'pod-restart-frequently', true, 'pod-restart-frequently', 'increase(kube_pod_container_status_restarts_total{namespace!="kube-system"}[60m:]) > 2', null, null, now(), now() );
values ('46e9e216-364a-4a3f-9182-85b2c4c34f77', 'pod-restart-frequently', true, 'pod-restart-frequently', 'increase(kube_pod_container_status_restarts_total{namespace!="kube-system"}[60m:])', null, null, now(), now() );

## SystemNotificationTemplates -> SystemNotificationMetricParameters
insert into system_notification_metric_parameters ( "order", system_notification_template_id, key, value, created_at, updated_at )
Expand All @@ -89,4 +89,4 @@ values ( 0, '46e9e216-364a-4a3f-9182-85b2c4c34f77', 'STACK', '$labels.taco_clust
insert into system_notification_metric_parameters ( "order", system_notification_template_id, key, value, created_at, updated_at )
values ( 1, '46e9e216-364a-4a3f-9182-85b2c4c34f77', 'POD', '$labels.pod', now(), now() );
insert into system_notification_metric_parameters ( "order", system_notification_template_id, key, value, created_at, updated_at )
values ( 3, '46e9e216-364a-4a3f-9182-85b2c4c34f77', 'NAMESPACE', '$labels.namespace', now(), now() );
values ( 2, '46e9e216-364a-4a3f-9182-85b2c4c34f77', 'NAMESPACE', '$labels.namespace', now(), now() );
Loading