-- CLOUD-19295 | Host Process 관련 metric meta 추가
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES ('host_process_cpu_second_total','Host Process CPU Second Total  (%)','CPU user usage in seconds ( % )','sum by (groupname) (rate(namedprocess_namegroup_cpu_seconds_total{{filter}}[1m]))*100','Process','Host','','true','false','"Host:{{$labels.instance}} Process CPU :{{humanize $value}}|{threshold}."');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('host_process_memory_bytes','Host  Process memory bytes (MiB)','number of bytes of memory   in use / 1048576','sum by (groupname)  ((namedprocess_namegroup_memory_bytes{ memtype="resident", {filter}})) / 1048576','Process','Host','','true','false','"Host:{{$labels.instance}} Process memory :{{humanize $value}}MiB|{threshold}MiB."');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('host_process_read_bytes','Host  Process read bytes ( KiB)','number of bytes read by this group /1024','sum by (groupname) (rate(namedprocess_namegroup_read_bytes_total{{filter}}[1m]))/1024','Process','Host','','true','false','"Host:{{$labels.instance}} Disk Read Size:{{humanize $value}}KiB|{threshold}KiB."');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('host_process_write_bytes','Host  Process write bytes(KiB)','number of bytes written by this group/1024','sum by (groupname) (rate(namedprocess_namegroup_write_bytes_total{{filter}}[1m]))/1024','Process','Host','','true','false','"Host:{{$labels.instance}} Disk Write Size:{{humanize $value}}KiB|{threshold}KiB."');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('host_process_count','Host  Process number','number of processes in   this group', 'sum by (groupname)  (namedprocess_namegroup_num_procs{{filter}})', 'Process','Host','','true','false','"Host:{{$labels.instance}} Count:{{humanize $value}}|{threshold}."');

-- CLOUD-19283 Topology Agent 와 node exporter 통합
-- Auto-generated SQL script #202307261024
UPDATE public.agent_install_file_info
	SET yaml='---',use_yn=false
	WHERE id=4;
UPDATE public.agent_install_file_info
	SET yaml='---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: cloudmoa-cluster-role
rules:
  - nonResourceURLs:
      - "*"
    verbs:
      - get
  - apiGroups:
      - metrics.k8s.io
    resources:
      - pods
      - nodes
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - ""
    resources:
      - pods
    verbs:
      - get
      - list
      - watch
      - update
  - apiGroups:
      - ""
    resources:
      - services
    verbs:
      - get
      - list
      - watch
      - update
  - apiGroups:
      - ""
    resources:
      - nodes/stats
      - endpoints
      - namespaces
      - events
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - apps
    resources:
      - daemonsets
      - deployments
      - deployments/scale
      - replicasets
      - replicasets/scale
      - statefulsets
      - statefulsets/scale
    verbs:
      - get
      - list
      - watch
      - update
  - apiGroups:
      - batch
    resources:
      - jobs
    verbs:
      - get
      - list
      - watch
      - update
  - apiGroups:
      - batch
    resources:
      - cronjobs
    verbs:
      - get
      - list
      - update
  - apiGroups:
      - storage.j8s.io
    resources:
      - storageclasses
    verbs:
      - get
      - list
  - apiGroups:
      - networking.k8s.io
    resources:
      - ingresses
    verbs:
      - get
      - list
  - apiGroups:
      - extensions
    resources:
      - ingresses
    verbs:
      - get
      - list
  - apiGroups:
      - policy
    resources:
      - podsecuritypolicies
    verbs:
      - use
    resourceNames:
      - imxc-ps
  - apiGroups:
      - certificates.k8s.io
    resourceNames:
      - kubernetes.io/kube-apiserver-client-kubelet
    resources:
      - signers
    verbs:
      - approve
  - apiGroups:
      - certificates.k8s.io
    resourceNames:
      - kubernetes.io/kubelet-serving
    resources:
      - signers
    verbs:
      - approve
  - apiGroups:
      - ""
    resources:
      - nodes
    verbs:
      - get
      - list
      - watch
      - proxy
  - apiGroups:
      - ""
    resources:
      - nodes/log
      - nodes/metrics
      - nodes/proxy
      - nodes/spec
      - nodes/stats
    verbs:
      - ''*''
  - apiGroups:
      - ''*''
    resources:
      - ''*''
    verbs:
      - get
      - list
      - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: cloudmoa-restricted-rb
  namespace: $CLOUDMOA_NAMESPACE
subjects:
  - kind: ServiceAccount
    name: default
    namespace: $CLOUDMOA_NAMESPACE
