From 4036b575a090c991e8ab2fa4e1199e4959d77381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EC=88=98=ED=98=84?= Date: Thu, 30 Oct 2025 03:17:10 +0900 Subject: [PATCH] feat: Update monitoring functions --- conf/api.yaml | 402 ++++++++++-------- .../js/common/api/services/monitoring_api.js | 122 +++--- .../js/pages/operation/analytics/logmanage.js | 184 ++++---- .../operation/analytics/monitoringconfig.js | 340 +++------------ .../js/pages/operation/manage/monitoring.js | 116 ++++- .../analytics/monitorings/mcismonitoring.html | 15 +- .../monitorings/_monitoringconfig_detail.html | 29 +- .../monitorings/_monitoringconfig_log.html | 69 --- .../_monitoringconfigtab_monitorStorages.html | 113 ----- .../_monitoringconfigtabcards.html | 14 - 10 files changed, 512 insertions(+), 892 deletions(-) delete mode 100644 front/templates/partials/operations/analytics/monitorings/_monitoringconfig_log.html delete mode 100644 front/templates/partials/operations/analytics/monitorings/_monitoringconfigtab_monitorStorages.html diff --git a/conf/api.yaml b/conf/api.yaml index e537994b..29e43367 100644 --- a/conf/api.yaml +++ b/conf/api.yaml @@ -1786,218 +1786,274 @@ serviceActions: description: webValidate mc-observability: - Poststorage: - method: post - resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/target/{targetId}/storage - description: "" - Getstorages: + LogLabelsQuery: method: get - resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/target/{targetId}/storage - description: "" - Putstorage: - method: put - resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/target/{targetId}/storage - description: "" - Getminingdbtags": + resourcePath: /api/o11y/log/labels + description: "Retrieve the list of label keys provided by Loki." + LogVolumeQuery: method: get - resourcePath: /api/o11y/monitoring/miningdb/tag - description: "" - Gettargetanomalydetectionsettings: + resourcePath: /api/o11y/log/log_volumes + description: "Retrieve log volumes (metric time series data) for the given period." + LogRangeQuery: method: get - resourcePath: /api/o11y/insight/anomaly-detection/settings/nsId/{nsId}/target/{targetId} - description: "Fetch the current settings for a specific anomaly detection target." - Postanomalydetection: - method: post - resourcePath: /api/o11y/insight/anomaly-detection/{settingSeq} - description: "Request anomaly detection" - Getpredictionoptions: + resourcePath: /api/o11y/log/query_range + description: "Retrieve log data for a specific query within a given time range." + GetAllInfluxDB: method: get - resourcePath: /api/o11y/insight/predictions/options - description: "Fetch the available target types, metric types, and prediction range options for the prediction API." - Gettargetsnsmci: + resourcePath: /api/o11y/monitoring/influxdb + description: "Retrieve all InfluxDB servers" + GetPlugins: method: get - resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/target - description: "" - Putitem: - method: put - resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/target/{targetId}/item - description: "" - Postitem: - method: post - resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/target/{targetId}/item - description: "" - Getitems: + resourcePath: /api/o11y/monitoring/plugins + description: "Retrieve plugin list" + GetAllVMs: method: get - resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/target/{targetId}/item - description: "" - Gettriggeralertslackuseralllist: + resourcePath: /api/o11y/monitoring/vm + description: "Retrieve all targets" + GetPaginatedTriggerHistories: method: get - resourcePath: /api/o11y/trigger/policy/{policySeq}/alert/slack - description: "" - Createtriggeralertslackuser: + resourcePath: /api/o11y/trigger/history + description: "Get paginated trigger histories" + GetPaginatedTriggerPolicies: + method: get + resourcePath: /api/o11y/trigger/policy + description: "Get paginated trigger policies" + CreateTriggerPolicy: method: post - resourcePath: /api/o11y/trigger/policy/{policySeq}/alert/slack - description: "" - Deletetriggeralertslackuser: - method: delete - resourcePath: /api/o11y/trigger/policy/{policySeq}/alert/slack/{seq} - description: "" - Getminingdbs: + resourcePath: /api/o11y/trigger/policy + description: "Create trigger policy" + GetMeasurementFields: method: get - resourcePath: /api/o11y/monitoring/miningdb - description: "" - Putminingdb: - method: put - resourcePath: /api/o11y/monitoring/miningdb - description: "" - Gettargets: + resourcePath: /api/o11y/monitoring/influxdb/measurement + description: "Retrieve InfluxDB measurements" + GetMeasurementTags: method: get - resourcePath: /api/o11y/monitoring/target - description: "" - Deletestorage: - method: delete - resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/target/{targetId}/storage/{storageSeq} - description: "" - Deleterequesttriggerpolicy: + resourcePath: /api/o11y/monitoring/influxdb/tag + description: "Retrieve InfluxDB tags" + GetAllAlertRules: + method: get + resourcePath: /api/o11y/trigger/alert/alert-rules + description: "Get all alert rules" + GetAllAlerts: + method: get + resourcePath: /api/o11y/trigger/alert/alerts + description: "Get all alerts" + GetAllContactPoints: + method: get + resourcePath: /api/o11y/trigger/alert/contact-points + description: "Get all contact points" + CheckGrafanaHealthStatus: + method: get + resourcePath: /api/o11y/trigger/alert/health + description: "Check grafana health status" + GetPaginatedAlertTestHistories: + method: get + resourcePath: /api/o11y/trigger/alert/test-history + description: "Get paginated alert test histories" + GetSupportedNotificationChannels: + method: get + resourcePath: /api/o11y/trigger/noti/channel + description: "Get supported notification channels" + GetPaginatedNotificationHistories: + method: get + resourcePath: /api/o11y/trigger/noti/history + description: "Get paginated notification histories" + DeleteTriggerPolicy: method: delete - resourcePath: /api/o11y/trigger/policy/{policySeq} - description: "" - Updaterequesttriggerpolicy: - method: patch - resourcePath: /api/o11y/trigger/policy/{policySeq} - description: "" - Getreadyz: + resourcePath: /api/o11y/trigger/policy/{id} + description: "Delete trigger policy" + LabelValueQuery: method: get - resourcePath: /api/o11y/readyz - description: "" - Getplugins: + resourcePath: /api/o11y/log/labels/{label}/values + description: "Retrieve the list of values for a specific label key." + GetVMByNsMci: method: get - resourcePath: /api/o11y/monitoring/plugins - description: "" - Getopensearchlogs: + resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/vm + description: "Retrieve target list by NS/MCI" + TestAlertReceiverConnection: method: post - resourcePath: /api/o11y/monitoring/opensearch/logs - description: "" - Gettriggerpolicyalllist: + resourcePath: /api/o11y/trigger/alert/alert-receiver/test + description: "Test alert receiver connection" + SearchAlertsByTitle: method: get - resourcePath: /api/o11y/trigger/policy - description: "" - Createrequesttriggerpolicy: + resourcePath: /api/o11y/trigger/alert/alerts/search + description: "Search alerts by title" + UpdateTriggerHistoryComment: + method: put + resourcePath: /api/o11y/trigger/history/{id}/comment + description: "Update trigger history comment" + UpdateTriggerPolicyNotificationChannels: + method: put + resourcePath: /api/o11y/trigger/policy/{id}/channel + description: "Update trigger policy notification channels" + AddTriggerVM: method: post - resourcePath: /api/o11y/trigger/policy - description: "The values that require Base64 encoding:\ndescription, name, threshold\n" - Getallanomalydetectionsettings: + resourcePath: /api/o11y/trigger/policy/{id}/vm + description: "Add trigger vm" + RemoveTriggerVM: + method: delete + resourcePath: /api/o11y/trigger/policy/{id}/vm + description: "Remove trigger vm" + GetMetricsByVMId: + method: post + resourcePath: /api/o11y/monitoring/influxdb/metric/{nsId}/{mciId}/{vmId} + description: "Retrieve InfluxDB metrics" + GetMetricsByNsIdAndMciId: + method: post + resourcePath: /api/o11y/monitoring/influxdb/metric/{nsId}/{mciId} + description: "Retrieve InfluxDB metrics" + GetVM: method: get - resourcePath: /api/o11y/insight/anomaly-detection/settings - description: "Fetch the current settings for all anomaly detection targets." - Postanomalydetectionsettings: + resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/vm/{vmId} + description: "Retrieve single target" + PostVM: method: post - resourcePath: /api/o11y/insight/anomaly-detection/settings - description: "Register a target for anomaly detection and automatically schedule detection tasks. \n(measurememt : field) Relationships are as follows. \ncpu : usage_idle \nmem : used_percent\n" - Getnss: + resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/vm/{vmId} + description: "Create target (VM)" + PutVM: + method: put + resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/vm/{vmId} + description: "Update target" + DeleteVM: + method: delete + resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/vm/{vmId} + description: "Delete target" + GetMonitoringItems: method: get - resourcePath: /api/o11y/monitoring/ns - description: "" - Getinfluxdbmetrics: + resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/vm/{vmId}/item + description: "Retrieve monitoring item list" + AddMonitoringItem: method: post - resourcePath: /api/o11y/monitoring/influxdb/metric - description: "" - Putanomalydetectionsettings: + resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/vm/{vmId}/item + description: "Add monitoring item" + UpdateMonitoringItem: + method: put + resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/vm/{vmId}/item + description: "Update monitoring item" + DeleteMonitoringItem: + method: delete + resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/vm/{vmId}/item/{itemSeq} + description: "Delete monitoring item" + UpdateAnomalySetting: method: put resourcePath: /api/o11y/insight/anomaly-detection/settings/{settingSeq} - description: "Modify the settings for a specific anomaly detection target, including the monitoring metric and interval." - Deleteanomalydetectionsettings: + description: "updateAnomalySetting" + DeleteAnomalySetting: method: delete resourcePath: /api/o11y/insight/anomaly-detection/settings/{settingSeq} - description: "Remove a target from anomaly detection, stopping and removing any scheduled tasks." - Deleteitem: + description: "deleteAnomalySetting" + PredictMonitoringDataForMci: + method: post + resourcePath: /api/o11y/insight/predictions/ns/{nsId}/mci/{mciId} + description: "predictMonitoringDataForMci" + PredictMonitoringDataForVm: + method: post + resourcePath: /api/o11y/insight/predictions/ns/{nsId}/mci/{mciId}/vm/{vmId} + description: "predictMonitoringDataForVm" + QueryLogAnalysis: + method: post + resourcePath: /api/o11y/insight/log-analysis/query + description: "queryLogAnalysis" + GetLLMChatSessions: + method: get + resourcePath: /api/o11y/insight/llm/session + description: "getLLMChatSessions" + PostLLMChatSession: + method: post + resourcePath: /api/o11y/insight/llm/session + description: "postLLMChatSession" + DeleteLLMChatSession: method: delete - resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/target/{targetId}/item/{itemSeq} - description: "" - Getinfluxdbmeasurements: + resourcePath: /api/o11y/insight/llm/session + description: "deleteLLMChatSession" + GetLLMApiKeys: method: get - resourcePath: /api/o11y/monitoring/influxdb/measurement - description: "" - Gettriggerhistoryalllist: + resourcePath: /api/o11y/insight/llm/api-keys + description: "getLLMApiKeys" + PostLLMApiKeys: + method: post + resourcePath: /api/o11y/insight/llm/api-keys + description: "postLLMApiKeys" + PredictAnomalyDetection: + method: post + resourcePath: /api/o11y/insight/anomaly-detection/{settingSeq} + description: "predictAnomalyDetection" + GetAnomalySettings: method: get - resourcePath: /api/o11y/trigger/policy/history - description: "Base64 Encoded value: \nname\n" - Postprediction: + resourcePath: /api/o11y/insight/anomaly-detection/settings + description: "getAnomalySettings" + CreateAnomalySetting: method: post - resourcePath: /api/o11y/insight/predictions/nsId/{nsId}/target/{targetId} - description: "Predict future metrics (cpu, mem, disk, system) for a given vm or mci group.\n(measurememt : field) Relationships are as follows. \ncpu : usage_idle \nmem : used_percent \ndisk : used_percent \nsystem : load1\n" - Getpredictionhistory: + resourcePath: /api/o11y/insight/anomaly-detection/settings + description: "createAnomalySetting" + QueryAlertAnalysis: + method: post + resourcePath: /api/o11y/insight/alert-analysis/query + description: "queryAlertAnalysis" + GetPredictionOptions: method: get - resourcePath: /api/o11y/insight/predictions/nsId/{nsId}/target/{targetId}/history - description: "Get previously stored prediction data for a specific vm or mci group." - Getinfluxdbtags: + resourcePath: /api/o11y/insight/predictions/options + description: "getPredictionOptions" + GetPredictionHistoryForVm: method: get - resourcePath: /api/o11y/monitoring/influxdb/tag - description: "" - Getcsp: + resourcePath: /api/o11y/insight/predictions/ns/{nsId}/mci/{mciId}/vm/{vmId}/history + description: "getPredictionHistoryForVm" + GetPredictionHistoryForMci: method: get - resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/target/{targetId}/csp/{measurement} - description: "" - Puttriggertarget: - method: put - resourcePath: /api/o11y/trigger/policy/{policySeq}/target - description: "" - Deletetriggeralertemailuser: - method: delete - resourcePath: /api/o11y/trigger/policy/{policySeq}/alert/email/{seq} - description: "" - Getanomalydetectionoptions: + resourcePath: /api/o11y/insight/predictions/ns/{nsId}/mci/{mciId}/history + description: "getPredictionHistoryForMci" + GetPredictionMeasurements: method: get - resourcePath: /api/o11y/insight/anomaly-detection/options - description: "Fetch the available target types, metric types, and interval options for the anomaly detection API." - Gettriggertargetalllist: + resourcePath: /api/o11y/insight/predictions/measurement + description: "getPredictionMeasurements" + GetPredictionSpecificMeasurement: method: get - resourcePath: /api/o11y/trigger/policy/target - description: "" - Gettriggeralertemailuseralllist: + resourcePath: /api/o11y/insight/predictions/measurement/{measurement} + description: "getPredictionSpecificMeasurement" + GetLLMSessionHistory: method: get - resourcePath: /api/o11y/trigger/policy/{policySeq}/alert/email - description: "" - Createtriggeralertemailuser: - method: post - resourcePath: /api/o11y/trigger/policy/{policySeq}/alert/email - description: "" - Getanomalydetectionhistory: + resourcePath: /api/o11y/insight/llm/session/{sessionId}/history + description: "getLLMSessionHistory" + GetLLMModelOptions: method: get - resourcePath: /api/o11y/insight/anomaly-detection/nsId/{nsId}/target/{targetId}/history - description: "Fetch the results of anomaly detection for a specific target within a given time range." - Gettarget: + resourcePath: /api/o11y/insight/llm/model + description: "getLLMModelOptions" + GetAnomalySettingsForMci: method: get - resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/target/{targetId} - description: "" - Puttarget: - method: put - resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/target/{targetId} - description: "" - Posttarget: - method: post - resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/target/{targetId} - description: "" - Deletetarget: - method: delete - resourcePath: /api/o11y/monitoring/{nsId}/{mciId}/target/{targetId} - description: "" - Getminingdbmetrics: - method: post - resourcePath: /api/o11y/monitoring/miningdb/metric - description: "" - Getminingdbmeasurements: + resourcePath: /api/o11y/insight/anomaly-detection/settings/ns/{nsId}/mci/{mciId} + description: "getAnomalySettingsForMci" + GetAnomalySettingsForVm: method: get - resourcePath: /api/o11y/monitoring/miningdb/measurement - description: "" - Getopensearches: + resourcePath: /api/o11y/insight/anomaly-detection/settings/ns/{nsId}/mci/{mciId}/vm/{vmId} + description: "getAnomalySettingsForVm" + GetOptions: method: get - resourcePath: /api/o11y/monitoring/opensearch - description: "" - Getinfluxdbs: + resourcePath: /api/o11y/insight/anomaly-detection/options + description: "getOptions" + GetAnomalyHistoryForVm: method: get - resourcePath: /api/o11y/monitoring/influxdb - description: "" + resourcePath: /api/o11y/insight/anomaly-detection/ns/{nsId}/mci/{mciId}/vm/{vmId}/history + description: "getAnomalyHistoryForVm" + GetAnomalyHistoryForMci: + method: get + resourcePath: /api/o11y/insight/anomaly-detection/ns/{nsId}/mci/{mciId}/history + description: "getAnomalyHistoryForMci" + GetMeasurements: + method: get + resourcePath: /api/o11y/insight/anomaly-detection/measurement + description: "getMeasurements" + GetSpecificMeasurement: + method: get + resourcePath: /api/o11y/insight/anomaly-detection/measurement/{measurement} + description: "getSpecificMeasurement" + DeleteAllLLMChatSessions: + method: delete + resourcePath: /api/o11y/insight/llm/sessions + description: "deleteAllLLMChatSessions" + DeleteLLMApiKeys: + method: delete + resourcePath: /api/o11y/insight/llm/api-Keys + description: "deleteLLMApiKeys" mc-application-manager: GetCatalogDetailUsingGET: diff --git a/front/assets/js/common/api/services/monitoring_api.js b/front/assets/js/common/api/services/monitoring_api.js index acc2c603..cffa9f6a 100644 --- a/front/assets/js/common/api/services/monitoring_api.js +++ b/front/assets/js/common/api/services/monitoring_api.js @@ -5,52 +5,67 @@ export async function getPlugIns() { controller, ) - var respMeasureMent = response.data.responseData; + var respMeasurement = response.data.responseData; - return respMeasureMent + return respMeasurement } catch (error) { console.error("Error occurred while getting plugins:", error); throw error; } } -export async function getInfluxDBMetrics(measurement, range, vmId) { +export async function getMeasurementFields() { + try { + var controller = "/api/" + "mc-observability/" + "GetMeasurementFields"; + const response = await webconsolejs["common/api/http"].commonAPIPost( + controller, + ) - const data = { + var respMeasurementFields = response.data.responseData; + + return respMeasurementFields + } catch (error) { + console.error("Error occurred while getting measurement fields:", error); + throw error; + } +} +export async function getInfluxDBMetrics(measurement, metric, range, period, nsId, mciId, vmId) { + const data = { + pathParams: { + nsId: nsId, + mciId: mciId, + vmId: vmId, + }, Request: { "measurement": measurement, - // "measurement": "cpu", "range": range, - // "range": "1h", - "group_time": "3h", + "group_time": period, "group_by": [ - "target_id" - // "cpu" + "vm_id" ], - "limit": 10, + "limit": 20, "fields": [ { "function": "mean", - "field": "usage_idle" + "field": metric } ], "conditions": [ - { - "key": "target_id", - "value": vmId - } + // { + // "key": "cpu", + // "value": "cpu-total" + // } ] } } - // var controller = "/api/" + "mc-observability/" + "GETInfluxDBMetrics"; - var controller = "/api/" + "mc-observability/" + "GETInfluxDBMetrics"; + var controller = "/api/" + "mc-observability/" + "GetMetricsByVMId"; const response = webconsolejs["common/api/http"].commonAPIPost( controller, data ); - if (!response) { + if (!response) { // Return CPU dummy data if not available return { "responseData": { "data": [ @@ -304,52 +319,17 @@ export async function monitoringPrediction() { } // Log 조회. -// limit : 가져올 row 갯수 -// range : ?? -// conditions : -// key:"tag.ns_id", value:"" -> value는 선택된 nsId -// key:"tag.mci_id", value:"" -> value는 선택된 mciId -// key:"tag.target_id", value:"" -> value는 선택된 vmId - -// key:"tail.message", value:"" -> value는 filter하고자 하는 keyword -export async function getMonitoringLog(nsId, mciId, targetId, keyword) { - //GET_OpensearchLogs - - const data = {} - let request = {} - let conditions = new Array(); - if (nsId != "") { - let aCondition = {} - aCondition.key = "tag.ns_id"; - aCondition.value = nsId; - conditions.push(aCondition) - } - if (mciId != "") { - let aCondition = {} - aCondition.key = "tag.mci_id"; - aCondition.value = mciId; - conditions.push(aCondition) - } - if (targetId != "") { - let aCondition = {} - aCondition.key = "tag.target_id"; - aCondition.value = targetId; - conditions.push(aCondition) - } - if (keyword != "") { - let aCondition = {} - aCondition.key = "tail.message"; - aCondition.value = keyword - conditions.push(aCondition) +export async function getMonitoringLog(nsId, mciId, vmId, keyword) { + var query = "{NS_ID=\"" + nsId + "\", MCI_ID=\"" + mciId + "\", VM_ID=\"" + vmId + "\"} |~ \"(?i)" + keyword + "\"" + const data = { + queryParams: { + "query": query, + "limit": "20", + }, } - //request.range = "" - request.limit = 100; - request.conditions = conditions; - data.request = request; - - var controller = "/api/" + "mc-observability/" + "GETOpensearchLogs"; + var controller = "/api/" + "mc-observability/" + "LogRangeQuery"; const response = await webconsolejs["common/api/http"].commonAPIPost( controller, data @@ -416,9 +396,9 @@ export async function getDetectionHistory() { } // 모니터링 Agent가 설치된 vm 목록 by ns, mci -export async function getTargetsNsMci(nsId, mciId) { +export async function getVMByNsMci(nsId, mciId) { - var controller = "/api/" + "mc-observability/" + "GetTargetsNSMCI"; + var controller = "/api/" + "mc-observability/" + "GetVMByNsMci"; let data = { pathParams: { nsId: nsId, @@ -437,13 +417,13 @@ export async function getTargetsNsMci(nsId, mciId) { } export async function InstallMonitoringAgent(nsId, mciId, vmId){ - var controller = "/api/" + "mc-observability/" + "PostTarget"; + var controller = "/api/" + "mc-observability/" + "PostVM"; let data = { pathParams: { nsId: nsId, mciId: mciId, - targetId: vmId, + vmId: vmId, }, request: { name:vmId @@ -460,7 +440,7 @@ export async function InstallMonitoringAgent(nsId, mciId, vmId){ } export async function UninstallMonitoringAgent(nsId, mciId, vmId){ - var controller = "/api/" + "mc-observability/" + "DeleteTarget"; + var controller = "/api/" + "mc-observability/" + "DeleteVM"; let data = { pathParams: { @@ -479,14 +459,14 @@ export async function UninstallMonitoringAgent(nsId, mciId, vmId){ } -export async function GetMonitoringTarget(nsId, mciId, vmId){ - var controller = "/api/" + "mc-observability/" + "Gettarget"; +export async function GetMonitoringVM(nsId, mciId, vmId){ + var controller = "/api/" + "mc-observability/" + "GetVM"; let data = { pathParams: { nsId: nsId, mciId: mciId, - targetId: vmId, + vmId: vmId, }, }; @@ -500,13 +480,13 @@ export async function GetMonitoringTarget(nsId, mciId, vmId){ } export async function GetMetricitems(nsId, mciId, vmId){ - var controller = "/api/" + "mc-observability/" + "Getitems"; + var controller = "/api/" + "mc-observability/" + "GetMonitoringItems"; let data = { pathParams: { nsId: nsId, mciId: mciId, - targetId: vmId, + vmId: vmId, }, }; diff --git a/front/assets/js/pages/operation/analytics/logmanage.js b/front/assets/js/pages/operation/analytics/logmanage.js index 19c26d49..431cf63a 100644 --- a/front/assets/js/pages/operation/analytics/logmanage.js +++ b/front/assets/js/pages/operation/analytics/logmanage.js @@ -246,72 +246,53 @@ function initLogTable() { }, { title: "NS", - field: "tag", - formatter: tagNsIdFormatter, + field: "labels", + formatter: labelsNsIdFormatter, vertAlign: "middle" }, { title: "MCI", - field: "tag", - formatter: tagMciIdFormatter, + field: "labels", + formatter: labelsMciIdFormatter, vertAlign: "middle" }, { - title: "Target", - field: "tag", - formatter: tagTargetIdFormatter, + title: "VM", + field: "labels", + formatter: labelsVMIdFormatter, vertAlign: "middle" }, { title: "Host", - field: "tail", - formatter: tailHostFormatter, - vertAlign: "middle" - }, - { - title: "PID", - field: "tail", - formatter: tailPidFormatter, - vertAlign: "middle" - }, - { - title: "Program", - field: "tail", - formatter: tailprogramFormatter, + field: "labels", + formatter: labelsHostFormatter, vertAlign: "middle" }, { title: "Timestamp", - field: "tail", - formatter: tailTimestampFormatter, + field: "timestamp", vertAlign: "middle" }, { - title: "Message", - field: "tail", - formatter: tailMessageFormatter, + title: "Value", + field: "value", vertAlign: "middle" - }, + } ]; - // { - // "@timestamp": "2024-10-18T08:41:22.820224306Z", - // measurement_name: "tail", - // tag: { - // host: "2ebc9c59f973", - // mci_id: "mc-o11y", - // ns_id: "", - // path: "/var/log/syslog", - // target_id: "mc-o11y" - // }, - // tail: { - // host: "o11y", - // message: "[httpd] 40.82.137.29 - mc-agent [18/Oct/2024:08:41:22 +0000] \"POST /write?db=mc-observability&rp=autogen HTTP/1.1 \" 204 0 \"-\" \"Telegraf/1.29.5 Go/1.22.0\" c103937f-8d2c-11ef-8867-0242ac130009 11023", - // pid: "886", - // program: "mc-o11y-influx", - // timestamp: "Oct 18 08:41:22" - // } - // } + // { + // "labels": { + // "MCI_ID": "mci01", + // "NS_ID": "test01", + // "VM_ID": "vm-1", + // "host": "d4127tlb7ccc738sedbg", + // "level": "UNKNOWN", + // "service": "systemd", + // "source": "syslog" + // }, + // "timestamp": 1.761802223E18, + // "value": "{\"level\":\"UNKNOWN\",\"pid\":\"1\",\"filename\":\"syslog\",\"source\":\"syslog\",\"host\":\"d4127tlb7ccc738sedbg\",\"time\":\"Oct 30 14:30:23\",\"message\":\"Finished system activity accounting tool.\",\"service\":\"systemd\"}" + // } logListTable = setLogTabulator("loglist-table", tableObjParams, columns, true); // 행 클릭 시 @@ -324,47 +305,21 @@ function initLogTable() { }); } -// tag와 tail에 모두 host가 있어 function name에 prefix를 줌. -function tagHostFormatter(cell) { - var row = cell.getData() - return row.tag.host; -} -function tagNsIdFormatter(cell) { - var row = cell.getData() - return row.tag.ns_id; -} -function tagMciIdFormatter(cell) { - var row = cell.getData() - return row.tag.mci_id; -} -function tagTargetIdFormatter(cell) { - var row = cell.getData() - return row.tag.target_id; -} -function tagPathFormatter(cell) { - var row = cell.getData() - return row.tag.path; -} - -function tailHostFormatter(cell) { +function labelsHostFormatter(cell) { var row = cell.getData() - return row.tail.host; + return row.labels.host; } -function tailPidFormatter(cell) { +function labelsNsIdFormatter(cell) { var row = cell.getData() - return row.tail.pid; + return row.labels.NS_ID; } -function tailprogramFormatter(cell) { +function labelsMciIdFormatter(cell) { var row = cell.getData() - return row.tail.program; + return row.labels.MCI_ID; } -function tailTimestampFormatter(cell) { +function labelsVMIdFormatter(cell) { var row = cell.getData() - return row.tail.timestamp; -} -function tailMessageFormatter(cell) { - var row = cell.getData() - return row.tail.message; + return row.labels.VM_ID; } // toggleSelectBox of table row @@ -424,13 +379,13 @@ export async function getCollectedLog() { var selectedMciId = $("#log_mcilist").val(); var selectedVmId = $("#log_targetlist").val(); var keyword = $("#keyword").val(); - + // 선택 검증 if (!selectedMciId) { alert("Please select a Workload"); return; } - + if (!selectedVmId) { alert("Please select a Server"); return; @@ -440,42 +395,45 @@ export async function getCollectedLog() { selectedWorkspaceProject = await webconsolejs["partials/layout/navbar"].workspaceProjectInit(); var selectedNsId = selectedWorkspaceProject.nsId; - // 실제 API 호출 (현재는 주석 처리되어 있음) - // try{ - // var response = await webconsolejs["common/api/services/monitoring_api"].getMonitoringLog(selectedNsId, selectedMciId, selectedVmId, keyword); - // getLogListCallbackSuccess(response.data.responseData) - // }catch(e){ - - // 임시 데이터 (실제 API 연동 시 제거) - const dataObject = { - data: [ - { - "@timestamp": "2024-11-06T08:41:22.820224306Z", - measurement_name: "tail", - tag: { - host: "2ebc9c59f973", - mci_id: selectedMciId, - ns_id: selectedNsId, - path: "/var/log/syslog", - target_id: selectedVmId - }, - tail: { - host: "o11y", - message: keyword ? `[Filtered by keyword: ${keyword}] [httpd] 40.82.137.29 - mc-agent [18/Oct/2024:08:41:22 +0000] "POST /write?db=mc-observability&rp=autogen HTTP/1.1 " 204 0 "-" "Telegraf/1.29.5 Go/1.22.0" c103937f-8d2c-11ef-8867-0242ac130009 11023` : "[httpd] 40.82.137.29 - mc-agent [18/Oct/2024:08:41:22 +0000] \"POST /write?db=mc-observability&rp=autogen HTTP/1.1 \" 204 0 \"-\" \"Telegraf/1.29.5 Go/1.22.0\" c103937f-8d2c-11ef-8867-0242ac130009 11023", - pid: "886", - program: "mc-o11y-influx", - timestamp: "Nov 06 08:41:22" - } - } - ] - }; - getLogListCallbackSuccess(dataObject.data) - // } + try{ + console.log("Fetching log data...", { nsId: selectedNsId, mciId: selectedMciId, vmId: selectedVmId, keyword: keyword }); + var response = await webconsolejs["common/api/services/monitoring_api"].getMonitoringLog(selectedNsId, selectedMciId, selectedVmId, keyword); + + console.log("Full response:", response); + console.log("Response data:", response.data); + console.log("Response data.responseData:", response.data?.responseData); + + if (response && response.data && response.data.responseData && response.data.responseData.data && response.data.responseData.data.data) { + getLogListCallbackSuccess(response.data.responseData.data.data); + } else { + console.error("Invalid response structure:", response); + alert("Failed to load log data: Invalid response structure"); + } + }catch(e){ + console.error("Error fetching log data:", e); + alert("Error fetching log data: " + e.message); + } } function getLogListCallbackSuccess(logList) { - logListTable.setData(logList); + console.log("Setting table data:", logList); + console.log("Is logList an array?", Array.isArray(logList)); + console.log("logList length:", logList?.length); + + if (!logList) { + console.error("logList is null or undefined"); + alert("No log data available"); + return; + } + if (!Array.isArray(logList)) { + console.error("logList is not an array:", typeof logList); + alert("Invalid log data format"); + return; + } + + logListTable.setData(logList); + console.log("Table data set successfully"); } async function getSelectedLogData(selectedLogData) { diff --git a/front/assets/js/pages/operation/analytics/monitoringconfig.js b/front/assets/js/pages/operation/analytics/monitoringconfig.js index cedd561b..541a67e6 100644 --- a/front/assets/js/pages/operation/analytics/monitoringconfig.js +++ b/front/assets/js/pages/operation/analytics/monitoringconfig.js @@ -90,10 +90,6 @@ var currentServernodeId = "-1"; var monitorConfigListTable; var monitorMetricsTable; var editMetricsModalTable; -var monitorLogTraceTable; -var editLogCollectorModalTable; -var monitorStoragesTable; -var editStorageModalTable; //DOMContentLoaded 는 Page에서 1개만. // init + 파일명 () : ex) initMci() 를 호출하도록 한다. @@ -124,10 +120,6 @@ async function initMonitorConfig() { initMonitorConfigTable(); initMonitorMetricsTable(); initEditMetricsModalTable(); - initmonitorLogTraceTable(); - initEditLogCollectorModalTable(); - initMonitorStoragesTable(); - initEditStorageModalTable(); } // workload 목록 조회 ( mci + pmk ) @@ -166,32 +158,39 @@ $("#workloadlist").on('change', async function () { var aVm = aMci.vm[vmIndex] aVm.workloadType = "MCI"; // [MCI/PMK] aVm.workloadName = currentWorkloadName; - aVm.monAgentStatus = "Not Installed"; + aVm.monitoringAgentStatus = "Not Installed"; + aVm.logAgentStatus = "Not Installed"; vmMap.set(aVm.id, aVm); } // 2. mci에 agent 설치된 목록 조회 - var monitorTargetList = await webconsolejs["common/api/services/monitoring_api"].getTargetsNsMci(currentNsId, currentWorkloadId) + var monitorTargetList = await webconsolejs["common/api/services/monitoring_api"].getVMByNsMci(currentNsId, currentWorkloadId) for (var i in monitorTargetList.data) { // [ // { - // "alias_name": null, - // "description": "dm0x", - // "id": "vm-1", - // "mci_id": "mci01", - // "name": null, - // "ns_id": "ns01", - // "state": "ACTIVE" + // "description": "Created via CB-Tumblebug", + // "log_agent_status": "SUCCESS", + // "mci_id": "mci01", + // "monitoring_agent_status": "SUCCESS", + // "name": "vm-1", + // "ns_id": "test01", + // "vm_id": "vm-1" // } // ] - var findVm = vmMap.get(monitorTargetList.data[i].id) + var findVm = vmMap.get(monitorTargetList.data[i].vm_id) if(findVm){ - // state가 null인 경우 ACTIVE로 처리 - var agentState = monitorTargetList.data[i].state; - if(agentState === null || agentState === undefined) { - agentState = "ACTIVE"; + // monitoringAgentStatus가 null인 경우 FAILED로 처리 + var monitoringAgentStatus = monitorTargetList.data[i].monitoring_agent_status; + if(monitoringAgentStatus === null || monitoringAgentStatus === undefined) { + monitoringAgentStatus = "FAILED"; } - findVm.monAgentStatus = agentState; // [ACTIVE/INACTIVE] - vmMap.set(findVm.id, findVm); + findVm.monitoringAgentStatus = monitoringAgentStatus; // [INSTALLING/SERVICE_INACTIVE/SUCCESS/FAILED] + + // logAgentStatus가 null인 경우 FAILED로 처리 + var logAgentStatus = monitorTargetList.data[i].log_agent_status; + if(logAgentStatus === null || logAgentStatus === undefined) { + logAgentStatus = "FAILED"; + } + findVm.logAgentStatus = logAgentStatus; // [INSTALLING/SERVICE_INACTIVE/SUCCESS/FAILED] } } }catch(e){ @@ -225,6 +224,7 @@ function initMonitorConfigTable() { vertAlign: "middle", hozAlign: "center", headerSort: false, + width: 80, }, { title: "Workload", @@ -252,36 +252,20 @@ function initMonitorConfigTable() { // visible: true // }, { - title: "Agent Status", - field: "monAgentStatus", + title: "Monitoring Agent Status", + field: "monitoringAgentStatus", vertAlign: "middle", hozAlign: "center", - width: 120, - }, - { - title: "Collect Status", - field: "collectStatus", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center", - maxWidth: 150, + width: 180, }, { - title: "Collect datetime", - field: "collectDatetime", + title: "Log Agent Status", + field: "logAgentStatus", vertAlign: "middle", hozAlign: "center", headerHozAlign: "center", - maxWidth: 150, - }, - { - title: "Log/Treace", - field: "logTrace", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center", - maxWidth: 135, - }, + width: 160, + } ]; monitorConfigListTable = setTabulator("monitorconfiglist-table", tableObjParams, columns, true); @@ -312,9 +296,9 @@ function initMonitorConfigTable() { monitorConfigListTable.on("cellClick", function(e, cell){ var field = cell.getField(); - if(field == "monAgentStatus"){ + if(field == "monitoringAgentStatus" || field == "logAgentStatus"){ var agentStatus = cell.getValue(); - if(agentStatus != "ACTIVE" && agentStatus != "INACTIVE"){ + if(agentStatus != "SUCCESS" && agentStatus != "INSTALLING"){ var targetVmId = cell.getRow().getData().id; var targetModal = "commonDefaultModal"; var modalTitle = "MonitoringAgentInstall" @@ -342,8 +326,9 @@ export function installMonitoringAgent(vmId){ response.then(() => { // 선택된 서버 노드의 상태 업데이트 if (selectedServerNode && selectedServerNode.id === vmId) { - selectedServerNode.monAgentStatus = "ACTIVE"; - + selectedServerNode.monitoringAgentStatus = "INSTALLING"; + selectedServerNode.logAgentStatus = "INSTALLING"; + // UI 업데이트 setMonitorConfigInfoData(); @@ -351,7 +336,8 @@ export function installMonitoringAgent(vmId){ var tableData = monitorConfigListTable.getData(); var updatedData = tableData.map(row => { if (row.id === vmId) { - row.monAgentStatus = "ACTIVE"; + row.monitoringAgentStatus = "INSTALLING"; + row.logAgentStatus = "INSTALLING"; } return row; }); @@ -379,21 +365,21 @@ function initMonitorMetricsTable() { }, { title: "Server Name/Id", - field: "target_id", + field: "vmId", vertAlign: "middle", hozAlign: "center", headerHozAlign: "center" }, { - title: "Plugin name", - field: "plugin_name", + title: "Plugin seq", + field: "pluginSeq", vertAlign: "middle", hozAlign: "center", headerHozAlign: "center" }, { - title: "Plugin seq", - field: "plugin_seq", + title: "Plugin name", + field: "pluginName", vertAlign: "middle", hozAlign: "center", headerHozAlign: "center" @@ -413,7 +399,7 @@ function initMonitorMetricsTable() { monitorMetricsTable = setTabulator("monitorMetricsTable", tableObjParams, columns, true); // 행 클릭 시 - monitorMetricsTable.on("rowClick", function (e, row) { + monitorConfigListTable.on("rowClick", function (e, row) { }); monitorMetricsTable.on("cellClick", function(e, cell){ @@ -440,7 +426,6 @@ function decodeBase64(data) { return atob(data); } - function initEditMetricsModalTable() { var tableObjParams = {}; @@ -484,10 +469,10 @@ function initEditMetricsModalTable() { editMetricsModalTable.on("cellClick", function(e, cell){ // var field = cell.getField(); - // if(field == "monAgentStatus"){ + // if(field == "monitoringAgentStatus" || field == "logAgentStatus"){ // var agentStatus = cell.getValue(); // console.log("agentStatus", agentStatus) - // if(agentStatus != "ACTIVE" && agentStatus != "INACTIVE"){ + // if(agentStatus != "SUCCESS" && agentStatus != "INSTALLING"){ // console.log("Row data:", cell.getRow().getData()); // console.log("id data:", cell.getRow().getData().id); // var targetVmId = cell.getRow().getData().id; @@ -506,223 +491,6 @@ function initEditMetricsModalTable() { }); } -function initmonitorLogTraceTable() { - - var tableObjParams = {}; - - var columns = [ - { - formatter: "rowSelection", - titleFormatter: "rowSelection", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center", - headerSort: false, - width: 60, - }, - { - title: "seq", - field: "seq", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center" - }, - { - title: "Server Name/Id", - field: "Server Name/Id", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center" - }, - { - title: "Plugin name", - field: "Plugin name", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center" - }, - { - title: "Plugin seq", - field: "Plugin seq", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center" - }, - { - title: "Plugin Config", - field: "Plugin Config", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center" - } - ]; - - monitorLogTraceTable = setTabulator("monitorLogTraceTable", tableObjParams, columns, true); - - // 행 클릭 시 - monitorLogTraceTable.on("rowClick", function (e, row) { - }); - - monitorLogTraceTable.on("cellClick", function(e, cell){ - }); - - // TODO : 선택된 여러개 row에 대해 처리 - monitorLogTraceTable.on("rowSelectionChanged", function (data, rows) { - - }); -} - -function initEditLogCollectorModalTable() { - - var tableObjParams = {}; - - var columns = [ - { - formatter: "rowSelection", - titleFormatter: "rowSelection", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center", - headerSort: false, - width: 60, - }, - { - title: "Target Item", - field: "Target Item", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center" - }, - { - title: "Description", - field: "Description", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center" - } - ]; - - editLogCollectorModalTable = setTabulator("editLogCollectorModalTable", tableObjParams, columns, true); - - // 행 클릭 시 - editLogCollectorModalTable.on("rowClick", function (e, row) { - }); - - editLogCollectorModalTable.on("cellClick", function(e, cell){ - }); - - // TODO : 선택된 여러개 row에 대해 처리 - editLogCollectorModalTable.on("rowSelectionChanged", function (data, rows) { - - }); -} - -function initMonitorStoragesTable() { - - var tableObjParams = {}; - - var columns = [ - { - formatter: "rowSelection", - titleFormatter: "rowSelection", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center", - headerSort: false, - width: 60, - }, - { - title: "Server Name/Id", - field: "Server Name/Id", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center" - }, - { - title: "Plugin Name", - field: "Plugin Name", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center" - }, - { - title: "Plugin seq", - field: "Plugin seq", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center" - }, - { - title: "Plugin Config", - field: "Plugin Config", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center" - } - ]; - - monitorStoragesTable = setTabulator("monitorStoragesTable", tableObjParams, columns, true); - - // 행 클릭 시 - monitorStoragesTable.on("rowClick", function (e, row) { - }); - - monitorStoragesTable.on("cellClick", function(e, cell){ - }); - - // TODO : 선택된 여러개 row에 대해 처리 - monitorStoragesTable.on("rowSelectionChanged", function (data, rows) { - - }); -} - -function initEditStorageModalTable() { - - var tableObjParams = {}; - - var columns = [ - { - formatter: "rowSelection", - titleFormatter: "rowSelection", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center", - headerSort: false, - width: 60, - }, - { - title: "Storage name", - field: "Storage name", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center" - }, - { - title: "Description", - field: "Description", - vertAlign: "middle", - hozAlign: "center", - headerHozAlign: "center" - } - ]; - - editStorageModalTable = setTabulator("editStorageModalTable", tableObjParams, columns, true); - - // 행 클릭 시 - editStorageModalTable.on("rowClick", function (e, row) { - }); - - editStorageModalTable.on("cellClick", function(e, cell){ - }); - - // TODO : 선택된 여러개 row에 대해 처리 - editStorageModalTable.on("rowSelectionChanged", function (data, rows) { - - }); -} - - - // 클릭한 monitor config info 가져오기 // 표에서 선택된 MonitorConfigId 받아옴 function getSelectedMonitorConfigData(servernodeId) { @@ -753,21 +521,19 @@ async function setMonitorConfigInfoData() { $(htmlCardIdPrefix+"name").text(selectedServerNode.name+" / "+selectedServerNode.id) $(htmlCardIdPrefix+"desc").text(selectedServerNode.description) $(htmlCardIdPrefix+"workload").text(selectedServerNode.workloadType+" / "+selectedServerNode.workloadName) - $(htmlCardIdPrefix+"monitor").html(generateOnOffIndicator(selectedServerNode.monAgentStatus === "ACTIVE" ? true : false)) - $(htmlCardIdPrefix+"agent_status").html(generateStatusIndicator(selectedServerNode.monAgentStatus === "ACTIVE" ? "success" : "danger", selectedServerNode.monAgentStatus)) - if (selectedServerNode.collectStatus) { - $(htmlCardIdPrefix+"collect_status").html(generateStatusIndicator(selectedServerNode.collectStatus === "ACTIVE" ? "success" : "danger", selectedServerNode.collectStatus)) - } else { - $(htmlCardIdPrefix+"collect_status").html(""); - } + $(htmlCardIdPrefix+"monitor").html(generateOnOffIndicator(selectedServerNode.monitoringAgentStatus === "SUCCESS" && selectedServerNode.logAgentStatus === "SUCCESS" ? true : false)) + $(htmlCardIdPrefix+"monitoring_agent_status").html(generateStatusIndicator(selectedServerNode.logAgentStatus === "SUCCESS" ? "success" : "danger", selectedServerNode.monitoringAgentStatus)) + $(htmlCardIdPrefix+"log_agent_status").html(generateStatusIndicator(selectedServerNode.logAgentStatus === "SUCCESS" ? "success" : "danger", selectedServerNode.monitoringAgentStatus)) // 토글 박스 이벤트 리스너 추가 $(htmlCardIdPrefix+"monitor input[type='checkbox']").off('change').on('change', function() { var isChecked = $(this).is(':checked'); - var currentAgentStatus = selectedServerNode.monAgentStatus; + var currentMonitoringAgentStatus = selectedServerNode.monitoringAgentStatus; + var currentLogAgentStatus = selectedServerNode.logAgentStatus; // 토글 ON 시: 에이전트가 설치되지 않은 경우 설치 모달 표시 - if (isChecked && currentAgentStatus !== "ACTIVE" && currentAgentStatus !== "INACTIVE") { + if (isChecked && currentMonitoringAgentStatus !== "SUCCESS" && currentMonitoringAgentStatus !== "INSTALLING" && + currentLogAgentStatus !== "SUCCESS" && currentLogAgentStatus !== "INSTALLING") { var targetVmId = selectedServerNode.id; var targetModal = "commonDefaultModal"; var modalTitle = "MonitoringAgentInstall"; diff --git a/front/assets/js/pages/operation/manage/monitoring.js b/front/assets/js/pages/operation/manage/monitoring.js index 7fc7519d..e28d8964 100644 --- a/front/assets/js/pages/operation/manage/monitoring.js +++ b/front/assets/js/pages/operation/manage/monitoring.js @@ -150,7 +150,12 @@ $("#monitoring_serverlist").on('change', async function () { var selectedNsId = selectedWorkspaceProject.nsId; setMonitoringMesurement() +}) + +$("#monitoring_measurement").on('change', async function () { + var selectedMeasurement = $("#monitoring_measurement").val(); + setMonitoringMetric(selectedMeasurement) }) // Extend Detection 토글 이벤트 리스너 @@ -195,7 +200,7 @@ async function setMonitoringMesurement() { if (Array.isArray(data) && data.length > 0) { data.forEach(function (item) { - if (item.plugin_type === "INPUT") { + if (item.pluginType === "INPUT") { var option = document.createElement("option"); option.value = item.name || item.pluginId; option.text = item.name || item.pluginId; @@ -208,11 +213,78 @@ async function setMonitoringMesurement() { } } +async function setMonitoringMetric(selectedMeasurement) { + try { + var respMeasurementFields = await webconsolejs["common/api/services/monitoring_api"].getMeasurementFields(); + + // API 응답 구조 확인 및 데이터 추출 + var data; + if (respMeasurementFields && respMeasurementFields.responseData && respMeasurementFields.responseData.data) { + data = respMeasurementFields.responseData.data; + } else if (respMeasurementFields && respMeasurementFields.data) { + data = respMeasurementFields.data; + } else if (respMeasurementFields && Array.isArray(respMeasurementFields)) { + data = respMeasurementFields; + } else { + console.error("Unexpected API response structure:", respMeasurementFields); + data = []; + } + + var metricSelect = document.getElementById("monitoring_metric"); + + if (!metricSelect) { + console.error("monitoring_metric element not found."); + return; + } + + metricSelect.innerHTML = ""; + + var defaultOption = document.createElement("option"); + defaultOption.value = ""; + defaultOption.text = "Select"; + metricSelect.appendChild(defaultOption); + + if (Array.isArray(data) && data.length > 0) { + data.forEach(function (measurement) { + if (measurement.measurement === selectedMeasurement) { + measurement.fields.forEach(function (field) { + var option = document.createElement("option"); + option.value = field.key; + option.text = field.key; + metricSelect.appendChild(option); + }); + } + }); + } + } catch (error) { + console.error("setMonitoringMetric 오류:", error); + } +} + export async function startMonitoring() { + selectedWorkspaceProject = await webconsolejs["partials/layout/navbar"].workspaceProjectInit(); + var selectedNsId = selectedWorkspaceProject.nsId; + + // NS가 선택되지 않은 경우 처리 + if (!selectedNsId) { + alert("Please select a Workspace first."); + return; + } + + var selectedMci = $("#monitoring_mcilist").val() + + // MCI가 선택되지 않은 경우 처리 + if (!selectedNsId) { + alert("Please select a Workload first."); + return; + } + var selectedMeasurement = $("#monitoring_measurement").val(); + var selectedMetric = $("#monitoring_metric").val(); var selectedRange = $("#monitoring_range").val(); + var selectedPeriod = $("#monitoring_period").val(); var selectedVMId = $("#monitoring_serverlist").val(); - + // VM이 선택되지 않은 경우 처리 if (!selectedVMId) { alert("Please select a VM first."); @@ -225,7 +297,7 @@ export async function startMonitoring() { $("#selected_vm_name").text("(" + selectedVMName + ")"); } - var response = await webconsolejs["common/api/services/monitoring_api"].getInfluxDBMetrics(selectedMeasurement, selectedRange, selectedVMId); + var response = await webconsolejs["common/api/services/monitoring_api"].getInfluxDBMetrics(selectedMeasurement, selectedMetric, selectedRange, selectedPeriod, selectedNsId, selectedMci, selectedVMId); // 응답 데이터의 구조를 검증 if (response && response.responseData && response.responseData.data) { @@ -242,26 +314,24 @@ async function drawMonitoringGraph(MonitoringData) { // MonitoringData.data가 존재하는지 확인 if (MonitoringData && Array.isArray(MonitoringData)) { - MonitoringData.forEach(cpuData => { - if (["cpu0", "cpu1", "cpu2", "cpu3"].includes(cpuData.tags.cpu)) { - const seriesData = { - name: cpuData.tags.cpu, - data: cpuData.values - .map(value => ({ - x: value[0], // timestamp - y: value[1] !== null ? parseFloat(value[1]).toFixed(2) : null - })) - .filter(point => point.y !== null) - }; - chartDataList.push(seriesData); - - cpuData.values.forEach(value => { - const timestamp = value[0]; - if (!chartLabels.includes(timestamp)) { - chartLabels.push(timestamp); - } - }); - } + MonitoringData.forEach(data => { + const seriesData = { + name: data.name, + data: data.values + .map(value => ({ + x: value[0], // timestamp + y: value[1] !== null ? parseFloat(value[1]).toFixed(2) : null + })) + .filter(point => point.y !== null) + }; + chartDataList.push(seriesData); + + data.values.forEach(value => { + const timestamp = value[0]; + if (!chartLabels.includes(timestamp)) { + chartLabels.push(timestamp); + } + }); }); } else { console.error("MonitoringData is invalid or does not contain data:", MonitoringData); diff --git a/front/templates/pages/operations/analytics/monitorings/mcismonitoring.html b/front/templates/pages/operations/analytics/monitorings/mcismonitoring.html index 95b26108..9d86efee 100644 --- a/front/templates/pages/operations/analytics/monitorings/mcismonitoring.html +++ b/front/templates/pages/operations/analytics/monitorings/mcismonitoring.html @@ -41,10 +41,10 @@

Monitoring Trend / Workload

- -
@@ -77,11 +77,18 @@

Monitoring Trend / Workload

- - + + + + + + +
diff --git a/front/templates/partials/operations/analytics/monitorings/_monitoringconfig_detail.html b/front/templates/partials/operations/analytics/monitorings/_monitoringconfig_detail.html index 572f9a99..3bfed814 100644 --- a/front/templates/partials/operations/analytics/monitorings/_monitoringconfig_detail.html +++ b/front/templates/partials/operations/analytics/monitorings/_monitoringconfig_detail.html @@ -40,25 +40,18 @@
Monitor
-
Agent Status
+
Monitoring Agent Status
-
+
-
Collect Status
+
Log Agent Status
-
-
- -
-
-
Collect datetime
-
-
+
@@ -71,22 +64,8 @@
Monitor Metrics
-
- -
- -
- - -
-
-
Log
-
-
-
- \ No newline at end of file diff --git a/front/templates/partials/operations/analytics/monitorings/_monitoringconfig_log.html b/front/templates/partials/operations/analytics/monitorings/_monitoringconfig_log.html deleted file mode 100644 index e01d23b8..00000000 --- a/front/templates/partials/operations/analytics/monitorings/_monitoringconfig_log.html +++ /dev/null @@ -1,69 +0,0 @@ -
-

- Monitor Log & Trace / Server(vm) - -

-
- -
- -
-
- - - - -
-
-
- -
-
-
-
-
- - - \ No newline at end of file diff --git a/front/templates/partials/operations/analytics/monitorings/_monitoringconfigtab_monitorStorages.html b/front/templates/partials/operations/analytics/monitorings/_monitoringconfigtab_monitorStorages.html deleted file mode 100644 index 391205b7..00000000 --- a/front/templates/partials/operations/analytics/monitorings/_monitoringconfigtab_monitorStorages.html +++ /dev/null @@ -1,113 +0,0 @@ -
-

- Monitor Storages / Server(vm) - -

-
- -
- -
-
- - - - - - - - -
-
-
- -
-
-
-
-
- - diff --git a/front/templates/partials/operations/analytics/monitorings/_monitoringconfigtabcards.html b/front/templates/partials/operations/analytics/monitorings/_monitoringconfigtabcards.html index 8c98b732..8193c7dc 100644 --- a/front/templates/partials/operations/analytics/monitorings/_monitoringconfigtabcards.html +++ b/front/templates/partials/operations/analytics/monitorings/_monitoringconfigtabcards.html @@ -11,12 +11,6 @@ - -
@@ -28,14 +22,6 @@
<%= partial("partials/operations/analytics/monitorings/monitoringconfig_metric.html") %>
- -
- <%= partial("partials/operations/analytics/monitorings/monitoringconfig_log.html") %> -
- -
- <%= partial("partials/operations/analytics/monitorings/monitoringconfigtab_monitorStorages.html") %> -