From b69a4a44d2d764fe4ad2aa9e80d507c0f77c1b5b Mon Sep 17 00:00:00 2001 From: Giuseppe-La-Manna Date: Fri, 3 Jan 2025 16:04:10 +0100 Subject: [PATCH 1/3] P4PU-694 added graphic on dashboard opex --- .../workbooks/OPEXWorkbook.json.tpl | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/06_domains/cittadini-app/workbooks/OPEXWorkbook.json.tpl b/src/06_domains/cittadini-app/workbooks/OPEXWorkbook.json.tpl index cebe34a..99c4cce 100644 --- a/src/06_domains/cittadini-app/workbooks/OPEXWorkbook.json.tpl +++ b/src/06_domains/cittadini-app/workbooks/OPEXWorkbook.json.tpl @@ -105,11 +105,38 @@ "version": "NotebookGroup/1.0", "groupType": "editable", "items": [ + { + "type": 9, + "content": { + "version": "KqlParameterItem/1.0", + "parameters": [ + { + "id": "180832b5-b7a9-41ba-bde0-95a9a072b3b3", + "version": "KqlParameterItem/1.0", + "name": "origin", + "type": 2, + "isRequired": true, + "typeSettings": { + "additionalResourceOptions": [], + "showDefault": false + }, + "jsonData": "[\r\n {\"label\":\"APIM\",\"value\":\"apim\",\"selected\": true},\r\n {\"label\":\"internal\",\"value\":\"internal\",\"selected\": true}\r\n]", + "timeContext": { + "durationMs": 86400000 + } + } + ], + "style": "pills", + "queryType": 0, + "resourceType": "microsoft.operationalinsights/workspaces" + }, + "name": "parameters - 4" + }, { "type": 3, "content": { "version": "KqlItem/1.0", - "query": "let startTime = {timeRangeOverall:start};\nlet endTime = {timeRangeOverall:end};\nlet interval = totimespan({timeSpan:label});\nlet data = requests\n | where timestamp between (startTime .. endTime) and operation_Name startswith \"arc\";\nlet operationData = data;\nlet totalOperationCount = operationData\n | summarize Total = count() by operation_Name;\noperationData\n| join kind=inner totalOperationCount on operation_Name\n| summarize\n Count = count(),\n Users = dcount(tostring(customDimensions[\"Request-X-Forwarded-For\"])),\n AvgResponseTime = round(avg(duration), 2)\n by operation_Name, resultCode, Total\n| project\n ['Request Name'] = operation_Name,\n ['Result Code'] = resultCode,\n ['Total Response'] = Count,\n ['Rate %'] = (Count * 100) / Total,\n ['Users Affected'] = Users,\n ['Avg Response Time (ms)'] = AvgResponseTime\n| sort by ['Total Response'] desc\n\n", + "query": "let startTime = {timeRangeOverall:start};\nlet endTime = {timeRangeOverall:end};\nlet interval = totimespan({timeSpan:label});\nlet origin = \"{origin}\";\nlet data = requests\n | where timestamp between (startTime .. endTime)\n | where iff( origin == \"apim\", operation_Name startswith \"arc\", url contains \"citizen.internal\");\nlet operationData = data;\nlet totalOperationCount = operationData\n | summarize Total = count() by operation_Name;\noperationData\n| join kind=inner totalOperationCount on operation_Name\n| summarize\n Count = count(),\n Users = dcount(tostring(customDimensions[\"Request-X-Forwarded-For\"])),\n AvgResponseTime = round(avg(duration), 2)\n by operation_Name, resultCode, Total\n| project\n ['Request Name'] = operation_Name,\n ['Result Code'] = resultCode,\n ['Total Response'] = Count,\n ['Rate %'] = (Count * 100) / Total,\n ['Users Affected'] = Users,\n ['Avg Response Time (ms)'] = AvgResponseTime\n| sort by ['Total Response'] desc\n\n", "size": 0, "showAnalytics": true, "timeContextFromParameter": "timeRangeOverall", @@ -362,7 +389,7 @@ "type": 3, "content": { "version": "KqlItem/1.0", - "query": "let startTime = {timeRangeOverall:start};\nlet endTime = {timeRangeOverall:end};\nlet interval = totimespan({timeSpan:label});\n\nlet dataset = requests\n // additional filters can be applied here\n | where timestamp between (startTime .. endTime) and operation_Name startswith \"arc\"\n;\ndataset\n| summarize percentile_95=percentile(duration, 95) by bin(timestamp, interval)\n| project timestamp, percentile_95, watermark=1000\n| render timechart", + "query": "let startTime = {timeRangeOverall:start};\nlet endTime = {timeRangeOverall:end};\nlet interval = totimespan({timeSpan:label});\nlet origin = \"{origin}\";\n\nlet dataset = requests\n // additional filters can be applied here\n | where timestamp between (startTime .. endTime)\n | where iff( origin == \"apim\", operation_Name startswith \"arc\", url contains \"citizen.internal\");\n\ndataset\n| summarize percentile_95=percentile(duration, 95) by bin(timestamp, interval)\n| project timestamp, percentile_95, watermark=1000\n| render timechart", "size": 0, "aggregation": 3, "showAnalytics": true, @@ -406,7 +433,7 @@ "type": 3, "content": { "version": "KqlItem/1.0", - "query": "let startTime = {timeRangeOverall:start};\r\nlet endTime = {timeRangeOverall:end};\r\nlet interval = totimespan({timeSpan:label});\r\n\r\nlet data = requests\r\n| where timestamp between (startTime .. endTime) and operation_Name has \"arc\";\r\nlet unknowApi = data\r\n| join kind=inner exceptions on operation_Id\r\n| where type has \"OperationNotFound\";\r\nlet totalRequestCount = toscalar (data\r\n| count);\r\nlet joinedUnknowApi = unknowApi\r\n| summarize\r\n        Count = count(),\r\n        Users = dcount(tostring(customDimensions[\"Request-X-Forwarded-For\"]))\r\n        by operation_Name, resultCode, type\r\n| project \r\n        ['Request Name'] = operation_Name,\r\n        ['Result Code'] = resultCode,\r\n        ['Total Response'] = Count,\r\n        ['Rate (% of total requests)'] = (Count * 100) / totalRequestCount,\r\n        ['Users Affected'] = Users,\r\n        ['Type'] = type;\r\nunion joinedUnknowApi", + "query": "let startTime = {timeRangeOverall:start};\r\nlet endTime = {timeRangeOverall:end};\r\nlet interval = totimespan({timeSpan:label});\r\nlet origin = \"{origin}\";\r\nlet data = requests\r\n| where timestamp between (startTime .. endTime)\r\n| where iff( origin == \"apim\", operation_Name startswith \"arc\", url contains \"citizen.internal\");\r\nlet unknowApi = data\r\n| join kind=inner exceptions on operation_Id\r\n| where type has \"OperationNotFound\";\r\nlet totalRequestCount = toscalar (data\r\n| count);\r\nlet joinedUnknowApi = unknowApi\r\n| summarize\r\n        Count = count(),\r\n        Users = dcount(tostring(customDimensions[\"Request-X-Forwarded-For\"]))\r\n        by operation_Name, resultCode, type\r\n| project \r\n        ['Request Name'] = operation_Name,\r\n        ['Result Code'] = resultCode,\r\n        ['Total Response'] = Count,\r\n        ['Rate (% of total requests)'] = (Count * 100) / totalRequestCount,\r\n        ['Users Affected'] = Users,\r\n        ['Type'] = type;\r\nunion joinedUnknowApi", "size": 1, "showAnalytics": true, "title": "Operation Not Found", From a579d7c8816d57a013fab85f3a2a6c09fc1cc152 Mon Sep 17 00:00:00 2001 From: Giuseppe-La-Manna Date: Tue, 7 Jan 2025 10:02:00 +0100 Subject: [PATCH 2/3] P4PU-694 updated label --- src/06_domains/cittadini-app/workbooks/OPEXWorkbook.json.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/06_domains/cittadini-app/workbooks/OPEXWorkbook.json.tpl b/src/06_domains/cittadini-app/workbooks/OPEXWorkbook.json.tpl index 99c4cce..90683c2 100644 --- a/src/06_domains/cittadini-app/workbooks/OPEXWorkbook.json.tpl +++ b/src/06_domains/cittadini-app/workbooks/OPEXWorkbook.json.tpl @@ -120,7 +120,7 @@ "additionalResourceOptions": [], "showDefault": false }, - "jsonData": "[\r\n {\"label\":\"APIM\",\"value\":\"apim\",\"selected\": true},\r\n {\"label\":\"internal\",\"value\":\"internal\",\"selected\": true}\r\n]", + "jsonData": "[\r\n {\"label\":\"APIM\",\"value\":\"apim\",\"selected\": true},\r\n {\"label\":\"Internal\",\"value\":\"internal\",\"selected\": true}\r\n]", "timeContext": { "durationMs": 86400000 } From d20f15f9a1d613119e204c5d78e4c64a1f3cb196 Mon Sep 17 00:00:00 2001 From: Giuseppe-La-Manna Date: Tue, 7 Jan 2025 17:40:56 +0100 Subject: [PATCH 3/3] P4PU-694 updated queries --- .../cittadini-app/workbooks/OPEXWorkbook.json.tpl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/06_domains/cittadini-app/workbooks/OPEXWorkbook.json.tpl b/src/06_domains/cittadini-app/workbooks/OPEXWorkbook.json.tpl index 90683c2..4cf95b4 100644 --- a/src/06_domains/cittadini-app/workbooks/OPEXWorkbook.json.tpl +++ b/src/06_domains/cittadini-app/workbooks/OPEXWorkbook.json.tpl @@ -120,7 +120,7 @@ "additionalResourceOptions": [], "showDefault": false }, - "jsonData": "[\r\n {\"label\":\"APIM\",\"value\":\"apim\",\"selected\": true},\r\n {\"label\":\"Internal\",\"value\":\"internal\",\"selected\": true}\r\n]", + "jsonData": "[\r\n {\"label\":\"APIM\",\"value\":\"https://api.${env}.cittadini.pagopa.it\",\"selected\": true},\r\n {\"label\":\"Internal\",\"value\":\"https://citizen.internal.${env}.cittadini.pagopa.it\",\"selected\": true}\r\n]", "timeContext": { "durationMs": 86400000 } @@ -136,7 +136,7 @@ "type": 3, "content": { "version": "KqlItem/1.0", - "query": "let startTime = {timeRangeOverall:start};\nlet endTime = {timeRangeOverall:end};\nlet interval = totimespan({timeSpan:label});\nlet origin = \"{origin}\";\nlet data = requests\n | where timestamp between (startTime .. endTime)\n | where iff( origin == \"apim\", operation_Name startswith \"arc\", url contains \"citizen.internal\");\nlet operationData = data;\nlet totalOperationCount = operationData\n | summarize Total = count() by operation_Name;\noperationData\n| join kind=inner totalOperationCount on operation_Name\n| summarize\n Count = count(),\n Users = dcount(tostring(customDimensions[\"Request-X-Forwarded-For\"])),\n AvgResponseTime = round(avg(duration), 2)\n by operation_Name, resultCode, Total\n| project\n ['Request Name'] = operation_Name,\n ['Result Code'] = resultCode,\n ['Total Response'] = Count,\n ['Rate %'] = (Count * 100) / Total,\n ['Users Affected'] = Users,\n ['Avg Response Time (ms)'] = AvgResponseTime\n| sort by ['Total Response'] desc\n\n", + "query": "let startTime = {timeRangeOverall:start};\nlet endTime = {timeRangeOverall:end};\nlet interval = totimespan({timeSpan:label});\nlet originUrl = \"{origin}\";\nlet data = requests\n | where timestamp between (startTime .. endTime)\n | where url startswith originUrl and not(name has_any (\"OPTIONS\", \"HEAD\"));\nlet operationData = data;\nlet totalOperationCount = operationData\n | summarize Total = count() by operation_Name;\noperationData\n| join kind=inner totalOperationCount on operation_Name\n| summarize\n Count = count(),\n Users = dcount(tostring(customDimensions[\"Request-X-Forwarded-For\"])),\n AvgResponseTime = round(avg(duration), 2)\n by operation_Name, resultCode, Total\n| project\n ['Request Name'] = operation_Name,\n ['Result Code'] = resultCode,\n ['Total Response'] = Count,\n ['Rate %'] = (Count * 100) / Total,\n ['Users Affected'] = Users,\n ['Avg Response Time (ms)'] = AvgResponseTime\n| sort by ['Total Response'] desc\n\n", "size": 0, "showAnalytics": true, "timeContextFromParameter": "timeRangeOverall", @@ -389,7 +389,7 @@ "type": 3, "content": { "version": "KqlItem/1.0", - "query": "let startTime = {timeRangeOverall:start};\nlet endTime = {timeRangeOverall:end};\nlet interval = totimespan({timeSpan:label});\nlet origin = \"{origin}\";\n\nlet dataset = requests\n // additional filters can be applied here\n | where timestamp between (startTime .. endTime)\n | where iff( origin == \"apim\", operation_Name startswith \"arc\", url contains \"citizen.internal\");\n\ndataset\n| summarize percentile_95=percentile(duration, 95) by bin(timestamp, interval)\n| project timestamp, percentile_95, watermark=1000\n| render timechart", + "query": "let startTime = {timeRangeOverall:start};\nlet endTime = {timeRangeOverall:end};\nlet interval = totimespan({timeSpan:label});\nlet originUrl = \"{origin}\";\n\nlet dataset = requests\n // additional filters can be applied here\n | where timestamp between (startTime .. endTime)\n | where url startswith originUrl and not(name has_any (\"OPTIONS\", \"HEAD\"));\n\ndataset\n| summarize percentile_95=percentile(duration, 95) by bin(timestamp, interval)\n| project timestamp, percentile_95, watermark=1000\n| render timechart", "size": 0, "aggregation": 3, "showAnalytics": true, @@ -408,7 +408,7 @@ "type": 3, "content": { "version": "KqlItem/1.0", - "query": "let startTime = {timeRangeOverall:start};\nlet endTime = {timeRangeOverall:end};\nlet interval = totimespan({timeSpan:label});\n\nlet tot = requests\n | where timestamp between (startTime .. endTime) \n | where operation_Name has 'cittadini'\n | summarize tot = todouble(count()) by bin(timestamp, interval);\nlet errors = requests\n | where operation_Name has 'cittadini'\n | where strcmp(resultCode, \"412\") > 0 \n | summarize not_ok = count() by bin(timestamp, interval);\ntot\n| join kind=leftouter errors on timestamp\n| project timestamp, availability = (tot - coalesce(not_ok, 0)) / tot, watermark=0.99", + "query": "let startTime = {timeRangeOverall:start};\nlet endTime = {timeRangeOverall:end};\nlet interval = totimespan({timeSpan:label});\nlet originUrl = \"{origin}\";\nlet tot = requests\n | where timestamp between (startTime .. endTime) \n | where url startswith originUrl and not(name has_any (\"OPTIONS\", \"HEAD\"))\n | summarize tot = todouble(count()) by bin(timestamp, interval);\nlet errors = requests\n | where url startswith originUrl and not(name has_any (\"OPTIONS\", \"HEAD\"))\n | where strcmp(resultCode, \"412\") > 0 \n | summarize not_ok = count() by bin(timestamp, interval);\ntot\n| join kind=leftouter errors on timestamp\n| project timestamp, availability = (tot - coalesce(not_ok, 0)) / tot, watermark=0.99", "size": 0, "aggregation": 3, "showAnalytics": true, @@ -433,7 +433,7 @@ "type": 3, "content": { "version": "KqlItem/1.0", - "query": "let startTime = {timeRangeOverall:start};\r\nlet endTime = {timeRangeOverall:end};\r\nlet interval = totimespan({timeSpan:label});\r\nlet origin = \"{origin}\";\r\nlet data = requests\r\n| where timestamp between (startTime .. endTime)\r\n| where iff( origin == \"apim\", operation_Name startswith \"arc\", url contains \"citizen.internal\");\r\nlet unknowApi = data\r\n| join kind=inner exceptions on operation_Id\r\n| where type has \"OperationNotFound\";\r\nlet totalRequestCount = toscalar (data\r\n| count);\r\nlet joinedUnknowApi = unknowApi\r\n| summarize\r\n        Count = count(),\r\n        Users = dcount(tostring(customDimensions[\"Request-X-Forwarded-For\"]))\r\n        by operation_Name, resultCode, type\r\n| project \r\n        ['Request Name'] = operation_Name,\r\n        ['Result Code'] = resultCode,\r\n        ['Total Response'] = Count,\r\n        ['Rate (% of total requests)'] = (Count * 100) / totalRequestCount,\r\n        ['Users Affected'] = Users,\r\n        ['Type'] = type;\r\nunion joinedUnknowApi", + "query": "let startTime = {timeRangeOverall:start};\r\nlet endTime = {timeRangeOverall:end};\r\nlet interval = totimespan({timeSpan:label});\r\nlet originUrl = \"{origin}\";\r\nlet data = requests\r\n| where timestamp between (startTime .. endTime)\r\n| where url startswith originUrl and not(name has_any (\"OPTIONS\", \"HEAD\"));\r\nlet unknowApi = data\r\n| join kind=inner exceptions on operation_Id\r\n| where type has \"OperationNotFound\";\r\nlet totalRequestCount = toscalar (data\r\n| count);\r\nlet joinedUnknowApi = unknowApi\r\n| summarize\r\n        Count = count(),\r\n        Users = dcount(tostring(customDimensions[\"Request-X-Forwarded-For\"]))\r\n        by operation_Name, resultCode, type\r\n| project \r\n        ['Request Name'] = operation_Name,\r\n        ['Result Code'] = resultCode,\r\n        ['Total Response'] = Count,\r\n        ['Rate (% of total requests)'] = (Count * 100) / totalRequestCount,\r\n        ['Users Affected'] = Users,\r\n        ['Type'] = type;\r\nunion joinedUnknowApi", "size": 1, "showAnalytics": true, "title": "Operation Not Found",