roleRef:
  kind: ClusterRole
  name: cloudmoa-cluster-role
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: policy/v1beta1
kind: PodSecurityPolicy
metadata:
  name: cloudmoa-psp
  namespace: $CLOUDMOA_NAMESPACE
spec:
  privileged: true
  seLinux:
    rule: RunAsAny
  supplementalGroups:
    rule: RunAsAny
  runAsUser:
    rule: RunAsAny
  fsGroup:
    rule: RunAsAny
  hostPorts:
    - max: 65535
      min: 0
  hostNetwork: true
  hostPID: true
  volumes:
    - configMap
    - secret
    - emptyDir
    - hostPath
    - projected
    - downwardAPI
    - persistentVolumeClaim
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: cloudmoa-topology-agent
  namespace: $CLOUDMOA_NAMESPACE
  labels:
    app: cloudmoa-topology-agent
spec:
  selector:
    matchLabels:
      app: cloudmoa-topology-agent
  template:
    metadata:
      labels:
        app: cloudmoa-topology-agent
    spec:
      hostNetwork: true
      hostPID: true
      tolerations:
      - effect: NoSchedule
        operator: Exists
      - effect: NoExecute
        operator: Exists
      containers:
      - image: $DOCKER_REGISTRY_URL/node-exporter
        name: node-agent
        resources:
          limits:
            cpu: 250m
            memory: 180Mi
          requests:
            cpu: 125m
            memory: 90Mi
        ports:
        - containerPort: 9110
          hostPort: 9110
          name: scrape
        args:
        - --path.procfs=/host/proc
        - --path.sysfs=/host/sys
        - --path.rootfs=/host/root
        - --collector.filesystem.ignored-mount-points=^/(dev|proc|sys|run|var/lib/docker/.+|var/lib/kubelet/pods/.+)($|/)
        - --collector.tcpstat
        - --web.listen-address=:9110
        # --log.level=debug
        env:
        - name: GOMAXPROCS
          value: "1"
        volumeMounts:
        - mountPath: /host/proc
          name: proc-volume
          readOnly: false
        - mountPath: /host/sys
          name: sys-volume
          readOnly: false
        - mountPath: /host/root
          mountPropagation: HostToContainer
          name: root-volume
          readOnly: true
      - name: cloudmoa-topology-agent
        image: $DOCKER_REGISTRY_URL/topology-agent:$IMAGE_TAG
        resources:
          requests:
            cpu: 200m
            memory: 512Mi
          limits:
            cpu: 500m
            memory: 600Mi
        securityContext:
          privileged: true
        volumeMounts:
        - mountPath: /host/usr/bin
          name: bin-volume
        - mountPath: /var/run/docker.sock
          name: docker-volume
        - mountPath: /host/proc
          name: proc-volume
        - mountPath: /root
          name: root-volume
        - mountPath: /log
          name: log-volume
        env:
          - name: DATAGATE
            value: $COLLTION_SERVER_DATAGATE_IP:$COLLTION_SERVER_DATAGATE_PORT
          - name: CLUSTER_ID
            value: $CLOUDMOA_CLUSTER_ID
          - name: ROOT_DIRECTORY
            value: /root
          - name: NODE_NAME
            valueFrom:
              fieldRef:
                apiVersion: v1
                fieldPath: spec.nodeName
          - name: POD_ID
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          - name: NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
          - name: LOG_LEVEL
            value: "INFO"
      volumes:
      - name: bin-volume
        hostPath:
          path: /usr/bin
          type: Directory
      - name: docker-volume
        hostPath:
          path: /var/run/docker.sock
      - name: proc-volume
        hostPath:
          path: /proc
      - name: root-volume
        hostPath:
          path: /
      - hostPath:
          path: /sys
        name: sys-volume
      - name: log-volume
        hostPath:
          path: /home'
	WHERE id=2;


