This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// getVirtualNodeUsageStats fetches the virtual node max CPU milli-cores and max memory used in bytes within a span of | |
// startDateTime to endDateTime. KQL requires the client to ensure that these times are in UTC and ISO 8061 format(RFC3339) | |
func getVirtualNodeUsageStats(ctx context.Context, tokenCredential azcore.TokenCredential, subscriptionId, clusterName, resourceGroup string, startDateTime, endDateTime time.Time) (map[string]float64, error) { | |
client, err := armoperationalinsights.NewWorkspacesClient(subscriptionId, tokenCredential, nil) | |
if err != nil { | |
zap.S().Error(err) | |
return nil, err | |
} | |
workspace, err := client.Get(ctx, resourceGroup, workspaceName, nil) | |
if err != nil { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let subscriptionId = '{subscription-id}'; | |
let resourceGroup = '{resource-group}'; | |
let clusterName = '{cluster-name}'; | |
let startDateTime = datetime({start-tate-time}); | |
let endDateTime = datetime({end-date-time}); | |
let clusterId = strcat('/subscriptions/', subscriptionId, '/resourceGroups/', resourceGroup, '/providers/Microsoft.ContainerService/managedClusters/', clusterName); | |
let memoryUsageCounterName = 'memoryRssBytes'; | |
let primaryInventory = KubePodInventory | | |
where TimeGenerated >= startDateTime | | |
where TimeGenerated < endDateTime | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cost": 177, | |
"interval": "PT1H", | |
"namespace": "Microsoft.ContainerService/managedClusters", | |
"resourceregion": "centralindia", | |
"timespan": "2022-05-17T05:10:12Z/2022-05-17T06:10:12Z", | |
"value": [ | |
{ | |
"displayDescription": "Aggregated measurement of CPU utilization in millicores across the cluster", | |
"errorCode": "Success", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"context" | |
"encoding/json" | |
"log" | |
"os" | |
"time" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cost": 59, | |
"timespan": "2022-05-12T08:18:37Z/2022-05-12T09:18:37Z", | |
"interval": "PT1M", | |
"value": [ | |
{ | |
"id": "/subscriptions/xxxxxxxxxxxxxxx/resourceGroups/anirudh-dialtone/providers/Microsoft.ContainerService/managedClusters/DialtoneCluster/providers/Microsoft.Insights/metrics/node_cpu_usage_millicores", | |
"type": "Microsoft.Insights/metrics", | |
"name": { | |
"value": "node_cpu_usage_millicores", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cost": 177, | |
"timespan": "2022-05-12T06:08:36Z/2022-05-12T07:08:36Z", | |
"interval": "PT1M", | |
"value": [ | |
{ | |
"id": "/subscriptions/xxxxxxxxxxxxx/resourceGroups/anirudh-dialtone/providers/Microsoft.ContainerService/managedClusters/DialtoneCluster/providers/Microsoft.Insights/metrics/node_cpu_usage_millicores", | |
"type": "Microsoft.Insights/metrics", | |
"name": { | |
"value": "node_cpu_usage_millicores", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"context" | |
"encoding/json" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"net/http" |