-- CLOUD-19460 Nginx metric에 {filter} 추가
-- Nginx Ingress 대시보드 지원 관련 metric meta 추가
UPDATE public.metric_meta2 SET expr = 'sum by (xm_clst_id, xm_namespace, xm_node_id, instance, class) (nginx_ingress_nginx_up{ {filter} })' WHERE id ='nginx_ingress_nginx_up';
UPDATE public.metric_meta2 SET expr = 'sum by (xm_clst_id, xm_namespace, xm_node_id, instance, class) (nginx_ingress_nginx_connections_active{ {filter} })' WHERE id ='nginx_ingress_nginx_connections_active';
UPDATE public.metric_meta2 SET expr = 'sum by (xm_clst_id, xm_namespace, xm_node_id, instance, class) (nginx_ingress_controller_nginx_reload_errors_total{ {filter} })' WHERE id ='nginx_ingress_controller_nginx_last_reload_status';
UPDATE public.metric_meta2 SET expr = 'sum by (xm_clst_id, xm_namespace, xm_node_id, instance, class) (nginx_ingress_controller_nginx_reload_errors_total{ {filter} })' WHERE id ='nginx_ingress_controller_nginx_reload_errors_total';
UPDATE public.metric_meta2 SET expr = 'sum by (xm_clst_id, xm_namespace, xm_node_id, instance, class) (nginx_ingress_controller_nginx_reloads_total{ {filter} })' WHERE id ='nginx_ingress_controller_nginx_reloads_total';
UPDATE public.metric_meta2 SET expr = 'sum by (xm_clst_id, xm_namespace, xm_node_id, instance, class) (nginx_ingress_nginx_http_requests_total{ {filter} })' WHERE id ='nginx_ingress_nginx_http_requests_total';
UPDATE public.metric_meta2 SET expr = 'sum by (xm_clst_id, xm_namespace, xm_node_id, instance, class) (rate(nginx_ingress_nginx_http_requests_total{ {filter} }[1m]))' WHERE id ='nginx_ingress_nginx_http_requests_second';

-- Nginx 대시보드 지원 관련 metric meta 추가
UPDATE public.metric_meta2 SET expr = 'sum by (instance) (nginx_up{ {filter} })' WHERE id ='nginx_up';
UPDATE public.metric_meta2 SET expr = 'sum by (instance) (irate(nginx_connections_accepted{ {filter} }[5m]))' WHERE id ='nginx_connections_accepted';
UPDATE public.metric_meta2 SET expr = 'sum by (instance) (irate(nginx_connections_handled{ {filter} }[5m]))' WHERE id ='nginx_connections_handled';
UPDATE public.metric_meta2 SET expr = 'sum by (instance) (nginx_connections_active{ {filter} })' WHERE id ='nginx_connections_active';
UPDATE public.metric_meta2 SET expr = 'sum by (instance) (nginx_connections_reading{ {filter} })' WHERE id ='nginx_connections_reading';
UPDATE public.metric_meta2 SET expr = 'sum by (instance) (nginx_connections_waiting{ {filter} })' WHERE id ='nginx_connections_waiting';
UPDATE public.metric_meta2 SET expr = 'sum by (instance) (nginx_connections_writing{ {filter} })' WHERE id ='nginx_connections_writing';
UPDATE public.metric_meta2 SET expr = 'sum by (instance) (irate(nginx_http_requests_total{ {filter} }[1m]))' WHERE id ='nginx_http_requests_total';

-- Kube Event 관련 metric meta 추가
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('kube_event_node','Kubernetes Node Event','Kubernetes Node Event','count by (xm_clst_id,xm_namespace,entity_type,involved_kind,involved_name,reason,type) (imxc_kubernetes_event_in_last_min{involved_kind="Node"})','Event','Node','','true','false','CLST:{{$labels.xm_clst_id}} NS:{{$labels.xm_namespace}}  Reason : {{$labels.reason}} Level : {{$labels.type}} ');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('kube_event_job','Kubernetes Job Event','Kubernetes Job Event','count by (xm_clst_id,xm_namespace,entity_type,involved_kind,involved_name,reason,type) (imxc_kubernetes_event_in_last_min{involved_kind="Job"})','Event','Workload','','true','false','CLST:{{$labels.xm_clst_id}} NS:{{$labels.xm_namespace}}  Reason : {{$labels.reason}} Level : {{$labels.type}} ');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('kube_event_cronjob','Kubernetes CronJob Event','Kubernetes CronJob Event','count by (xm_clst_id,xm_namespace,entity_type,involved_kind,involved_name,reason,type) (imxc_kubernetes_event_in_last_min{involved_kind="CronJob"})','Event','Workload','','true','false','CLST:{{$labels.xm_clst_id}} NS:{{$labels.xm_namespace}}  Reason : {{$labels.reason}} Level : {{$labels.type}} ');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('kube_event_daemonset','Kubernetes DaemonSet Event','Kubernetes DaemonSet Event','count by (xm_clst_id,xm_namespace,entity_type,involved_kind,involved_name,reason,type) (imxc_kubernetes_event_in_last_min{involved_kind="DaemonSet"})','Event','Workload','','true','false','CLST:{{$labels.xm_clst_id}} NS:{{$labels.xm_namespace}}  Reason : {{$labels.reason}} Level : {{$labels.type}} ');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('kube_event_deployment','Kubernetes Deployment Event','Kubernetes Deployment Event','count by (xm_clst_id,xm_namespace,entity_type,involved_kind,involved_name,reason,type) (imxc_kubernetes_event_in_last_min{involved_kind="Deployment"})','Event','Workload','','true','false','CLST:{{$labels.xm_clst_id}} NS:{{$labels.xm_namespace}}  Reason : {{$labels.reason}} Level : {{$labels.type}} ');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('kube_event_endpoints','Kubernetes Endpoints Event','Kubernetes Endpoints Event','count by (xm_clst_id,xm_namespace,entity_type,involved_kind,involved_name,reason,type) (imxc_kubernetes_event_in_last_min{involved_kind="Endpoints"})','Event','Workload','','true','false','CLST:{{$labels.xm_clst_id}} NS:{{$labels.xm_namespace}}  Reason : {{$labels.reason}} Level : {{$labels.type}} ');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('kube_event_persistentvolumeclaim','Kubernetes PersistentVolumeClaim Event','Kubernetes PersistentVolumeClaim Event','count by (xm_clst_id,xm_namespace,entity_type,involved_kind,involved_name,reason,type) (imxc_kubernetes_event_in_last_min{involved_kind="PersistentVolumeClaim"})','Event','Workload','','true','false','CLST:{{$labels.xm_clst_id}} NS:{{$labels.xm_namespace}}  Reason : {{$labels.reason}} Level : {{$labels.type}} ');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('kube_event_pod','Kubernetes Pod Event','Kubernetes Pod Event','count by (xm_clst_id,xm_namespace,entity_type,involved_kind,involved_name,reason,type) (imxc_kubernetes_event_in_last_min{involved_kind="Pod"})','Event','Workload','','true','false','CLST:{{$labels.xm_clst_id}} NS:{{$labels.xm_namespace}}  Reason : {{$labels.reason}} Level : {{$labels.type}} ');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('kube_event_warning','Kubernetes Warning Event','Kubernetes Warning Event','count by (xm_clst_id,xm_namespace,entity_type,involved_kind,involved_name,reason,type) (imxc_kubernetes_event_in_last_min{type="Warning"})','Event','Workload','','true','false','CLST:{{$labels.xm_clst_id}} NS:{{$labels.xm_namespace}} Name: {{$involved_name}} Reason : {{$labels.reason}} Level : {{$labels.type}} ');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('kube_event_replicaset','Kubernetes ReplicaSet Event','Kubernetes ReplicaSet Event','count by (xm_clst_id,xm_namespace,entity_type,involved_kind,involved_name,reason,type) (imxc_kubernetes_event_in_last_min{involved_kind="ReplicaSet"})','Event','Workload','','true','false','CLST:{{$labels.xm_clst_id}} NS:{{$labels.xm_namespace}}  Reason : {{$labels.reason}} Level : {{$labels.type}} ');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('kube_event_statefulset','Kubernetes StatefulSet Event','Kubernetes StatefulSet Event','count by (xm_clst_id,xm_namespace,entity_type,involved_kind,involved_name,reason,type) (imxc_kubernetes_event_in_last_min{involved_kind="StatefulSet"})','Event','Workload','','true','false','CLST:{{$labels.xm_clst_id}} NS:{{$labels.xm_namespace}}  Reason : {{$labels.reason}} Level : {{$labels.type}} ');

-- Event Alert 관련 metric meta 추가
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('event_alert_successful_create','Event Alert SuccessfulCreate','Event Alert SuccessfulCreate','count by (xm_clst_id, xm_namespace, entity_type, involved_kind, involved_name, reason, type) (imxc_kubernetes_event_in_last_min{reason=~"SuccessfulCreate", {filter} })','Event','Workload','','true','false','CLST:{{$labels.xm_clst_id}} NS:{{$labels.xm_namespace}}  Reason : {{$labels.reason}} Level : {{$labels.type}} Name : {{$labels.involved_name}} ');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('event_alert_successful_delete','Event Alert SuccessfulDelete','Event Alert SuccessfulDelete','count by (xm_clst_id, xm_namespace, entity_type, involved_kind, involved_name, reason, type) (imxc_kubernetes_event_in_last_min{reason=~"SuccessfulDelete", {filter} })','Event','Workload','','true','false','CLST:{{$labels.xm_clst_id}} NS:{{$labels.xm_namespace}}  Reason : {{$labels.reason}} Level : {{$labels.type}} Name : {{$labels.involved_name}} ');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('event_alert_deadline_exceeded','Event Alert DeadlineExceeded','Event Alert DeadlineExceeded','count by (xm_clst_id, xm_namespace, entity_type, involved_kind, involved_name, reason, type) (imxc_kubernetes_event_in_last_min{reason=~"DeadlineExceeded", {filter} })','Event','Workload','','true','false','CLST:{{$labels.xm_clst_id}} NS:{{$labels.xm_namespace}}  Reason : {{$labels.reason}} Level : {{$labels.type}} Name : {{$labels.involved_name}} ');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('event_alert_job','Event Alert Job','Event Alert Job','count by (xm_clst_id, xm_namespace, entity_type, involved_kind, involved_name, reason, type) (imxc_kubernetes_event_in_last_min{involved_kind=~"Job", {filter} })','Event','Workload','','true','false','CLST:{{$labels.xm_clst_id}} NS:{{$labels.xm_namespace}}  Reason : {{$labels.reason}} Level : {{$labels.type}} Name : {{$labels.involved_name}} ');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('event_alert_cronjob','Event Alert CronJob','Event Alert CronJob','count by (xm_clst_id, xm_namespace, entity_type, involved_kind, involved_name, reason, type) (imxc_kubernetes_event_in_last_min{involved_kind=~"CronJob", {filter} })','Event','Workload','','true','false','CLST:{{$labels.xm_clst_id}} NS:{{$labels.xm_namespace}}  Reason : {{$labels.reason}} Level : {{$labels.type}} Name : {{$labels.involved_name}} ');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('event_alert_normal','Event Alert Normal','Event Alert Normal','count by (xm_clst_id, xm_namespace, involved_kind, involved_name, reason, type) (imxc_kubernetes_event_in_last_min{type=~"Normal", {filter} })','Event','Workload','','true','false','CLST:{{$labels.xm_clst_id}} NS:{{$labels.xm_namespace}}  Reason : {{$labels.reason}} Level : {{$labels.type}} Name : {{$labels.involved_name}} ');
INSERT INTO public.metric_meta2 (id,meta_name,description,expr,resource_type,entity_type,groupby_keys,in_use,anomaly_score,message) VALUES('event_alert_warning','Event Alert Warning','Event Alert Warning','count by (xm_clst_id, xm_namespace, involved_kind, involved_name, reason, type) (imxc_kubernetes_event_in_last_min{type=~"Warning", {filter} })','Event','Workload','','true','false','CLST:{{$labels.xm_clst_id}} NS:{{$labels.xm_namespace}}  Reason : {{$labels.reason}} Level : {{$labels.type}} Name : {{$labels.involved_name}} ');

-- node-export 부분 node-agent 변경
UPDATE public.metric_meta2 SET expr = '(100 - (avg by (xm_clst_id, xm_node_id, xm_entity_type)(clamp_max(rate(node_cpu_seconds_total{ name="node-agent", mode="idle", xm_entity_type="Node", {filter} }[1m]),1.0) * 100)))' WHERE id ='node_cpu_usage';
UPDATE public.metric_meta2 SET expr = '(100 - (avg by (xm_clst_id)(clamp_max(rate(node_cpu_seconds_total{ name="node-agent", mode="idle", xm_entity_type="Node", {filter} }[1m]),1.0)) * 100))' WHERE id ='cluster_cpu_usage';
UPDATE public.metric_meta2 SET expr = '(100 - (avg by (xm_clst_id, xm_node_id) (clamp_max(rate(node_cpu_seconds_total{name="node-agent", mode="idle", xm_entity_type="Node", {filter}}[1m]),1.0)) * 100)) * sum by(xm_clst_id, xm_node_id)(imxc_kubernetes_node_resource_capacity_cpu{{filter}}) / 100' WHERE id ='node_cpu_used';
UPDATE public.metric_meta2 SET expr = 'avg by (xm_clst_id, xm_node_id, xm_entity_type) (rate(node_cpu_seconds_total{name="node-agent", mode="iowait", xm_entity_type="Node" , {filter}}[1m])) * 100' WHERE id ='node_cpu_iowait';
UPDATE public.alert_rule_meta SET expr = '(100 - (avg by (xm_clst_id, xm_node_id, xm_entity_type) (rate(node_cpu_seconds_total{ name=''node-agent'', mode=''idle'', xm_entity_type=''Node'', {filter} }[1m])) * 100))' WHERE id = 97;
UPDATE public.agent_install_file_info SET name = 'node-agent' WHERE id=4;
commit;
