From 8d5f005c5aff2a2d611c612abb21014b9b16c656 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Thu, 1 Jul 2021 15:12:48 +0530 Subject: [PATCH 01/14] Add table azure_compute_virtual_machine_metric_cpu_utilization_ closes #159 --- azure/monitoring_metric.go | 165 ++++++++++++++++++ azure/plugin.go | 121 ++++++------- ..._virtual_machine_metric_cpu_utilization.go | 39 +++++ ..._virtual_machine_metric_cpu_utilization.md | 40 +++++ go.mod | 3 +- go.sum | 10 +- 6 files changed, 308 insertions(+), 70 deletions(-) create mode 100644 azure/monitoring_metric.go create mode 100644 azure/table_azure_compute_virtual_machine_metric_cpu_utilization.go create mode 100644 docs/tables/azure_compute_virtual_machine_metric_cpu_utilization.md diff --git a/azure/monitoring_metric.go b/azure/monitoring_metric.go new file mode 100644 index 00000000..1583026c --- /dev/null +++ b/azure/monitoring_metric.go @@ -0,0 +1,165 @@ +package azure + +import ( + "context" + "strings" + "time" + + "github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2021-04-01-preview/insights" + "github.com/turbot/steampipe-plugin-sdk/grpc/proto" + "github.com/turbot/steampipe-plugin-sdk/plugin" + "github.com/turbot/steampipe-plugin-sdk/plugin/transform" +) + +type monitoringMetric struct { + // Resource Name + DimensionValue string + + // MetadataValue represents a metric metadata value. + MetaData *insights.MetadataValue + + // Metric the result data of a query. + Metric *insights.Metric + + // The maximum metric value for the data point. + Maximum *float64 + + // The minimum metric value for the data point. + Minimum *float64 + + // The average of the metric values that correspond to the data point. + Average *float64 + + // The number of metric values that contributed to the aggregate value of this data point. + SampleCount *float64 + + // The sum of the metric values for the data point. + Sum *float64 + + // The time stamp used for the data point. + TimeStamp string + + // The units in which the metric value is reported. + Unit string + + ResourceGroup string + + SubscriptionID string +} + +//// TABLE DEFINITION + +func monitoringMetricColumns(columns []*plugin.Column) []*plugin.Column { + return append(columns, commonMonitoringMetricColumns()...) +} + +func commonMonitoringMetricColumns() []*plugin.Column { + return []*plugin.Column{ + { + Name: "maximum", + Description: "The maximum metric value for the data point.", + Type: proto.ColumnType_DOUBLE, + }, + { + Name: "minimum", + Description: "The minimum metric value for the data point.", + Type: proto.ColumnType_DOUBLE, + }, + { + Name: "average", + Description: "The average of the metric values that correspond to the data point.", + Type: proto.ColumnType_DOUBLE, + }, + { + Name: "sample_count", + Description: "The number of metric values that contributed to the aggregate value of this data point.", + Type: proto.ColumnType_DOUBLE, + }, + { + Name: "sum", + Description: "The sum of the metric values for the data point.", + Type: proto.ColumnType_DOUBLE, + }, + { + Name: "timestamp", + Description: "The time stamp used for the data point.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("TimeStamp"), + }, + { + Name: "unit", + Description: "The units in which the metric value is reported.", + Type: proto.ColumnType_STRING, + }, + { + Name: "resource_group", + Description: "The time stamp used for the data point.", + Type: proto.ColumnType_STRING, + }, + { + Name: "subscrition_id", + Description: "The time stamp used for the data point.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("SubscriptionID"), + }, + } +} + +func getMonitoringIntervalForGranularity(granularity string) string { + switch strings.ToUpper(granularity) { + case "DAILY": + // 24 hours + return "PT24H" + case "HOURLY": + // 1 hour + return "PT1H" + } + // else 5 minutes + return "PT5M" +} + +func listAzureMonitorMetricStatistics(ctx context.Context, d *plugin.QueryData, granularity string, metricNameSpace string, metricNames string, dimensionValue string) (interface{}, error) { + session, err := GetNewSession(ctx, d, "MANAGEMENT") + if err != nil { + return nil, err + } + subscriptionID := session.SubscriptionID + + monitoringClient := insights.NewMetricsClient(subscriptionID) + monitoringClient.Authorizer = session.Authorizer + + // Define param values + interval := getMonitoringIntervalForGranularity(granularity) + aggregation := "average,count,maximum,minimum,total" + timeSpan := time.Now().UTC().AddDate(-1, 0, 0).Format(time.RFC3339) + "/" + time.Now().UTC().Format(time.RFC3339) // Retrive data within a year + orderBy := "timestamp" + top := int32(1000) // Maximum number of recodr fetch with given interval + filter := "" + + result, err := monitoringClient.List(ctx, dimensionValue, timeSpan, &interval, metricNames, aggregation, &top, orderBy, filter, insights.ResultTypeData, metricNameSpace) + if err != nil { + return nil, err + } + for _, metric := range *result.Value { + for _, timeseries := range *metric.Timeseries { + for _, data := range *timeseries.Data { + if data.Average != nil { + d.StreamListItem(ctx, &monitoringMetric{ + DimensionValue: strings.Split(dimensionValue, "/")[len(strings.Split(dimensionValue, "/"))-1], + TimeStamp: data.TimeStamp.Format(time.RFC3339), + Maximum: data.Maximum, + Minimum: data.Minimum, + Average: data.Average, + Sum: data.Total, + SampleCount: data.Count, + Unit: string(metric.Unit), + ResourceGroup: strings.Split(dimensionValue, "/")[4], + SubscriptionID: strings.Split(dimensionValue, "/")[2], + }) + } + } + } + } + + return nil, nil +} diff --git a/azure/plugin.go b/azure/plugin.go index 63feab55..cd9cd5b7 100644 --- a/azure/plugin.go +++ b/azure/plugin.go @@ -22,66 +22,67 @@ func Plugin(ctx context.Context) *plugin.Plugin { Schema: ConfigSchema, }, TableMap: map[string]*plugin.Table{ - "azure_ad_group": tableAzureAdGroup(ctx), - "azure_ad_service_principal": tableAzureAdServicePrincipal(ctx), - "azure_ad_user": tableAzureAdUser(ctx), - "azure_api_management": tableAzureAPIManagement(ctx), - "azure_app_service_environment": tableAzureAppServiceEnvironment(ctx), - "azure_app_service_function_app": tableAzureAppServiceFunctionApp(ctx), - "azure_app_service_plan": tableAzureAppServicePlan(ctx), - "azure_app_service_web_app": tableAzureAppServiceWebApp(ctx), - "azure_application_security_group": tableAzureApplicationSecurityGroup(ctx), - "azure_compute_availability_set": tableAzureComputeAvailabilitySet(ctx), - "azure_compute_disk": tableAzureComputeDisk(ctx), - "azure_compute_disk_encryption_set": tableAzureComputeDiskEncryptionSet(ctx), - "azure_compute_image": tableAzureComputeImage(ctx), - "azure_compute_resource_sku": tableAzureResourceSku(ctx), - "azure_compute_snapshot": tableAzureComputeSnapshot(ctx), - "azure_compute_virtual_machine": tableAzureComputeVirtualMachine(ctx), - "azure_cosmosdb_account": tableAzureCosmosDBAccount(ctx), - "azure_cosmosdb_mongo_database": tableAzureCosmosDBMongoDatabase(ctx), - "azure_cosmosdb_sql_database": tableAzureCosmosDBSQLDatabase(ctx), - "azure_diagnostic_setting": tableAzureDiagnosticSetting(ctx), - "azure_firewall": tableAzureFirewall(ctx), - "azure_key_vault": tableAzureKeyVault(ctx), - "azure_key_vault_key": tableAzureKeyVaultKey(ctx), - "azure_key_vault_secret": tableAzureKeyVaultSecret(ctx), - "azure_kubernetes_cluster": tableAzureKubernetesCluster(ctx), - "azure_location": tableAzureLocation(ctx), - "azure_log_alert": tableAzureLogAlert(ctx), - "azure_log_profile": tableAzureLogProfile(ctx), - "azure_management_lock": tableAzureManagementLock(ctx), - "azure_mysql_server": tableAzureMySQLServer(ctx), - "azure_network_interface": tableAzureNetworkInterface(ctx), - "azure_network_security_group": tableAzureNetworkSecurityGroup(ctx), - "azure_network_watcher": tableAzureNetworkWatcher(ctx), - "azure_network_watcher_flow_log": tableAzureNetworkWatcherFlowLog(ctx), - "azure_policy_assignment": tableAzurePolicyAssignment(ctx), - "azure_policy_definition": tableAzurePolicyDefinition(ctx), - "azure_postgresql_server": tableAzurePostgreSqlServer(ctx), - "azure_provider": tableAzureProvider(ctx), - "azure_public_ip": tableAzurePublicIP(ctx), - "azure_resource_group": tableAzureResourceGroup(ctx), - "azure_role_assignment": tableAzureIamRoleAssignment(ctx), - "azure_role_definition": tableAzureIamRoleDefinition(ctx), - "azure_route_table": tableAzureRouteTable(ctx), - "azure_security_center_auto_provisioning": tableAzureSecurityCenterAutoProvisioning(ctx), - "azure_security_center_contact": tableAzureSecurityCenterContact(ctx), - "azure_security_center_setting": tableAzureSecurityCenterSetting(ctx), - "azure_security_center_subscription_pricing": tableAzureSecurityCenterPricing(ctx), - "azure_sql_database": tableAzureSqlDatabase(ctx), - "azure_sql_server": tableAzureSQLServer(ctx), - "azure_storage_account": tableAzureStorageAccount(ctx), - "azure_storage_blob": tableAzureStorageBlob(ctx), - "azure_storage_blob_service": tableAzureStorageBlobService(ctx), - "azure_storage_container": tableAzureStorageContainer(ctx), - "azure_storage_queue": tableAzureStorageQueue(ctx), - "azure_storage_table": tableAzureStorageTable(ctx), - "azure_storage_table_service": tableAzureStorageTableService(ctx), - "azure_subnet": tableAzureSubnet(ctx), - "azure_subscription": tableAzureSubscription(ctx), - "azure_tenant": tableAzureTenant(ctx), - "azure_virtual_network": tableAzureVirtualNetwork(ctx), + "azure_ad_group": tableAzureAdGroup(ctx), + "azure_ad_service_principal": tableAzureAdServicePrincipal(ctx), + "azure_ad_user": tableAzureAdUser(ctx), + "azure_api_management": tableAzureAPIManagement(ctx), + "azure_app_service_environment": tableAzureAppServiceEnvironment(ctx), + "azure_app_service_function_app": tableAzureAppServiceFunctionApp(ctx), + "azure_app_service_plan": tableAzureAppServicePlan(ctx), + "azure_app_service_web_app": tableAzureAppServiceWebApp(ctx), + "azure_application_security_group": tableAzureApplicationSecurityGroup(ctx), + "azure_compute_availability_set": tableAzureComputeAvailabilitySet(ctx), + "azure_compute_disk": tableAzureComputeDisk(ctx), + "azure_compute_disk_encryption_set": tableAzureComputeDiskEncryptionSet(ctx), + "azure_compute_image": tableAzureComputeImage(ctx), + "azure_compute_resource_sku": tableAzureResourceSku(ctx), + "azure_compute_snapshot": tableAzureComputeSnapshot(ctx), + "azure_compute_virtual_machine": tableAzureComputeVirtualMachine(ctx), + "azure_compute_virtual_machine_metric_cpu_utilization": tableComputeInstanceCpuUtilizationMetric(ctx), + "azure_cosmosdb_account": tableAzureCosmosDBAccount(ctx), + "azure_cosmosdb_mongo_database": tableAzureCosmosDBMongoDatabase(ctx), + "azure_cosmosdb_sql_database": tableAzureCosmosDBSQLDatabase(ctx), + "azure_diagnostic_setting": tableAzureDiagnosticSetting(ctx), + "azure_firewall": tableAzureFirewall(ctx), + "azure_key_vault": tableAzureKeyVault(ctx), + "azure_key_vault_key": tableAzureKeyVaultKey(ctx), + "azure_key_vault_secret": tableAzureKeyVaultSecret(ctx), + "azure_kubernetes_cluster": tableAzureKubernetesCluster(ctx), + "azure_location": tableAzureLocation(ctx), + "azure_log_alert": tableAzureLogAlert(ctx), + "azure_log_profile": tableAzureLogProfile(ctx), + "azure_management_lock": tableAzureManagementLock(ctx), + "azure_mysql_server": tableAzureMySQLServer(ctx), + "azure_network_interface": tableAzureNetworkInterface(ctx), + "azure_network_security_group": tableAzureNetworkSecurityGroup(ctx), + "azure_network_watcher": tableAzureNetworkWatcher(ctx), + "azure_network_watcher_flow_log": tableAzureNetworkWatcherFlowLog(ctx), + "azure_policy_assignment": tableAzurePolicyAssignment(ctx), + "azure_policy_definition": tableAzurePolicyDefinition(ctx), + "azure_postgresql_server": tableAzurePostgreSqlServer(ctx), + "azure_provider": tableAzureProvider(ctx), + "azure_public_ip": tableAzurePublicIP(ctx), + "azure_resource_group": tableAzureResourceGroup(ctx), + "azure_role_assignment": tableAzureIamRoleAssignment(ctx), + "azure_role_definition": tableAzureIamRoleDefinition(ctx), + "azure_route_table": tableAzureRouteTable(ctx), + "azure_security_center_auto_provisioning": tableAzureSecurityCenterAutoProvisioning(ctx), + "azure_security_center_contact": tableAzureSecurityCenterContact(ctx), + "azure_security_center_setting": tableAzureSecurityCenterSetting(ctx), + "azure_security_center_subscription_pricing": tableAzureSecurityCenterPricing(ctx), + "azure_sql_database": tableAzureSqlDatabase(ctx), + "azure_sql_server": tableAzureSQLServer(ctx), + "azure_storage_account": tableAzureStorageAccount(ctx), + "azure_storage_blob": tableAzureStorageBlob(ctx), + "azure_storage_blob_service": tableAzureStorageBlobService(ctx), + "azure_storage_container": tableAzureStorageContainer(ctx), + "azure_storage_queue": tableAzureStorageQueue(ctx), + "azure_storage_table": tableAzureStorageTable(ctx), + "azure_storage_table_service": tableAzureStorageTableService(ctx), + "azure_subnet": tableAzureSubnet(ctx), + "azure_subscription": tableAzureSubscription(ctx), + "azure_tenant": tableAzureTenant(ctx), + "azure_virtual_network": tableAzureVirtualNetwork(ctx), // "azure_storage_table": tableAzureStorageTable(ctx), }, } diff --git a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization.go b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization.go new file mode 100644 index 00000000..fbafa457 --- /dev/null +++ b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization.go @@ -0,0 +1,39 @@ +package azure + +import ( + "context" + + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2020-06-01/compute" + "github.com/turbot/steampipe-plugin-sdk/grpc/proto" + "github.com/turbot/steampipe-plugin-sdk/plugin" + "github.com/turbot/steampipe-plugin-sdk/plugin/transform" +) + +//// TABLE DEFINITION + +func tableComputeInstanceCpuUtilizationMetric(_ context.Context) *plugin.Table { + return &plugin.Table{ + Name: "azure_compute_virtual_machine_metric_cpu_utilization", + Description: "Azure Compute Virtual Machine Metrics - CPU Utilization", + List: &plugin.ListConfig{ + ParentHydrate: listAzureComputeVirtualMachines, + Hydrate: listComputeVirtualMachineMMetricCpuUtilization, + }, + Columns: monitoringMetricColumns([]*plugin.Column{ + { + Name: "name", + Description: "The name of the virtual machine instance.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("DimensionValue"), + }, + }), + } +} + +//// LIST FUNCTION + +func listComputeVirtualMachineMMetricCpuUtilization(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + vmInfo := h.Item.(compute.VirtualMachine) + + return listAzureMonitorMetricStatistics(ctx, d, "FIVE_MINUTES", "Microsoft.Compute/virtualMachines", "Percentage CPU", *vmInfo.ID) +} diff --git a/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization.md b/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization.md new file mode 100644 index 00000000..07c31976 --- /dev/null +++ b/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization.md @@ -0,0 +1,40 @@ +# Table: azure_compute_virtual_machine_metric_cpu_utilization + +GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_virtual_machine_metric_cpu_utilization` table provides metric statistics at 5 minute intervals for the most recent 5 days. + +## Examples + +### Basic info + +```sql +select + name, + timestamp, + minimum, + maximum, + average, + sample_count +from + azure_compute_virtual_machine_metric_cpu_utilization +order by + name, + timestamp; +``` + +### CPU Over 80% average + +```sql +select + name, + timestamp, + round(minimum::numeric,2) as min_cpu, + round(maximum::numeric,2) as max_cpu, + round(average::numeric,2) as avg_cpu, + sample_count +from + azure_compute_virtual_machine_metric_cpu_utilization +where average > 80 +order by + name, + timestamp; +``` diff --git a/go.mod b/go.mod index 77726b59..0348f3a6 100644 --- a/go.mod +++ b/go.mod @@ -3,13 +3,12 @@ module github.com/turbot/steampipe-plugin-azure go 1.15 require ( - github.com/Azure/azure-sdk-for-go v53.0.0+incompatible + github.com/Azure/azure-sdk-for-go v55.4.0+incompatible github.com/Azure/azure-storage-blob-go v0.12.0 github.com/Azure/go-autorest/autorest v0.11.17 github.com/Azure/go-autorest/autorest/azure/auth v0.5.6 github.com/Azure/go-autorest/autorest/date v0.3.0 github.com/gofrs/uuid v4.0.0+incompatible // indirect - github.com/satori/go.uuid v1.2.0 // indirect github.com/tombuildsstuff/giovanni v0.15.1 github.com/turbot/go-kit v0.1.1 github.com/turbot/steampipe-plugin-sdk v0.2.7 diff --git a/go.sum b/go.sum index 300193d6..5c4b8349 100644 --- a/go.sum +++ b/go.sum @@ -3,11 +3,8 @@ github.com/Azure/azure-pipeline-go v0.2.3 h1:7U9HBg1JFK3jHl5qmo4CTZKFTVgMwdFHMVt github.com/Azure/azure-pipeline-go v0.2.3/go.mod h1:x841ezTBIMG6O3lAcl8ATHnsOPVl2bqk7S3ta6S6u4k= github.com/Azure/azure-sdk-for-go v45.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-sdk-for-go v47.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= -github.com/Azure/azure-sdk-for-go v50.1.0+incompatible h1:SUR6Y194mjyNkNbEzDHyYX8Butfa+Om9fcGSIy0ffhk= -github.com/Azure/azure-sdk-for-go v50.1.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= -github.com/Azure/azure-sdk-for-go v53.0.0+incompatible h1:DHeVnEdW3l7C/vXSdig9IJzoEpxgukIpYDfKBq6zNSI= -github.com/Azure/azure-sdk-for-go v53.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= -github.com/Azure/azure-sdk-for-go v53.1.0+incompatible h1:f2h0KLVGa3zIaMDMHBe5Lazc0FT5+L78z0B8K9PmDyg= +github.com/Azure/azure-sdk-for-go v55.4.0+incompatible h1:zn3+QwgCjRgIRgE0iWpF2LrFy5er/T0e5/EHrp1Zgak= +github.com/Azure/azure-sdk-for-go v55.4.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-storage-blob-go v0.12.0 h1:7bFXA1QB+lOK2/ASWHhp6/vnxjaeeZq6t8w1Jyp0Iaw= github.com/Azure/azure-storage-blob-go v0.12.0/go.mod h1:A0u4VjtpgZJ7Y7um/+ix2DHBuEKFC6sEIlj0xc13a4Q= github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= @@ -80,7 +77,6 @@ github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68= github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA= -github.com/gofrs/uuid v1.2.0 h1:coDhrjgyJaglxSjxuJdqQSSdUpG3w6p1OwN2od6frBU= github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -166,8 +162,6 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= -github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= From 6de119110e1627d61345f687d8ff19a043b32b4b Mon Sep 17 00:00:00 2001 From: ParthaI Date: Thu, 1 Jul 2021 15:21:27 +0530 Subject: [PATCH 02/14] Add table azure_compute_virtual_machine_metric_cpu_utilization_daily closes #147 --- azure/plugin.go | 123 +++++++++--------- ...al_machine_metric_cpu_utilization_daily.go | 39 ++++++ ..._virtual_machine_metric_cpu_utilization.md | 2 +- ...al_machine_metric_cpu_utilization_daily.md | 40 ++++++ 4 files changed, 142 insertions(+), 62 deletions(-) create mode 100644 azure/table_azure_compute_virtual_machine_metric_cpu_utilization_daily.go create mode 100644 docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_daily.md diff --git a/azure/plugin.go b/azure/plugin.go index cd9cd5b7..c3f9d6f6 100644 --- a/azure/plugin.go +++ b/azure/plugin.go @@ -22,67 +22,68 @@ func Plugin(ctx context.Context) *plugin.Plugin { Schema: ConfigSchema, }, TableMap: map[string]*plugin.Table{ - "azure_ad_group": tableAzureAdGroup(ctx), - "azure_ad_service_principal": tableAzureAdServicePrincipal(ctx), - "azure_ad_user": tableAzureAdUser(ctx), - "azure_api_management": tableAzureAPIManagement(ctx), - "azure_app_service_environment": tableAzureAppServiceEnvironment(ctx), - "azure_app_service_function_app": tableAzureAppServiceFunctionApp(ctx), - "azure_app_service_plan": tableAzureAppServicePlan(ctx), - "azure_app_service_web_app": tableAzureAppServiceWebApp(ctx), - "azure_application_security_group": tableAzureApplicationSecurityGroup(ctx), - "azure_compute_availability_set": tableAzureComputeAvailabilitySet(ctx), - "azure_compute_disk": tableAzureComputeDisk(ctx), - "azure_compute_disk_encryption_set": tableAzureComputeDiskEncryptionSet(ctx), - "azure_compute_image": tableAzureComputeImage(ctx), - "azure_compute_resource_sku": tableAzureResourceSku(ctx), - "azure_compute_snapshot": tableAzureComputeSnapshot(ctx), - "azure_compute_virtual_machine": tableAzureComputeVirtualMachine(ctx), - "azure_compute_virtual_machine_metric_cpu_utilization": tableComputeInstanceCpuUtilizationMetric(ctx), - "azure_cosmosdb_account": tableAzureCosmosDBAccount(ctx), - "azure_cosmosdb_mongo_database": tableAzureCosmosDBMongoDatabase(ctx), - "azure_cosmosdb_sql_database": tableAzureCosmosDBSQLDatabase(ctx), - "azure_diagnostic_setting": tableAzureDiagnosticSetting(ctx), - "azure_firewall": tableAzureFirewall(ctx), - "azure_key_vault": tableAzureKeyVault(ctx), - "azure_key_vault_key": tableAzureKeyVaultKey(ctx), - "azure_key_vault_secret": tableAzureKeyVaultSecret(ctx), - "azure_kubernetes_cluster": tableAzureKubernetesCluster(ctx), - "azure_location": tableAzureLocation(ctx), - "azure_log_alert": tableAzureLogAlert(ctx), - "azure_log_profile": tableAzureLogProfile(ctx), - "azure_management_lock": tableAzureManagementLock(ctx), - "azure_mysql_server": tableAzureMySQLServer(ctx), - "azure_network_interface": tableAzureNetworkInterface(ctx), - "azure_network_security_group": tableAzureNetworkSecurityGroup(ctx), - "azure_network_watcher": tableAzureNetworkWatcher(ctx), - "azure_network_watcher_flow_log": tableAzureNetworkWatcherFlowLog(ctx), - "azure_policy_assignment": tableAzurePolicyAssignment(ctx), - "azure_policy_definition": tableAzurePolicyDefinition(ctx), - "azure_postgresql_server": tableAzurePostgreSqlServer(ctx), - "azure_provider": tableAzureProvider(ctx), - "azure_public_ip": tableAzurePublicIP(ctx), - "azure_resource_group": tableAzureResourceGroup(ctx), - "azure_role_assignment": tableAzureIamRoleAssignment(ctx), - "azure_role_definition": tableAzureIamRoleDefinition(ctx), - "azure_route_table": tableAzureRouteTable(ctx), - "azure_security_center_auto_provisioning": tableAzureSecurityCenterAutoProvisioning(ctx), - "azure_security_center_contact": tableAzureSecurityCenterContact(ctx), - "azure_security_center_setting": tableAzureSecurityCenterSetting(ctx), - "azure_security_center_subscription_pricing": tableAzureSecurityCenterPricing(ctx), - "azure_sql_database": tableAzureSqlDatabase(ctx), - "azure_sql_server": tableAzureSQLServer(ctx), - "azure_storage_account": tableAzureStorageAccount(ctx), - "azure_storage_blob": tableAzureStorageBlob(ctx), - "azure_storage_blob_service": tableAzureStorageBlobService(ctx), - "azure_storage_container": tableAzureStorageContainer(ctx), - "azure_storage_queue": tableAzureStorageQueue(ctx), - "azure_storage_table": tableAzureStorageTable(ctx), - "azure_storage_table_service": tableAzureStorageTableService(ctx), - "azure_subnet": tableAzureSubnet(ctx), - "azure_subscription": tableAzureSubscription(ctx), - "azure_tenant": tableAzureTenant(ctx), - "azure_virtual_network": tableAzureVirtualNetwork(ctx), + "azure_ad_group": tableAzureAdGroup(ctx), + "azure_ad_service_principal": tableAzureAdServicePrincipal(ctx), + "azure_ad_user": tableAzureAdUser(ctx), + "azure_api_management": tableAzureAPIManagement(ctx), + "azure_app_service_environment": tableAzureAppServiceEnvironment(ctx), + "azure_app_service_function_app": tableAzureAppServiceFunctionApp(ctx), + "azure_app_service_plan": tableAzureAppServicePlan(ctx), + "azure_app_service_web_app": tableAzureAppServiceWebApp(ctx), + "azure_application_security_group": tableAzureApplicationSecurityGroup(ctx), + "azure_compute_availability_set": tableAzureComputeAvailabilitySet(ctx), + "azure_compute_disk": tableAzureComputeDisk(ctx), + "azure_compute_disk_encryption_set": tableAzureComputeDiskEncryptionSet(ctx), + "azure_compute_image": tableAzureComputeImage(ctx), + "azure_compute_resource_sku": tableAzureResourceSku(ctx), + "azure_compute_snapshot": tableAzureComputeSnapshot(ctx), + "azure_compute_virtual_machine": tableAzureComputeVirtualMachine(ctx), + "azure_compute_virtual_machine_metric_cpu_utilization": tableComputeInstanceCpuUtilizationMetric(ctx), + "azure_compute_virtual_machine_metric_cpu_utilization_daily": tableComputeInstanceCpuUtilizationMetricDaily(ctx), + "azure_cosmosdb_account": tableAzureCosmosDBAccount(ctx), + "azure_cosmosdb_mongo_database": tableAzureCosmosDBMongoDatabase(ctx), + "azure_cosmosdb_sql_database": tableAzureCosmosDBSQLDatabase(ctx), + "azure_diagnostic_setting": tableAzureDiagnosticSetting(ctx), + "azure_firewall": tableAzureFirewall(ctx), + "azure_key_vault": tableAzureKeyVault(ctx), + "azure_key_vault_key": tableAzureKeyVaultKey(ctx), + "azure_key_vault_secret": tableAzureKeyVaultSecret(ctx), + "azure_kubernetes_cluster": tableAzureKubernetesCluster(ctx), + "azure_location": tableAzureLocation(ctx), + "azure_log_alert": tableAzureLogAlert(ctx), + "azure_log_profile": tableAzureLogProfile(ctx), + "azure_management_lock": tableAzureManagementLock(ctx), + "azure_mysql_server": tableAzureMySQLServer(ctx), + "azure_network_interface": tableAzureNetworkInterface(ctx), + "azure_network_security_group": tableAzureNetworkSecurityGroup(ctx), + "azure_network_watcher": tableAzureNetworkWatcher(ctx), + "azure_network_watcher_flow_log": tableAzureNetworkWatcherFlowLog(ctx), + "azure_policy_assignment": tableAzurePolicyAssignment(ctx), + "azure_policy_definition": tableAzurePolicyDefinition(ctx), + "azure_postgresql_server": tableAzurePostgreSqlServer(ctx), + "azure_provider": tableAzureProvider(ctx), + "azure_public_ip": tableAzurePublicIP(ctx), + "azure_resource_group": tableAzureResourceGroup(ctx), + "azure_role_assignment": tableAzureIamRoleAssignment(ctx), + "azure_role_definition": tableAzureIamRoleDefinition(ctx), + "azure_route_table": tableAzureRouteTable(ctx), + "azure_security_center_auto_provisioning": tableAzureSecurityCenterAutoProvisioning(ctx), + "azure_security_center_contact": tableAzureSecurityCenterContact(ctx), + "azure_security_center_setting": tableAzureSecurityCenterSetting(ctx), + "azure_security_center_subscription_pricing": tableAzureSecurityCenterPricing(ctx), + "azure_sql_database": tableAzureSqlDatabase(ctx), + "azure_sql_server": tableAzureSQLServer(ctx), + "azure_storage_account": tableAzureStorageAccount(ctx), + "azure_storage_blob": tableAzureStorageBlob(ctx), + "azure_storage_blob_service": tableAzureStorageBlobService(ctx), + "azure_storage_container": tableAzureStorageContainer(ctx), + "azure_storage_queue": tableAzureStorageQueue(ctx), + "azure_storage_table": tableAzureStorageTable(ctx), + "azure_storage_table_service": tableAzureStorageTableService(ctx), + "azure_subnet": tableAzureSubnet(ctx), + "azure_subscription": tableAzureSubscription(ctx), + "azure_tenant": tableAzureTenant(ctx), + "azure_virtual_network": tableAzureVirtualNetwork(ctx), // "azure_storage_table": tableAzureStorageTable(ctx), }, } diff --git a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_daily.go b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_daily.go new file mode 100644 index 00000000..4509804e --- /dev/null +++ b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_daily.go @@ -0,0 +1,39 @@ +package azure + +import ( + "context" + + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2020-06-01/compute" + "github.com/turbot/steampipe-plugin-sdk/grpc/proto" + "github.com/turbot/steampipe-plugin-sdk/plugin" + "github.com/turbot/steampipe-plugin-sdk/plugin/transform" +) + +//// TABLE DEFINITION + +func tableComputeInstanceCpuUtilizationMetricDaily(_ context.Context) *plugin.Table { + return &plugin.Table{ + Name: "azure_compute_virtual_machine_metric_cpu_utilization_daily", + Description: "Azure Compute Virtual Machine Daily Metrics - CPU Utilization", + List: &plugin.ListConfig{ + ParentHydrate: listAzureComputeVirtualMachines, + Hydrate: listComputeVirtualMachineMMetricCpuUtilizationDaily, + }, + Columns: monitoringMetricColumns([]*plugin.Column{ + { + Name: "name", + Description: "The name of the virtual machine instance.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("DimensionValue"), + }, + }), + } +} + +//// LIST FUNCTION + +func listComputeVirtualMachineMMetricCpuUtilizationDaily(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + vmInfo := h.Item.(compute.VirtualMachine) + + return listAzureMonitorMetricStatistics(ctx, d, "DAILY", "Microsoft.Compute/virtualMachines", "Percentage CPU", *vmInfo.ID) +} diff --git a/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization.md b/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization.md index 07c31976..8c7ab88f 100644 --- a/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization.md +++ b/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization.md @@ -1,6 +1,6 @@ # Table: azure_compute_virtual_machine_metric_cpu_utilization -GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_virtual_machine_metric_cpu_utilization` table provides metric statistics at 5 minute intervals for the most recent 5 days. +GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_virtual_machine_metric_cpu_utilization` table provides metric statistics at 5 minute intervals for the most recent 1 year. ## Examples diff --git a/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_daily.md b/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_daily.md new file mode 100644 index 00000000..14ee3e64 --- /dev/null +++ b/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_daily.md @@ -0,0 +1,40 @@ +# Table: azure_compute_virtual_machine_metric_cpu_utilization_daily + +GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_virtual_machine_metric_cpu_utilization_daily` table provides metric statistics at 24 hours intervals for the most recent 1 year. + +## Examples + +### Basic info + +```sql +select + name, + timestamp, + minimum, + maximum, + average, + sample_count +from + azure_compute_virtual_machine_metric_cpu_utilization_daily +order by + name, + timestamp; +``` + +### CPU Over 80% average + +```sql +select + name, + timestamp, + round(minimum::numeric,2) as min_cpu, + round(maximum::numeric,2) as max_cpu, + round(average::numeric,2) as avg_cpu, + sample_count +from + azure_compute_virtual_machine_metric_cpu_utilization_daily +where average > 80 +order by + name, + timestamp; +``` From 3925ca9c7c604d0e395bc713edcf5e9660b29a2a Mon Sep 17 00:00:00 2001 From: ParthaI Date: Thu, 1 Jul 2021 15:32:46 +0530 Subject: [PATCH 03/14] Add table azure_compute_virtual_machine_metric_cpu_utilization_hourly closes #160 --- azure/monitoring_metric.go | 2 +- azure/plugin.go | 125 +++++++++--------- ...l_machine_metric_cpu_utilization_hourly.go | 39 ++++++ ...l_machine_metric_cpu_utilization_hourly.md | 40 ++++++ 4 files changed, 143 insertions(+), 63 deletions(-) create mode 100644 azure/table_azure_compute_virtual_machine_metric_cpu_utilization_hourly.go create mode 100644 docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_hourly.md diff --git a/azure/monitoring_metric.go b/azure/monitoring_metric.go index 1583026c..514dba38 100644 --- a/azure/monitoring_metric.go +++ b/azure/monitoring_metric.go @@ -97,7 +97,7 @@ func commonMonitoringMetricColumns() []*plugin.Column { Type: proto.ColumnType_STRING, }, { - Name: "subscrition_id", + Name: "subscription_id", Description: "The time stamp used for the data point.", Type: proto.ColumnType_STRING, Transform: transform.FromField("SubscriptionID"), diff --git a/azure/plugin.go b/azure/plugin.go index c3f9d6f6..7c950b51 100644 --- a/azure/plugin.go +++ b/azure/plugin.go @@ -22,68 +22,69 @@ func Plugin(ctx context.Context) *plugin.Plugin { Schema: ConfigSchema, }, TableMap: map[string]*plugin.Table{ - "azure_ad_group": tableAzureAdGroup(ctx), - "azure_ad_service_principal": tableAzureAdServicePrincipal(ctx), - "azure_ad_user": tableAzureAdUser(ctx), - "azure_api_management": tableAzureAPIManagement(ctx), - "azure_app_service_environment": tableAzureAppServiceEnvironment(ctx), - "azure_app_service_function_app": tableAzureAppServiceFunctionApp(ctx), - "azure_app_service_plan": tableAzureAppServicePlan(ctx), - "azure_app_service_web_app": tableAzureAppServiceWebApp(ctx), - "azure_application_security_group": tableAzureApplicationSecurityGroup(ctx), - "azure_compute_availability_set": tableAzureComputeAvailabilitySet(ctx), - "azure_compute_disk": tableAzureComputeDisk(ctx), - "azure_compute_disk_encryption_set": tableAzureComputeDiskEncryptionSet(ctx), - "azure_compute_image": tableAzureComputeImage(ctx), - "azure_compute_resource_sku": tableAzureResourceSku(ctx), - "azure_compute_snapshot": tableAzureComputeSnapshot(ctx), - "azure_compute_virtual_machine": tableAzureComputeVirtualMachine(ctx), - "azure_compute_virtual_machine_metric_cpu_utilization": tableComputeInstanceCpuUtilizationMetric(ctx), - "azure_compute_virtual_machine_metric_cpu_utilization_daily": tableComputeInstanceCpuUtilizationMetricDaily(ctx), - "azure_cosmosdb_account": tableAzureCosmosDBAccount(ctx), - "azure_cosmosdb_mongo_database": tableAzureCosmosDBMongoDatabase(ctx), - "azure_cosmosdb_sql_database": tableAzureCosmosDBSQLDatabase(ctx), - "azure_diagnostic_setting": tableAzureDiagnosticSetting(ctx), - "azure_firewall": tableAzureFirewall(ctx), - "azure_key_vault": tableAzureKeyVault(ctx), - "azure_key_vault_key": tableAzureKeyVaultKey(ctx), - "azure_key_vault_secret": tableAzureKeyVaultSecret(ctx), - "azure_kubernetes_cluster": tableAzureKubernetesCluster(ctx), - "azure_location": tableAzureLocation(ctx), - "azure_log_alert": tableAzureLogAlert(ctx), - "azure_log_profile": tableAzureLogProfile(ctx), - "azure_management_lock": tableAzureManagementLock(ctx), - "azure_mysql_server": tableAzureMySQLServer(ctx), - "azure_network_interface": tableAzureNetworkInterface(ctx), - "azure_network_security_group": tableAzureNetworkSecurityGroup(ctx), - "azure_network_watcher": tableAzureNetworkWatcher(ctx), - "azure_network_watcher_flow_log": tableAzureNetworkWatcherFlowLog(ctx), - "azure_policy_assignment": tableAzurePolicyAssignment(ctx), - "azure_policy_definition": tableAzurePolicyDefinition(ctx), - "azure_postgresql_server": tableAzurePostgreSqlServer(ctx), - "azure_provider": tableAzureProvider(ctx), - "azure_public_ip": tableAzurePublicIP(ctx), - "azure_resource_group": tableAzureResourceGroup(ctx), - "azure_role_assignment": tableAzureIamRoleAssignment(ctx), - "azure_role_definition": tableAzureIamRoleDefinition(ctx), - "azure_route_table": tableAzureRouteTable(ctx), - "azure_security_center_auto_provisioning": tableAzureSecurityCenterAutoProvisioning(ctx), - "azure_security_center_contact": tableAzureSecurityCenterContact(ctx), - "azure_security_center_setting": tableAzureSecurityCenterSetting(ctx), - "azure_security_center_subscription_pricing": tableAzureSecurityCenterPricing(ctx), - "azure_sql_database": tableAzureSqlDatabase(ctx), - "azure_sql_server": tableAzureSQLServer(ctx), - "azure_storage_account": tableAzureStorageAccount(ctx), - "azure_storage_blob": tableAzureStorageBlob(ctx), - "azure_storage_blob_service": tableAzureStorageBlobService(ctx), - "azure_storage_container": tableAzureStorageContainer(ctx), - "azure_storage_queue": tableAzureStorageQueue(ctx), - "azure_storage_table": tableAzureStorageTable(ctx), - "azure_storage_table_service": tableAzureStorageTableService(ctx), - "azure_subnet": tableAzureSubnet(ctx), - "azure_subscription": tableAzureSubscription(ctx), - "azure_tenant": tableAzureTenant(ctx), - "azure_virtual_network": tableAzureVirtualNetwork(ctx), + "azure_ad_group": tableAzureAdGroup(ctx), + "azure_ad_service_principal": tableAzureAdServicePrincipal(ctx), + "azure_ad_user": tableAzureAdUser(ctx), + "azure_api_management": tableAzureAPIManagement(ctx), + "azure_app_service_environment": tableAzureAppServiceEnvironment(ctx), + "azure_app_service_function_app": tableAzureAppServiceFunctionApp(ctx), + "azure_app_service_plan": tableAzureAppServicePlan(ctx), + "azure_app_service_web_app": tableAzureAppServiceWebApp(ctx), + "azure_application_security_group": tableAzureApplicationSecurityGroup(ctx), + "azure_compute_availability_set": tableAzureComputeAvailabilitySet(ctx), + "azure_compute_disk": tableAzureComputeDisk(ctx), + "azure_compute_disk_encryption_set": tableAzureComputeDiskEncryptionSet(ctx), + "azure_compute_image": tableAzureComputeImage(ctx), + "azure_compute_resource_sku": tableAzureResourceSku(ctx), + "azure_compute_snapshot": tableAzureComputeSnapshot(ctx), + "azure_compute_virtual_machine": tableAzureComputeVirtualMachine(ctx), + "azure_compute_virtual_machine_metric_cpu_utilization": tableComputeInstanceCpuUtilizationMetric(ctx), + "azure_compute_virtual_machine_metric_cpu_utilization_daily": tableComputeInstanceCpuUtilizationMetricDaily(ctx), + "azure_compute_virtual_machine_metric_cpu_utilization_hourly": tableComputeInstanceCpuUtilizationMetricHourly(ctx), + "azure_cosmosdb_account": tableAzureCosmosDBAccount(ctx), + "azure_cosmosdb_mongo_database": tableAzureCosmosDBMongoDatabase(ctx), + "azure_cosmosdb_sql_database": tableAzureCosmosDBSQLDatabase(ctx), + "azure_diagnostic_setting": tableAzureDiagnosticSetting(ctx), + "azure_firewall": tableAzureFirewall(ctx), + "azure_key_vault": tableAzureKeyVault(ctx), + "azure_key_vault_key": tableAzureKeyVaultKey(ctx), + "azure_key_vault_secret": tableAzureKeyVaultSecret(ctx), + "azure_kubernetes_cluster": tableAzureKubernetesCluster(ctx), + "azure_location": tableAzureLocation(ctx), + "azure_log_alert": tableAzureLogAlert(ctx), + "azure_log_profile": tableAzureLogProfile(ctx), + "azure_management_lock": tableAzureManagementLock(ctx), + "azure_mysql_server": tableAzureMySQLServer(ctx), + "azure_network_interface": tableAzureNetworkInterface(ctx), + "azure_network_security_group": tableAzureNetworkSecurityGroup(ctx), + "azure_network_watcher": tableAzureNetworkWatcher(ctx), + "azure_network_watcher_flow_log": tableAzureNetworkWatcherFlowLog(ctx), + "azure_policy_assignment": tableAzurePolicyAssignment(ctx), + "azure_policy_definition": tableAzurePolicyDefinition(ctx), + "azure_postgresql_server": tableAzurePostgreSqlServer(ctx), + "azure_provider": tableAzureProvider(ctx), + "azure_public_ip": tableAzurePublicIP(ctx), + "azure_resource_group": tableAzureResourceGroup(ctx), + "azure_role_assignment": tableAzureIamRoleAssignment(ctx), + "azure_role_definition": tableAzureIamRoleDefinition(ctx), + "azure_route_table": tableAzureRouteTable(ctx), + "azure_security_center_auto_provisioning": tableAzureSecurityCenterAutoProvisioning(ctx), + "azure_security_center_contact": tableAzureSecurityCenterContact(ctx), + "azure_security_center_setting": tableAzureSecurityCenterSetting(ctx), + "azure_security_center_subscription_pricing": tableAzureSecurityCenterPricing(ctx), + "azure_sql_database": tableAzureSqlDatabase(ctx), + "azure_sql_server": tableAzureSQLServer(ctx), + "azure_storage_account": tableAzureStorageAccount(ctx), + "azure_storage_blob": tableAzureStorageBlob(ctx), + "azure_storage_blob_service": tableAzureStorageBlobService(ctx), + "azure_storage_container": tableAzureStorageContainer(ctx), + "azure_storage_queue": tableAzureStorageQueue(ctx), + "azure_storage_table": tableAzureStorageTable(ctx), + "azure_storage_table_service": tableAzureStorageTableService(ctx), + "azure_subnet": tableAzureSubnet(ctx), + "azure_subscription": tableAzureSubscription(ctx), + "azure_tenant": tableAzureTenant(ctx), + "azure_virtual_network": tableAzureVirtualNetwork(ctx), // "azure_storage_table": tableAzureStorageTable(ctx), }, } diff --git a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_hourly.go b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_hourly.go new file mode 100644 index 00000000..8618ddb7 --- /dev/null +++ b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_hourly.go @@ -0,0 +1,39 @@ +package azure + +import ( + "context" + + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2020-06-01/compute" + "github.com/turbot/steampipe-plugin-sdk/grpc/proto" + "github.com/turbot/steampipe-plugin-sdk/plugin" + "github.com/turbot/steampipe-plugin-sdk/plugin/transform" +) + +//// TABLE DEFINITION + +func tableComputeInstanceCpuUtilizationMetricHourly(_ context.Context) *plugin.Table { + return &plugin.Table{ + Name: "azure_compute_virtual_machine_metric_cpu_utilization_hourly", + Description: "Azure Compute Virtual Machine Hourly Metrics - CPU Utilization", + List: &plugin.ListConfig{ + ParentHydrate: listAzureComputeVirtualMachines, + Hydrate: listComputeVirtualMachineMMetricCpuUtilizationHourly, + }, + Columns: monitoringMetricColumns([]*plugin.Column{ + { + Name: "name", + Description: "The name of the virtual machine instance.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("DimensionValue"), + }, + }), + } +} + +//// LIST FUNCTION + +func listComputeVirtualMachineMMetricCpuUtilizationHourly(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + vmInfo := h.Item.(compute.VirtualMachine) + + return listAzureMonitorMetricStatistics(ctx, d, "HOURLY", "Microsoft.Compute/virtualMachines", "Percentage CPU", *vmInfo.ID) +} diff --git a/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_hourly.md b/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_hourly.md new file mode 100644 index 00000000..0f34c20e --- /dev/null +++ b/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_hourly.md @@ -0,0 +1,40 @@ +# Table: azure_compute_virtual_machine_metric_cpu_utilization_hourly + +GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_virtual_machine_metric_cpu_utilization_hourly` table provides metric statistics at 1 hour intervals for the most recent 1 year. + +## Examples + +### Basic info + +```sql +select + name, + timestamp, + minimum, + maximum, + average, + sample_count +from + azure_compute_virtual_machine_metric_cpu_utilization_hourly +order by + name, + timestamp; +``` + +### CPU Over 80% average + +```sql +select + name, + timestamp, + round(minimum::numeric,2) as min_cpu, + round(maximum::numeric,2) as max_cpu, + round(average::numeric,2) as avg_cpu, + sample_count +from + azure_compute_virtual_machine_metric_cpu_utilization_hourly +where average > 80 +order by + name, + timestamp; +``` From 292526ee2355734f0046a716f8a263964ed060b4 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Thu, 1 Jul 2021 18:01:19 +0530 Subject: [PATCH 04/14] Add table azure_compute_disk_metric_read_ops closes #161 --- azure/plugin.go | 1 + ...able_azure_compute_disk_metric_read_ops.go | 39 ++++++++++++++++++ ..._virtual_machine_metric_cpu_utilization.go | 4 +- ...al_machine_metric_cpu_utilization_daily.go | 4 +- ...l_machine_metric_cpu_utilization_hourly.go | 4 +- .../azure_compute_disk_metric_read_ops.md | 40 +++++++++++++++++++ 6 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 azure/table_azure_compute_disk_metric_read_ops.go create mode 100644 docs/tables/azure_compute_disk_metric_read_ops.md diff --git a/azure/plugin.go b/azure/plugin.go index 7c950b51..a71a9651 100644 --- a/azure/plugin.go +++ b/azure/plugin.go @@ -34,6 +34,7 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_compute_availability_set": tableAzureComputeAvailabilitySet(ctx), "azure_compute_disk": tableAzureComputeDisk(ctx), "azure_compute_disk_encryption_set": tableAzureComputeDiskEncryptionSet(ctx), + "azure_compute_disk_metric_read_ops": tableComputeDisksReadOpsMetric(ctx), "azure_compute_image": tableAzureComputeImage(ctx), "azure_compute_resource_sku": tableAzureResourceSku(ctx), "azure_compute_snapshot": tableAzureComputeSnapshot(ctx), diff --git a/azure/table_azure_compute_disk_metric_read_ops.go b/azure/table_azure_compute_disk_metric_read_ops.go new file mode 100644 index 00000000..72116e83 --- /dev/null +++ b/azure/table_azure_compute_disk_metric_read_ops.go @@ -0,0 +1,39 @@ +package azure + +import ( + "context" + + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2020-06-01/compute" + "github.com/turbot/steampipe-plugin-sdk/grpc/proto" + "github.com/turbot/steampipe-plugin-sdk/plugin" + "github.com/turbot/steampipe-plugin-sdk/plugin/transform" +) + +//// TABLE DEFINITION + +func tableComputeDisksReadOpsMetric(_ context.Context) *plugin.Table { + return &plugin.Table{ + Name: "azure_compute_disk_metric_read_ops", + Description: "Azure Compute Disk Metrics - Read Ops", + List: &plugin.ListConfig{ + ParentHydrate: listAzureComputeDisks, + Hydrate: listComputeDiskMetricReadOps, + }, + Columns: monitoringMetricColumns([]*plugin.Column{ + { + Name: "name", + Description: "The name of the compute disk.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("DimensionValue"), + }, + }), + } +} + +//// LIST FUNCTION + +func listComputeDiskMetricReadOps(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + diskInfo := h.Item.(compute.Disk) + + return listAzureMonitorMetricStatistics(ctx, d, "FIVE_MINUTES", "Microsoft.Compute/disks", "Composite Disk Read Operations/sec", *diskInfo.ID) +} diff --git a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization.go b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization.go index fbafa457..0b17303a 100644 --- a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization.go +++ b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization.go @@ -17,7 +17,7 @@ func tableComputeInstanceCpuUtilizationMetric(_ context.Context) *plugin.Table { Description: "Azure Compute Virtual Machine Metrics - CPU Utilization", List: &plugin.ListConfig{ ParentHydrate: listAzureComputeVirtualMachines, - Hydrate: listComputeVirtualMachineMMetricCpuUtilization, + Hydrate: listComputeVirtualMachineMetricCpuUtilization, }, Columns: monitoringMetricColumns([]*plugin.Column{ { @@ -32,7 +32,7 @@ func tableComputeInstanceCpuUtilizationMetric(_ context.Context) *plugin.Table { //// LIST FUNCTION -func listComputeVirtualMachineMMetricCpuUtilization(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { +func listComputeVirtualMachineMetricCpuUtilization(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { vmInfo := h.Item.(compute.VirtualMachine) return listAzureMonitorMetricStatistics(ctx, d, "FIVE_MINUTES", "Microsoft.Compute/virtualMachines", "Percentage CPU", *vmInfo.ID) diff --git a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_daily.go b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_daily.go index 4509804e..57548e08 100644 --- a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_daily.go +++ b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_daily.go @@ -17,7 +17,7 @@ func tableComputeInstanceCpuUtilizationMetricDaily(_ context.Context) *plugin.Ta Description: "Azure Compute Virtual Machine Daily Metrics - CPU Utilization", List: &plugin.ListConfig{ ParentHydrate: listAzureComputeVirtualMachines, - Hydrate: listComputeVirtualMachineMMetricCpuUtilizationDaily, + Hydrate: listComputeVirtualMachineMetricCpuUtilizationDaily, }, Columns: monitoringMetricColumns([]*plugin.Column{ { @@ -32,7 +32,7 @@ func tableComputeInstanceCpuUtilizationMetricDaily(_ context.Context) *plugin.Ta //// LIST FUNCTION -func listComputeVirtualMachineMMetricCpuUtilizationDaily(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { +func listComputeVirtualMachineMetricCpuUtilizationDaily(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { vmInfo := h.Item.(compute.VirtualMachine) return listAzureMonitorMetricStatistics(ctx, d, "DAILY", "Microsoft.Compute/virtualMachines", "Percentage CPU", *vmInfo.ID) diff --git a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_hourly.go b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_hourly.go index 8618ddb7..a715b2e1 100644 --- a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_hourly.go +++ b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_hourly.go @@ -17,7 +17,7 @@ func tableComputeInstanceCpuUtilizationMetricHourly(_ context.Context) *plugin.T Description: "Azure Compute Virtual Machine Hourly Metrics - CPU Utilization", List: &plugin.ListConfig{ ParentHydrate: listAzureComputeVirtualMachines, - Hydrate: listComputeVirtualMachineMMetricCpuUtilizationHourly, + Hydrate: listComputeVirtualMachineMetricCpuUtilizationHourly, }, Columns: monitoringMetricColumns([]*plugin.Column{ { @@ -32,7 +32,7 @@ func tableComputeInstanceCpuUtilizationMetricHourly(_ context.Context) *plugin.T //// LIST FUNCTION -func listComputeVirtualMachineMMetricCpuUtilizationHourly(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { +func listComputeVirtualMachineMetricCpuUtilizationHourly(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { vmInfo := h.Item.(compute.VirtualMachine) return listAzureMonitorMetricStatistics(ctx, d, "HOURLY", "Microsoft.Compute/virtualMachines", "Percentage CPU", *vmInfo.ID) diff --git a/docs/tables/azure_compute_disk_metric_read_ops.md b/docs/tables/azure_compute_disk_metric_read_ops.md new file mode 100644 index 00000000..379c93ee --- /dev/null +++ b/docs/tables/azure_compute_disk_metric_read_ops.md @@ -0,0 +1,40 @@ +# Table: azure_compute_disk_metric_read_ops + +GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_read_ops` table provides metric statistics at 5 minute intervals for the most recent 1 year. + +## Examples + +### Basic info + +```sql +select + name, + timestamp, + minimum, + maximum, + average, + sample_count +from + azure_compute_disk_metric_read_ops +order by + name, + timestamp; +``` + +### CPU Over 10 Bytes average + +```sql +select + name, + timestamp, + round(minimum::numeric,2) as min_read_ops, + round(maximum::numeric,2) as max_read_ops, + round(average::numeric,2) as avg_read_ops, + sample_count +from + azure_compute_disk_metric_read_ops +where average > 10 +order by + name, + timestamp; +``` From be86b2eb2c07253bcd12a3e312d6fde5cba21971 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Thu, 1 Jul 2021 18:10:00 +0530 Subject: [PATCH 05/14] Add table azure_compute_disk_metric_read_ops_hourly closes #162 --- azure/plugin.go | 1 + ...ure_compute_disk_metric_read_ops_hourly.go | 39 ++++++++++++++++++ ...ure_compute_disk_metric_read_ops_hourly.md | 40 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 azure/table_azure_compute_disk_metric_read_ops_hourly.go create mode 100644 docs/tables/azure_compute_disk_metric_read_ops_hourly.md diff --git a/azure/plugin.go b/azure/plugin.go index a71a9651..1d7ff699 100644 --- a/azure/plugin.go +++ b/azure/plugin.go @@ -35,6 +35,7 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_compute_disk": tableAzureComputeDisk(ctx), "azure_compute_disk_encryption_set": tableAzureComputeDiskEncryptionSet(ctx), "azure_compute_disk_metric_read_ops": tableComputeDisksReadOpsMetric(ctx), + "azure_compute_disk_metric_read_ops_hourly": tableComputeDisksReadOpsMetricHourly(ctx), "azure_compute_image": tableAzureComputeImage(ctx), "azure_compute_resource_sku": tableAzureResourceSku(ctx), "azure_compute_snapshot": tableAzureComputeSnapshot(ctx), diff --git a/azure/table_azure_compute_disk_metric_read_ops_hourly.go b/azure/table_azure_compute_disk_metric_read_ops_hourly.go new file mode 100644 index 00000000..cb4fee3f --- /dev/null +++ b/azure/table_azure_compute_disk_metric_read_ops_hourly.go @@ -0,0 +1,39 @@ +package azure + +import ( + "context" + + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2020-06-01/compute" + "github.com/turbot/steampipe-plugin-sdk/grpc/proto" + "github.com/turbot/steampipe-plugin-sdk/plugin" + "github.com/turbot/steampipe-plugin-sdk/plugin/transform" +) + +//// TABLE DEFINITION + +func tableComputeDisksReadOpsMetricHourly(_ context.Context) *plugin.Table { + return &plugin.Table{ + Name: "azure_compute_disk_metric_read_ops_hourly", + Description: "Azure Compute Disk Metrics - Read Ops Hourly", + List: &plugin.ListConfig{ + ParentHydrate: listAzureComputeDisks, + Hydrate: listComputeDiskMetricReadOpsHourly, + }, + Columns: monitoringMetricColumns([]*plugin.Column{ + { + Name: "name", + Description: "The name of the compute disk.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("DimensionValue"), + }, + }), + } +} + +//// LIST FUNCTION + +func listComputeDiskMetricReadOpsHourly(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + diskInfo := h.Item.(compute.Disk) + + return listAzureMonitorMetricStatistics(ctx, d, "HOURLY", "Microsoft.Compute/disks", "Composite Disk Read Operations/sec", *diskInfo.ID) +} diff --git a/docs/tables/azure_compute_disk_metric_read_ops_hourly.md b/docs/tables/azure_compute_disk_metric_read_ops_hourly.md new file mode 100644 index 00000000..7461579d --- /dev/null +++ b/docs/tables/azure_compute_disk_metric_read_ops_hourly.md @@ -0,0 +1,40 @@ +# Table: azure_compute_disk_metric_read_ops_hourly + +GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_read_ops_hourly` table provides metric statistics at 60 minute intervals for the most recent 1 year. + +## Examples + +### Basic info + +```sql +select + name, + timestamp, + minimum, + maximum, + average, + sample_count +from + azure_compute_disk_metric_read_ops_hourly +order by + name, + timestamp; +``` + +### CPU Over 10 Bytes average + +```sql +select + name, + timestamp, + round(minimum::numeric,2) as min_read_ops, + round(maximum::numeric,2) as max_read_ops, + round(average::numeric,2) as avg_read_ops, + sample_count +from + azure_compute_disk_metric_read_ops_hourly +where average > 10 +order by + name, + timestamp; +``` From 1b11b21ebfaa0269dcfb0cf1abbe3f63f91eb753 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Thu, 1 Jul 2021 18:24:29 +0530 Subject: [PATCH 06/14] Add table azure_compute_disk_metric_read_ops_daily closes #148 --- azure/plugin.go | 1 + ...zure_compute_disk_metric_read_ops_daily.go | 39 ++++++++++++++++++ ...zure_compute_disk_metric_read_ops_daily.md | 40 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 azure/table_azure_compute_disk_metric_read_ops_daily.go create mode 100644 docs/tables/azure_compute_disk_metric_read_ops_daily.md diff --git a/azure/plugin.go b/azure/plugin.go index 1d7ff699..e4ebbc04 100644 --- a/azure/plugin.go +++ b/azure/plugin.go @@ -36,6 +36,7 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_compute_disk_encryption_set": tableAzureComputeDiskEncryptionSet(ctx), "azure_compute_disk_metric_read_ops": tableComputeDisksReadOpsMetric(ctx), "azure_compute_disk_metric_read_ops_hourly": tableComputeDisksReadOpsMetricHourly(ctx), + "azure_compute_disk_metric_read_ops_daily": tableComputeDisksReadOpsMetricDaily(ctx), "azure_compute_image": tableAzureComputeImage(ctx), "azure_compute_resource_sku": tableAzureResourceSku(ctx), "azure_compute_snapshot": tableAzureComputeSnapshot(ctx), diff --git a/azure/table_azure_compute_disk_metric_read_ops_daily.go b/azure/table_azure_compute_disk_metric_read_ops_daily.go new file mode 100644 index 00000000..f686a6f5 --- /dev/null +++ b/azure/table_azure_compute_disk_metric_read_ops_daily.go @@ -0,0 +1,39 @@ +package azure + +import ( + "context" + + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2020-06-01/compute" + "github.com/turbot/steampipe-plugin-sdk/grpc/proto" + "github.com/turbot/steampipe-plugin-sdk/plugin" + "github.com/turbot/steampipe-plugin-sdk/plugin/transform" +) + +//// TABLE DEFINITION + +func tableComputeDisksReadOpsMetricDaily(_ context.Context) *plugin.Table { + return &plugin.Table{ + Name: "azure_compute_disk_metric_read_ops_daily", + Description: "Azure Compute Disk Metrics - Read Ops Daily", + List: &plugin.ListConfig{ + ParentHydrate: listAzureComputeDisks, + Hydrate: listComputeDiskMetricReadOpsDaily, + }, + Columns: monitoringMetricColumns([]*plugin.Column{ + { + Name: "name", + Description: "The name of the compute disk.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("DimensionValue"), + }, + }), + } +} + +//// LIST FUNCTION + +func listComputeDiskMetricReadOpsDaily(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + diskInfo := h.Item.(compute.Disk) + + return listAzureMonitorMetricStatistics(ctx, d, "DAILY", "Microsoft.Compute/disks", "Composite Disk Read Operations/sec", *diskInfo.ID) +} diff --git a/docs/tables/azure_compute_disk_metric_read_ops_daily.md b/docs/tables/azure_compute_disk_metric_read_ops_daily.md new file mode 100644 index 00000000..24cbbf78 --- /dev/null +++ b/docs/tables/azure_compute_disk_metric_read_ops_daily.md @@ -0,0 +1,40 @@ +# Table: azure_compute_disk_metric_read_ops_daily + +GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_read_ops_daily` table provides metric statistics at 24 hours intervals for the most recent 1 year. + +## Examples + +### Basic info + +```sql +select + name, + timestamp, + minimum, + maximum, + average, + sample_count +from + azure_compute_disk_metric_read_ops_daily +order by + name, + timestamp; +``` + +### CPU Over 10 Bytes average + +```sql +select + name, + timestamp, + round(minimum::numeric,2) as min_read_ops, + round(maximum::numeric,2) as max_read_ops, + round(average::numeric,2) as avg_read_ops, + sample_count +from + azure_compute_disk_metric_read_ops_daily +where average > 10 +order by + name, + timestamp; +``` From 6c12bbbd75b1fa490e34eb2306cffbf280bdecaa Mon Sep 17 00:00:00 2001 From: ParthaI Date: Fri, 2 Jul 2021 10:21:15 +0530 Subject: [PATCH 07/14] Add table azure_compute_disk_metric_write_ops closes #164 --- azure/plugin.go | 1 + ...ble_azure_compute_disk_metric_write_ops.go | 39 ++++++++++++++++++ .../azure_compute_disk_metric_write_ops.md | 40 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 azure/table_azure_compute_disk_metric_write_ops.go create mode 100644 docs/tables/azure_compute_disk_metric_write_ops.md diff --git a/azure/plugin.go b/azure/plugin.go index e4ebbc04..4dd5d135 100644 --- a/azure/plugin.go +++ b/azure/plugin.go @@ -37,6 +37,7 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_compute_disk_metric_read_ops": tableComputeDisksReadOpsMetric(ctx), "azure_compute_disk_metric_read_ops_hourly": tableComputeDisksReadOpsMetricHourly(ctx), "azure_compute_disk_metric_read_ops_daily": tableComputeDisksReadOpsMetricDaily(ctx), + "azure_compute_disk_metric_write_ops": tableComputeDisksWriteOpsMetric(ctx), "azure_compute_image": tableAzureComputeImage(ctx), "azure_compute_resource_sku": tableAzureResourceSku(ctx), "azure_compute_snapshot": tableAzureComputeSnapshot(ctx), diff --git a/azure/table_azure_compute_disk_metric_write_ops.go b/azure/table_azure_compute_disk_metric_write_ops.go new file mode 100644 index 00000000..8c46326c --- /dev/null +++ b/azure/table_azure_compute_disk_metric_write_ops.go @@ -0,0 +1,39 @@ +package azure + +import ( + "context" + + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2020-06-01/compute" + "github.com/turbot/steampipe-plugin-sdk/grpc/proto" + "github.com/turbot/steampipe-plugin-sdk/plugin" + "github.com/turbot/steampipe-plugin-sdk/plugin/transform" +) + +//// TABLE DEFINITION + +func tableComputeDisksWriteOpsMetric(_ context.Context) *plugin.Table { + return &plugin.Table{ + Name: "azure_compute_disk_metric_write_ops", + Description: "Azure Compute Disk Metrics - Write Ops", + List: &plugin.ListConfig{ + ParentHydrate: listAzureComputeDisks, + Hydrate: listComputeDiskMetricWriteOps, + }, + Columns: monitoringMetricColumns([]*plugin.Column{ + { + Name: "name", + Description: "The name of the compute disk.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("DimensionValue"), + }, + }), + } +} + +//// LIST FUNCTION + +func listComputeDiskMetricWriteOps(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + diskInfo := h.Item.(compute.Disk) + + return listAzureMonitorMetricStatistics(ctx, d, "FIVE_MINUTES", "Microsoft.Compute/disks", "Composite Disk Write Operations/sec", *diskInfo.ID) +} diff --git a/docs/tables/azure_compute_disk_metric_write_ops.md b/docs/tables/azure_compute_disk_metric_write_ops.md new file mode 100644 index 00000000..80861aae --- /dev/null +++ b/docs/tables/azure_compute_disk_metric_write_ops.md @@ -0,0 +1,40 @@ +# Table: azure_compute_disk_metric_write_ops + +GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_write_ops` table provides metric statistics at 5 minute intervals for the most recent 1 year. + +## Examples + +### Basic info + +```sql +select + name, + timestamp, + minimum, + maximum, + average, + sample_count +from + azure_compute_disk_metric_write_ops +order by + name, + timestamp; +``` + +### CPU Over 10 Bytes average + +```sql +select + name, + timestamp, + round(minimum::numeric,2) as min_write_ops, + round(maximum::numeric,2) as max_write_ops, + round(average::numeric,2) as avg_write_ops, + sample_count +from + azure_compute_disk_metric_write_ops +where average > 10 +order by + name, + timestamp; +``` From d2800fac20c157ac6623bcdc029e4fadb626ed28 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Fri, 2 Jul 2021 10:22:59 +0530 Subject: [PATCH 08/14] Update the doc --- docs/tables/azure_compute_disk_metric_read_ops.md | 2 +- docs/tables/azure_compute_disk_metric_read_ops_daily.md | 2 +- docs/tables/azure_compute_disk_metric_read_ops_hourly.md | 2 +- docs/tables/azure_compute_disk_metric_write_ops.md | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/tables/azure_compute_disk_metric_read_ops.md b/docs/tables/azure_compute_disk_metric_read_ops.md index 379c93ee..840cb261 100644 --- a/docs/tables/azure_compute_disk_metric_read_ops.md +++ b/docs/tables/azure_compute_disk_metric_read_ops.md @@ -21,7 +21,7 @@ order by timestamp; ``` -### CPU Over 10 Bytes average +### Operations Over 10 Bytes average ```sql select diff --git a/docs/tables/azure_compute_disk_metric_read_ops_daily.md b/docs/tables/azure_compute_disk_metric_read_ops_daily.md index 24cbbf78..5e94fb37 100644 --- a/docs/tables/azure_compute_disk_metric_read_ops_daily.md +++ b/docs/tables/azure_compute_disk_metric_read_ops_daily.md @@ -21,7 +21,7 @@ order by timestamp; ``` -### CPU Over 10 Bytes average +### Operations Over 10 Bytes average ```sql select diff --git a/docs/tables/azure_compute_disk_metric_read_ops_hourly.md b/docs/tables/azure_compute_disk_metric_read_ops_hourly.md index 7461579d..79a83197 100644 --- a/docs/tables/azure_compute_disk_metric_read_ops_hourly.md +++ b/docs/tables/azure_compute_disk_metric_read_ops_hourly.md @@ -21,7 +21,7 @@ order by timestamp; ``` -### CPU Over 10 Bytes average +### Operations Over 10 Bytes average ```sql select diff --git a/docs/tables/azure_compute_disk_metric_write_ops.md b/docs/tables/azure_compute_disk_metric_write_ops.md index 80861aae..2aecacba 100644 --- a/docs/tables/azure_compute_disk_metric_write_ops.md +++ b/docs/tables/azure_compute_disk_metric_write_ops.md @@ -21,7 +21,7 @@ order by timestamp; ``` -### CPU Over 10 Bytes average +### Operations Over 10 Bytes average ```sql select From 311537b3fb535a294f711bcbb549068bb6cb38b5 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Fri, 2 Jul 2021 10:28:55 +0530 Subject: [PATCH 09/14] Add table azure_compute_disk_metric_write_ops_hourly closes #165 --- azure/plugin.go | 1 + ...re_compute_disk_metric_write_ops_hourly.go | 39 ++++++++++++++++++ ...re_compute_disk_metric_write_ops_hourly.md | 40 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 azure/table_azure_compute_disk_metric_write_ops_hourly.go create mode 100644 docs/tables/azure_compute_disk_metric_write_ops_hourly.md diff --git a/azure/plugin.go b/azure/plugin.go index 4dd5d135..806e0da5 100644 --- a/azure/plugin.go +++ b/azure/plugin.go @@ -38,6 +38,7 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_compute_disk_metric_read_ops_hourly": tableComputeDisksReadOpsMetricHourly(ctx), "azure_compute_disk_metric_read_ops_daily": tableComputeDisksReadOpsMetricDaily(ctx), "azure_compute_disk_metric_write_ops": tableComputeDisksWriteOpsMetric(ctx), + "azure_compute_disk_metric_write_ops_hourly": tableComputeDisksWriteOpsMetricHourly(ctx), "azure_compute_image": tableAzureComputeImage(ctx), "azure_compute_resource_sku": tableAzureResourceSku(ctx), "azure_compute_snapshot": tableAzureComputeSnapshot(ctx), diff --git a/azure/table_azure_compute_disk_metric_write_ops_hourly.go b/azure/table_azure_compute_disk_metric_write_ops_hourly.go new file mode 100644 index 00000000..684526c3 --- /dev/null +++ b/azure/table_azure_compute_disk_metric_write_ops_hourly.go @@ -0,0 +1,39 @@ +package azure + +import ( + "context" + + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2020-06-01/compute" + "github.com/turbot/steampipe-plugin-sdk/grpc/proto" + "github.com/turbot/steampipe-plugin-sdk/plugin" + "github.com/turbot/steampipe-plugin-sdk/plugin/transform" +) + +//// TABLE DEFINITION + +func tableComputeDisksWriteOpsMetricHourly(_ context.Context) *plugin.Table { + return &plugin.Table{ + Name: "azure_compute_disk_metric_write_ops_hourly", + Description: "Azure Compute Disk Metrics - Write Ops Hourly", + List: &plugin.ListConfig{ + ParentHydrate: listAzureComputeDisks, + Hydrate: listComputeDiskMetricWriteOpsHourly, + }, + Columns: monitoringMetricColumns([]*plugin.Column{ + { + Name: "name", + Description: "The name of the compute disk.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("DimensionValue"), + }, + }), + } +} + +//// LIST FUNCTION + +func listComputeDiskMetricWriteOpsHourly(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + diskInfo := h.Item.(compute.Disk) + + return listAzureMonitorMetricStatistics(ctx, d, "HOURLY", "Microsoft.Compute/disks", "Composite Disk Write Operations/sec", *diskInfo.ID) +} diff --git a/docs/tables/azure_compute_disk_metric_write_ops_hourly.md b/docs/tables/azure_compute_disk_metric_write_ops_hourly.md new file mode 100644 index 00000000..c9edc63d --- /dev/null +++ b/docs/tables/azure_compute_disk_metric_write_ops_hourly.md @@ -0,0 +1,40 @@ +# Table: azure_compute_disk_metric_write_ops_hourly + +GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_write_ops_hourly` table provides metric statistics at 5 minute intervals for the most recent 1 year. + +## Examples + +### Basic info + +```sql +select + name, + timestamp, + minimum, + maximum, + average, + sample_count +from + azure_compute_disk_metric_write_ops_hourly +order by + name, + timestamp; +``` + +### Operations Over 10 Bytes average + +```sql +select + name, + timestamp, + round(minimum::numeric,2) as min_write_ops, + round(maximum::numeric,2) as max_write_ops, + round(average::numeric,2) as avg_write_ops, + sample_count +from + azure_compute_disk_metric_write_ops_hourly +where average > 10 +order by + name, + timestamp; +``` From b8ede4bb6bfce3cfddf06c0434720d99077737d1 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Fri, 2 Jul 2021 10:42:04 +0530 Subject: [PATCH 10/14] Add table azure_compute_disk_metric_write_ops_daily closes #149 --- azure/monitoring_metric.go | 2 +- azure/plugin.go | 1 + ...ure_compute_disk_metric_write_ops_daily.go | 39 ++++++++++++++++++ ...ure_compute_disk_metric_write_ops_daily.md | 40 +++++++++++++++++++ ...re_compute_disk_metric_write_ops_hourly.md | 2 +- 5 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 azure/table_azure_compute_disk_metric_write_ops_daily.go create mode 100644 docs/tables/azure_compute_disk_metric_write_ops_daily.md diff --git a/azure/monitoring_metric.go b/azure/monitoring_metric.go index 514dba38..a9e1c88f 100644 --- a/azure/monitoring_metric.go +++ b/azure/monitoring_metric.go @@ -131,7 +131,7 @@ func listAzureMonitorMetricStatistics(ctx context.Context, d *plugin.QueryData, // Define param values interval := getMonitoringIntervalForGranularity(granularity) aggregation := "average,count,maximum,minimum,total" - timeSpan := time.Now().UTC().AddDate(-1, 0, 0).Format(time.RFC3339) + "/" + time.Now().UTC().Format(time.RFC3339) // Retrive data within a year + timeSpan := time.Now().UTC().AddDate(-1, 0, 0).Format(time.RFC3339) + "/" + time.Now().UTC().AddDate(0, 0, 1).Format(time.RFC3339) // Retrive data within a year orderBy := "timestamp" top := int32(1000) // Maximum number of recodr fetch with given interval filter := "" diff --git a/azure/plugin.go b/azure/plugin.go index 806e0da5..fe3dcdd5 100644 --- a/azure/plugin.go +++ b/azure/plugin.go @@ -38,6 +38,7 @@ func Plugin(ctx context.Context) *plugin.Plugin { "azure_compute_disk_metric_read_ops_hourly": tableComputeDisksReadOpsMetricHourly(ctx), "azure_compute_disk_metric_read_ops_daily": tableComputeDisksReadOpsMetricDaily(ctx), "azure_compute_disk_metric_write_ops": tableComputeDisksWriteOpsMetric(ctx), + "azure_compute_disk_metric_write_ops_daily": tableComputeDisksWriteOpsMetricDaily(ctx), "azure_compute_disk_metric_write_ops_hourly": tableComputeDisksWriteOpsMetricHourly(ctx), "azure_compute_image": tableAzureComputeImage(ctx), "azure_compute_resource_sku": tableAzureResourceSku(ctx), diff --git a/azure/table_azure_compute_disk_metric_write_ops_daily.go b/azure/table_azure_compute_disk_metric_write_ops_daily.go new file mode 100644 index 00000000..9212dd7e --- /dev/null +++ b/azure/table_azure_compute_disk_metric_write_ops_daily.go @@ -0,0 +1,39 @@ +package azure + +import ( + "context" + + "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2020-06-01/compute" + "github.com/turbot/steampipe-plugin-sdk/grpc/proto" + "github.com/turbot/steampipe-plugin-sdk/plugin" + "github.com/turbot/steampipe-plugin-sdk/plugin/transform" +) + +//// TABLE DEFINITION + +func tableComputeDisksWriteOpsMetricDaily(_ context.Context) *plugin.Table { + return &plugin.Table{ + Name: "azure_compute_disk_metric_write_ops_daily", + Description: "Azure Compute Disk Metrics - Write Ops Daily", + List: &plugin.ListConfig{ + ParentHydrate: listAzureComputeDisks, + Hydrate: listComputeDiskMetricWriteOpsDaily, + }, + Columns: monitoringMetricColumns([]*plugin.Column{ + { + Name: "name", + Description: "The name of the compute disk.", + Type: proto.ColumnType_STRING, + Transform: transform.FromField("DimensionValue"), + }, + }), + } +} + +//// LIST FUNCTION + +func listComputeDiskMetricWriteOpsDaily(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + diskInfo := h.Item.(compute.Disk) + + return listAzureMonitorMetricStatistics(ctx, d, "DAILY", "Microsoft.Compute/disks", "Composite Disk Write Operations/sec", *diskInfo.ID) +} diff --git a/docs/tables/azure_compute_disk_metric_write_ops_daily.md b/docs/tables/azure_compute_disk_metric_write_ops_daily.md new file mode 100644 index 00000000..635d07c9 --- /dev/null +++ b/docs/tables/azure_compute_disk_metric_write_ops_daily.md @@ -0,0 +1,40 @@ +# Table: azure_compute_disk_metric_write_ops_daily + +GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_write_ops_daily` table provides metric statistics at 1 hour intervals for the most recent 1 year. + +## Examples + +### Basic info + +```sql +select + name, + timestamp, + minimum, + maximum, + average, + sample_count +from + azure_compute_disk_metric_write_ops_daily +order by + name, + timestamp; +``` + +### Operations Over 10 Bytes average + +```sql +select + name, + timestamp, + round(minimum::numeric,2) as min_write_ops, + round(maximum::numeric,2) as max_write_ops, + round(average::numeric,2) as avg_write_ops, + sample_count +from + azure_compute_disk_metric_write_ops_daily +where average > 10 +order by + name, + timestamp; +``` diff --git a/docs/tables/azure_compute_disk_metric_write_ops_hourly.md b/docs/tables/azure_compute_disk_metric_write_ops_hourly.md index c9edc63d..ff165175 100644 --- a/docs/tables/azure_compute_disk_metric_write_ops_hourly.md +++ b/docs/tables/azure_compute_disk_metric_write_ops_hourly.md @@ -1,6 +1,6 @@ # Table: azure_compute_disk_metric_write_ops_hourly -GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_write_ops_hourly` table provides metric statistics at 5 minute intervals for the most recent 1 year. +GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_write_ops_hourly` table provides metric statistics at 60 minute intervals for the most recent 1 year. ## Examples From 6580a28731bdfbdca27dccb0da37f55506ba0f68 Mon Sep 17 00:00:00 2001 From: ParthaI Date: Mon, 5 Jul 2021 19:39:22 +0530 Subject: [PATCH 11/14] Made changes as per review comments --- azure/monitoring_metric.go | 25 ++++++++++++++----- ...able_azure_compute_disk_metric_read_ops.go | 2 +- ...zure_compute_disk_metric_read_ops_daily.go | 2 +- ...ure_compute_disk_metric_read_ops_hourly.go | 2 +- ...ble_azure_compute_disk_metric_write_ops.go | 2 +- ...ure_compute_disk_metric_write_ops_daily.go | 2 +- ...re_compute_disk_metric_write_ops_hourly.go | 2 +- ...al_machine_metric_cpu_utilization_daily.go | 2 +- ...l_machine_metric_cpu_utilization_hourly.go | 2 +- .../azure_compute_disk_metric_read_ops.md | 2 +- ...ure_compute_disk_metric_read_ops_hourly.md | 2 +- .../azure_compute_disk_metric_write_ops.md | 2 +- ...ure_compute_disk_metric_write_ops_daily.md | 2 +- ...re_compute_disk_metric_write_ops_hourly.md | 2 +- ..._virtual_machine_metric_cpu_utilization.md | 2 +- ...l_machine_metric_cpu_utilization_hourly.md | 2 +- 16 files changed, 34 insertions(+), 21 deletions(-) diff --git a/azure/monitoring_metric.go b/azure/monitoring_metric.go index a9e1c88f..4e181674 100644 --- a/azure/monitoring_metric.go +++ b/azure/monitoring_metric.go @@ -83,7 +83,7 @@ func commonMonitoringMetricColumns() []*plugin.Column { { Name: "timestamp", Description: "The time stamp used for the data point.", - Type: proto.ColumnType_STRING, + Type: proto.ColumnType_TIMESTAMP, Transform: transform.FromField("TimeStamp"), }, { @@ -93,12 +93,12 @@ func commonMonitoringMetricColumns() []*plugin.Column { }, { Name: "resource_group", - Description: "The time stamp used for the data point.", + Description: ColumnDescriptionResourceGroup, Type: proto.ColumnType_STRING, }, { Name: "subscription_id", - Description: "The time stamp used for the data point.", + Description: ColumnDescriptionSubscription, Type: proto.ColumnType_STRING, Transform: transform.FromField("SubscriptionID"), }, @@ -118,6 +118,19 @@ func getMonitoringIntervalForGranularity(granularity string) string { return "PT5M" } +func getMonitoringStartDateForGranularity(granularity string) string { + switch strings.ToUpper(granularity) { + case "DAILY": + // Last 1 year + return time.Now().UTC().AddDate(-1, 0, 0).Format(time.RFC3339) + case "HOURLY": + // Last 60 days + return time.Now().UTC().AddDate(0, 0, -60).Format(time.RFC3339) + } + // Last 5 days + return time.Now().UTC().AddDate(0, 0, -5).Format(time.RFC3339) +} + func listAzureMonitorMetricStatistics(ctx context.Context, d *plugin.QueryData, granularity string, metricNameSpace string, metricNames string, dimensionValue string) (interface{}, error) { session, err := GetNewSession(ctx, d, "MANAGEMENT") if err != nil { @@ -131,9 +144,9 @@ func listAzureMonitorMetricStatistics(ctx context.Context, d *plugin.QueryData, // Define param values interval := getMonitoringIntervalForGranularity(granularity) aggregation := "average,count,maximum,minimum,total" - timeSpan := time.Now().UTC().AddDate(-1, 0, 0).Format(time.RFC3339) + "/" + time.Now().UTC().AddDate(0, 0, 1).Format(time.RFC3339) // Retrive data within a year + timeSpan := getMonitoringStartDateForGranularity(granularity) + "/" + time.Now().UTC().AddDate(0, 0, 1).Format(time.RFC3339) // Retrieve data within a year orderBy := "timestamp" - top := int32(1000) // Maximum number of recodr fetch with given interval + top := int32(1000) // Maximum number of record fetch with given interval filter := "" result, err := monitoringClient.List(ctx, dimensionValue, timeSpan, &interval, metricNames, aggregation, &top, orderBy, filter, insights.ResultTypeData, metricNameSpace) @@ -153,7 +166,7 @@ func listAzureMonitorMetricStatistics(ctx context.Context, d *plugin.QueryData, Sum: data.Total, SampleCount: data.Count, Unit: string(metric.Unit), - ResourceGroup: strings.Split(dimensionValue, "/")[4], + ResourceGroup: strings.ToLower(strings.Split(dimensionValue, "/")[4]), SubscriptionID: strings.Split(dimensionValue, "/")[2], }) } diff --git a/azure/table_azure_compute_disk_metric_read_ops.go b/azure/table_azure_compute_disk_metric_read_ops.go index 72116e83..b35f7451 100644 --- a/azure/table_azure_compute_disk_metric_read_ops.go +++ b/azure/table_azure_compute_disk_metric_read_ops.go @@ -22,7 +22,7 @@ func tableComputeDisksReadOpsMetric(_ context.Context) *plugin.Table { Columns: monitoringMetricColumns([]*plugin.Column{ { Name: "name", - Description: "The name of the compute disk.", + Description: "The name of the disk.", Type: proto.ColumnType_STRING, Transform: transform.FromField("DimensionValue"), }, diff --git a/azure/table_azure_compute_disk_metric_read_ops_daily.go b/azure/table_azure_compute_disk_metric_read_ops_daily.go index f686a6f5..748a5efa 100644 --- a/azure/table_azure_compute_disk_metric_read_ops_daily.go +++ b/azure/table_azure_compute_disk_metric_read_ops_daily.go @@ -22,7 +22,7 @@ func tableComputeDisksReadOpsMetricDaily(_ context.Context) *plugin.Table { Columns: monitoringMetricColumns([]*plugin.Column{ { Name: "name", - Description: "The name of the compute disk.", + Description: "The name of the disk.", Type: proto.ColumnType_STRING, Transform: transform.FromField("DimensionValue"), }, diff --git a/azure/table_azure_compute_disk_metric_read_ops_hourly.go b/azure/table_azure_compute_disk_metric_read_ops_hourly.go index cb4fee3f..098ccaaf 100644 --- a/azure/table_azure_compute_disk_metric_read_ops_hourly.go +++ b/azure/table_azure_compute_disk_metric_read_ops_hourly.go @@ -22,7 +22,7 @@ func tableComputeDisksReadOpsMetricHourly(_ context.Context) *plugin.Table { Columns: monitoringMetricColumns([]*plugin.Column{ { Name: "name", - Description: "The name of the compute disk.", + Description: "The name of the disk.", Type: proto.ColumnType_STRING, Transform: transform.FromField("DimensionValue"), }, diff --git a/azure/table_azure_compute_disk_metric_write_ops.go b/azure/table_azure_compute_disk_metric_write_ops.go index 8c46326c..f29a3a35 100644 --- a/azure/table_azure_compute_disk_metric_write_ops.go +++ b/azure/table_azure_compute_disk_metric_write_ops.go @@ -22,7 +22,7 @@ func tableComputeDisksWriteOpsMetric(_ context.Context) *plugin.Table { Columns: monitoringMetricColumns([]*plugin.Column{ { Name: "name", - Description: "The name of the compute disk.", + Description: "The name of the disk.", Type: proto.ColumnType_STRING, Transform: transform.FromField("DimensionValue"), }, diff --git a/azure/table_azure_compute_disk_metric_write_ops_daily.go b/azure/table_azure_compute_disk_metric_write_ops_daily.go index 9212dd7e..dab2626b 100644 --- a/azure/table_azure_compute_disk_metric_write_ops_daily.go +++ b/azure/table_azure_compute_disk_metric_write_ops_daily.go @@ -22,7 +22,7 @@ func tableComputeDisksWriteOpsMetricDaily(_ context.Context) *plugin.Table { Columns: monitoringMetricColumns([]*plugin.Column{ { Name: "name", - Description: "The name of the compute disk.", + Description: "The name of the disk.", Type: proto.ColumnType_STRING, Transform: transform.FromField("DimensionValue"), }, diff --git a/azure/table_azure_compute_disk_metric_write_ops_hourly.go b/azure/table_azure_compute_disk_metric_write_ops_hourly.go index 684526c3..5fa61e7e 100644 --- a/azure/table_azure_compute_disk_metric_write_ops_hourly.go +++ b/azure/table_azure_compute_disk_metric_write_ops_hourly.go @@ -22,7 +22,7 @@ func tableComputeDisksWriteOpsMetricHourly(_ context.Context) *plugin.Table { Columns: monitoringMetricColumns([]*plugin.Column{ { Name: "name", - Description: "The name of the compute disk.", + Description: "The name of the disk.", Type: proto.ColumnType_STRING, Transform: transform.FromField("DimensionValue"), }, diff --git a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_daily.go b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_daily.go index 57548e08..6a2a6229 100644 --- a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_daily.go +++ b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_daily.go @@ -14,7 +14,7 @@ import ( func tableComputeInstanceCpuUtilizationMetricDaily(_ context.Context) *plugin.Table { return &plugin.Table{ Name: "azure_compute_virtual_machine_metric_cpu_utilization_daily", - Description: "Azure Compute Virtual Machine Daily Metrics - CPU Utilization", + Description: "Azure Compute Virtual Machine Metrics - CPU Utilization (Daily)", List: &plugin.ListConfig{ ParentHydrate: listAzureComputeVirtualMachines, Hydrate: listComputeVirtualMachineMetricCpuUtilizationDaily, diff --git a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_hourly.go b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_hourly.go index a715b2e1..62dff296 100644 --- a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_hourly.go +++ b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_hourly.go @@ -14,7 +14,7 @@ import ( func tableComputeInstanceCpuUtilizationMetricHourly(_ context.Context) *plugin.Table { return &plugin.Table{ Name: "azure_compute_virtual_machine_metric_cpu_utilization_hourly", - Description: "Azure Compute Virtual Machine Hourly Metrics - CPU Utilization", + Description: "Azure Compute Virtual Machine Metrics - CPU Utilization (Hourly)", List: &plugin.ListConfig{ ParentHydrate: listAzureComputeVirtualMachines, Hydrate: listComputeVirtualMachineMetricCpuUtilizationHourly, diff --git a/docs/tables/azure_compute_disk_metric_read_ops.md b/docs/tables/azure_compute_disk_metric_read_ops.md index 840cb261..74229ab1 100644 --- a/docs/tables/azure_compute_disk_metric_read_ops.md +++ b/docs/tables/azure_compute_disk_metric_read_ops.md @@ -1,6 +1,6 @@ # Table: azure_compute_disk_metric_read_ops -GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_read_ops` table provides metric statistics at 5 minute intervals for the most recent 1 year. +GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_read_ops` table provides metric statistics at 5 minute intervals for the most recent 5 days. ## Examples diff --git a/docs/tables/azure_compute_disk_metric_read_ops_hourly.md b/docs/tables/azure_compute_disk_metric_read_ops_hourly.md index 79a83197..a5b50a53 100644 --- a/docs/tables/azure_compute_disk_metric_read_ops_hourly.md +++ b/docs/tables/azure_compute_disk_metric_read_ops_hourly.md @@ -1,6 +1,6 @@ # Table: azure_compute_disk_metric_read_ops_hourly -GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_read_ops_hourly` table provides metric statistics at 60 minute intervals for the most recent 1 year. +GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_read_ops_hourly` table provides metric statistics at 60 minute intervals for the most recent 60 days. ## Examples diff --git a/docs/tables/azure_compute_disk_metric_write_ops.md b/docs/tables/azure_compute_disk_metric_write_ops.md index 2aecacba..5ef9e392 100644 --- a/docs/tables/azure_compute_disk_metric_write_ops.md +++ b/docs/tables/azure_compute_disk_metric_write_ops.md @@ -1,6 +1,6 @@ # Table: azure_compute_disk_metric_write_ops -GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_write_ops` table provides metric statistics at 5 minute intervals for the most recent 1 year. +GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_write_ops` table provides metric statistics at 5 minute intervals for the most recent 5 days. ## Examples diff --git a/docs/tables/azure_compute_disk_metric_write_ops_daily.md b/docs/tables/azure_compute_disk_metric_write_ops_daily.md index 635d07c9..740ab2c4 100644 --- a/docs/tables/azure_compute_disk_metric_write_ops_daily.md +++ b/docs/tables/azure_compute_disk_metric_write_ops_daily.md @@ -1,6 +1,6 @@ # Table: azure_compute_disk_metric_write_ops_daily -GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_write_ops_daily` table provides metric statistics at 1 hour intervals for the most recent 1 year. +GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_write_ops_daily` table provides metric statistics at 24 hour intervals for the most recent 1 year. ## Examples diff --git a/docs/tables/azure_compute_disk_metric_write_ops_hourly.md b/docs/tables/azure_compute_disk_metric_write_ops_hourly.md index ff165175..b5791448 100644 --- a/docs/tables/azure_compute_disk_metric_write_ops_hourly.md +++ b/docs/tables/azure_compute_disk_metric_write_ops_hourly.md @@ -1,6 +1,6 @@ # Table: azure_compute_disk_metric_write_ops_hourly -GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_write_ops_hourly` table provides metric statistics at 60 minute intervals for the most recent 1 year. +GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_write_ops_hourly` table provides metric statistics at 60 minute intervals for the most recent 60 days. ## Examples diff --git a/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization.md b/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization.md index 8c7ab88f..07c31976 100644 --- a/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization.md +++ b/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization.md @@ -1,6 +1,6 @@ # Table: azure_compute_virtual_machine_metric_cpu_utilization -GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_virtual_machine_metric_cpu_utilization` table provides metric statistics at 5 minute intervals for the most recent 1 year. +GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_virtual_machine_metric_cpu_utilization` table provides metric statistics at 5 minute intervals for the most recent 5 days. ## Examples diff --git a/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_hourly.md b/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_hourly.md index 0f34c20e..af4df716 100644 --- a/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_hourly.md +++ b/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_hourly.md @@ -1,6 +1,6 @@ # Table: azure_compute_virtual_machine_metric_cpu_utilization_hourly -GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_virtual_machine_metric_cpu_utilization_hourly` table provides metric statistics at 1 hour intervals for the most recent 1 year. +GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_virtual_machine_metric_cpu_utilization_hourly` table provides metric statistics at 1 hour intervals for the most recent 60 days. ## Examples From 852b5ffd465c25e237eaefb361706294b048ba17 Mon Sep 17 00:00:00 2001 From: Subhajit Kumar Mondal Date: Mon, 5 Jul 2021 21:05:22 +0530 Subject: [PATCH 12/14] Fixed table descriptions --- azure/monitoring_metric.go | 20 +++---------------- ...able_azure_compute_disk_metric_read_ops.go | 2 +- ...zure_compute_disk_metric_read_ops_daily.go | 4 ++-- ...ure_compute_disk_metric_read_ops_hourly.go | 4 ++-- ...ble_azure_compute_disk_metric_write_ops.go | 2 +- ...ure_compute_disk_metric_write_ops_daily.go | 4 ++-- ...re_compute_disk_metric_write_ops_hourly.go | 4 ++-- ..._virtual_machine_metric_cpu_utilization.go | 4 ++-- ...al_machine_metric_cpu_utilization_daily.go | 4 ++-- ...l_machine_metric_cpu_utilization_hourly.go | 4 ++-- azure/utils.go | 13 ++++++++++++ 11 files changed, 32 insertions(+), 33 deletions(-) diff --git a/azure/monitoring_metric.go b/azure/monitoring_metric.go index 4e181674..11e7083c 100644 --- a/azure/monitoring_metric.go +++ b/azure/monitoring_metric.go @@ -14,37 +14,24 @@ import ( type monitoringMetric struct { // Resource Name DimensionValue string - // MetadataValue represents a metric metadata value. MetaData *insights.MetadataValue - // Metric the result data of a query. Metric *insights.Metric - // The maximum metric value for the data point. Maximum *float64 - // The minimum metric value for the data point. Minimum *float64 - // The average of the metric values that correspond to the data point. Average *float64 - // The number of metric values that contributed to the aggregate value of this data point. SampleCount *float64 - // The sum of the metric values for the data point. Sum *float64 - // The time stamp used for the data point. TimeStamp string - // The units in which the metric value is reported. Unit string - - ResourceGroup string - - SubscriptionID string } //// TABLE DEFINITION @@ -95,12 +82,13 @@ func commonMonitoringMetricColumns() []*plugin.Column { Name: "resource_group", Description: ColumnDescriptionResourceGroup, Type: proto.ColumnType_STRING, + Transform: transform.FromField("DimensionValue").Transform(extractResourceGroupFromID), }, { Name: "subscription_id", Description: ColumnDescriptionSubscription, Type: proto.ColumnType_STRING, - Transform: transform.FromField("SubscriptionID"), + Transform: transform.FromField("DimensionValue").Transform(idToSubscriptionID), }, } } @@ -158,7 +146,7 @@ func listAzureMonitorMetricStatistics(ctx context.Context, d *plugin.QueryData, for _, data := range *timeseries.Data { if data.Average != nil { d.StreamListItem(ctx, &monitoringMetric{ - DimensionValue: strings.Split(dimensionValue, "/")[len(strings.Split(dimensionValue, "/"))-1], + DimensionValue: dimensionValue, TimeStamp: data.TimeStamp.Format(time.RFC3339), Maximum: data.Maximum, Minimum: data.Minimum, @@ -166,8 +154,6 @@ func listAzureMonitorMetricStatistics(ctx context.Context, d *plugin.QueryData, Sum: data.Total, SampleCount: data.Count, Unit: string(metric.Unit), - ResourceGroup: strings.ToLower(strings.Split(dimensionValue, "/")[4]), - SubscriptionID: strings.Split(dimensionValue, "/")[2], }) } } diff --git a/azure/table_azure_compute_disk_metric_read_ops.go b/azure/table_azure_compute_disk_metric_read_ops.go index b35f7451..c49c9ebd 100644 --- a/azure/table_azure_compute_disk_metric_read_ops.go +++ b/azure/table_azure_compute_disk_metric_read_ops.go @@ -24,7 +24,7 @@ func tableComputeDisksReadOpsMetric(_ context.Context) *plugin.Table { Name: "name", Description: "The name of the disk.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("DimensionValue"), + Transform: transform.FromField("DimensionValue").Transform(lastPathElement), }, }), } diff --git a/azure/table_azure_compute_disk_metric_read_ops_daily.go b/azure/table_azure_compute_disk_metric_read_ops_daily.go index 748a5efa..c97409b2 100644 --- a/azure/table_azure_compute_disk_metric_read_ops_daily.go +++ b/azure/table_azure_compute_disk_metric_read_ops_daily.go @@ -14,7 +14,7 @@ import ( func tableComputeDisksReadOpsMetricDaily(_ context.Context) *plugin.Table { return &plugin.Table{ Name: "azure_compute_disk_metric_read_ops_daily", - Description: "Azure Compute Disk Metrics - Read Ops Daily", + Description: "Azure Compute Disk Metrics - Read Ops (Daily)", List: &plugin.ListConfig{ ParentHydrate: listAzureComputeDisks, Hydrate: listComputeDiskMetricReadOpsDaily, @@ -24,7 +24,7 @@ func tableComputeDisksReadOpsMetricDaily(_ context.Context) *plugin.Table { Name: "name", Description: "The name of the disk.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("DimensionValue"), + Transform: transform.FromField("DimensionValue").Transform(lastPathElement), }, }), } diff --git a/azure/table_azure_compute_disk_metric_read_ops_hourly.go b/azure/table_azure_compute_disk_metric_read_ops_hourly.go index 098ccaaf..3a3a08f0 100644 --- a/azure/table_azure_compute_disk_metric_read_ops_hourly.go +++ b/azure/table_azure_compute_disk_metric_read_ops_hourly.go @@ -14,7 +14,7 @@ import ( func tableComputeDisksReadOpsMetricHourly(_ context.Context) *plugin.Table { return &plugin.Table{ Name: "azure_compute_disk_metric_read_ops_hourly", - Description: "Azure Compute Disk Metrics - Read Ops Hourly", + Description: "Azure Compute Disk Metrics - Read Ops (Hourly)", List: &plugin.ListConfig{ ParentHydrate: listAzureComputeDisks, Hydrate: listComputeDiskMetricReadOpsHourly, @@ -24,7 +24,7 @@ func tableComputeDisksReadOpsMetricHourly(_ context.Context) *plugin.Table { Name: "name", Description: "The name of the disk.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("DimensionValue"), + Transform: transform.FromField("DimensionValue").Transform(lastPathElement), }, }), } diff --git a/azure/table_azure_compute_disk_metric_write_ops.go b/azure/table_azure_compute_disk_metric_write_ops.go index f29a3a35..c2f7bf2b 100644 --- a/azure/table_azure_compute_disk_metric_write_ops.go +++ b/azure/table_azure_compute_disk_metric_write_ops.go @@ -24,7 +24,7 @@ func tableComputeDisksWriteOpsMetric(_ context.Context) *plugin.Table { Name: "name", Description: "The name of the disk.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("DimensionValue"), + Transform: transform.FromField("DimensionValue").Transform(lastPathElement), }, }), } diff --git a/azure/table_azure_compute_disk_metric_write_ops_daily.go b/azure/table_azure_compute_disk_metric_write_ops_daily.go index dab2626b..e35a873d 100644 --- a/azure/table_azure_compute_disk_metric_write_ops_daily.go +++ b/azure/table_azure_compute_disk_metric_write_ops_daily.go @@ -14,7 +14,7 @@ import ( func tableComputeDisksWriteOpsMetricDaily(_ context.Context) *plugin.Table { return &plugin.Table{ Name: "azure_compute_disk_metric_write_ops_daily", - Description: "Azure Compute Disk Metrics - Write Ops Daily", + Description: "Azure Compute Disk Metrics - Write Ops (Daily)", List: &plugin.ListConfig{ ParentHydrate: listAzureComputeDisks, Hydrate: listComputeDiskMetricWriteOpsDaily, @@ -24,7 +24,7 @@ func tableComputeDisksWriteOpsMetricDaily(_ context.Context) *plugin.Table { Name: "name", Description: "The name of the disk.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("DimensionValue"), + Transform: transform.FromField("DimensionValue").Transform(lastPathElement), }, }), } diff --git a/azure/table_azure_compute_disk_metric_write_ops_hourly.go b/azure/table_azure_compute_disk_metric_write_ops_hourly.go index 5fa61e7e..c92f1875 100644 --- a/azure/table_azure_compute_disk_metric_write_ops_hourly.go +++ b/azure/table_azure_compute_disk_metric_write_ops_hourly.go @@ -14,7 +14,7 @@ import ( func tableComputeDisksWriteOpsMetricHourly(_ context.Context) *plugin.Table { return &plugin.Table{ Name: "azure_compute_disk_metric_write_ops_hourly", - Description: "Azure Compute Disk Metrics - Write Ops Hourly", + Description: "Azure Compute Disk Metrics - Write Ops (Hourly)", List: &plugin.ListConfig{ ParentHydrate: listAzureComputeDisks, Hydrate: listComputeDiskMetricWriteOpsHourly, @@ -24,7 +24,7 @@ func tableComputeDisksWriteOpsMetricHourly(_ context.Context) *plugin.Table { Name: "name", Description: "The name of the disk.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("DimensionValue"), + Transform: transform.FromField("DimensionValue").Transform(lastPathElement), }, }), } diff --git a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization.go b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization.go index 0b17303a..c399016e 100644 --- a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization.go +++ b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization.go @@ -22,9 +22,9 @@ func tableComputeInstanceCpuUtilizationMetric(_ context.Context) *plugin.Table { Columns: monitoringMetricColumns([]*plugin.Column{ { Name: "name", - Description: "The name of the virtual machine instance.", + Description: "The name of the virtual machine.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("DimensionValue"), + Transform: transform.FromField("DimensionValue").Transform(lastPathElement), }, }), } diff --git a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_daily.go b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_daily.go index 6a2a6229..91610b21 100644 --- a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_daily.go +++ b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_daily.go @@ -22,9 +22,9 @@ func tableComputeInstanceCpuUtilizationMetricDaily(_ context.Context) *plugin.Ta Columns: monitoringMetricColumns([]*plugin.Column{ { Name: "name", - Description: "The name of the virtual machine instance.", + Description: "The name of the virtual machine.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("DimensionValue"), + Transform: transform.FromField("DimensionValue").Transform(lastPathElement), }, }), } diff --git a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_hourly.go b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_hourly.go index 62dff296..ae856273 100644 --- a/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_hourly.go +++ b/azure/table_azure_compute_virtual_machine_metric_cpu_utilization_hourly.go @@ -22,9 +22,9 @@ func tableComputeInstanceCpuUtilizationMetricHourly(_ context.Context) *plugin.T Columns: monitoringMetricColumns([]*plugin.Column{ { Name: "name", - Description: "The name of the virtual machine instance.", + Description: "The name of the virtual machine.", Type: proto.ColumnType_STRING, - Transform: transform.FromField("DimensionValue"), + Transform: transform.FromField("DimensionValue").Transform(lastPathElement), }, }), } diff --git a/azure/utils.go b/azure/utils.go index e4971ed1..c8ecc8c9 100644 --- a/azure/utils.go +++ b/azure/utils.go @@ -46,6 +46,19 @@ func extractResourceGroupFromID(ctx context.Context, d *transform.TransformData) return resourceGroup, nil } +func lastPathElement(_ context.Context, d *transform.TransformData) (interface{}, error) { + return getLastPathElement(types.SafeString(d.Value)), nil +} + +func getLastPathElement(path string) string { + if path == "" { + return "" + } + + pathItems := strings.Split(path, "/") + return pathItems[len(pathItems)-1] +} + func convertDateToTime(ctx context.Context, d *transform.TransformData) (interface{}, error) { if d.Value == nil { return nil, nil From 5dce283b5fdf288917683a08a8e46200ebb04573 Mon Sep 17 00:00:00 2001 From: Subhajit Kumar Mondal Date: Tue, 6 Jul 2021 10:55:39 +0530 Subject: [PATCH 13/14] Updated docs --- docs/tables/azure_compute_disk_metric_read_ops.md | 5 +++-- docs/tables/azure_compute_disk_metric_read_ops_daily.md | 5 +++-- docs/tables/azure_compute_disk_metric_read_ops_hourly.md | 5 +++-- docs/tables/azure_compute_disk_metric_write_ops.md | 2 +- docs/tables/azure_compute_disk_metric_write_ops_daily.md | 5 +++-- docs/tables/azure_compute_disk_metric_write_ops_hourly.md | 5 +++-- .../azure_compute_virtual_machine_metric_cpu_utilization.md | 2 +- ...e_compute_virtual_machine_metric_cpu_utilization_daily.md | 5 +++-- ..._compute_virtual_machine_metric_cpu_utilization_hourly.md | 5 +++-- 9 files changed, 23 insertions(+), 16 deletions(-) diff --git a/docs/tables/azure_compute_disk_metric_read_ops.md b/docs/tables/azure_compute_disk_metric_read_ops.md index 74229ab1..9153b2c6 100644 --- a/docs/tables/azure_compute_disk_metric_read_ops.md +++ b/docs/tables/azure_compute_disk_metric_read_ops.md @@ -1,6 +1,6 @@ # Table: azure_compute_disk_metric_read_ops -GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_read_ops` table provides metric statistics at 5 minute intervals for the most recent 5 days. +GCP Monitoring metrics provide data about the performance of your systems. The `azure_compute_disk_metric_read_ops` table provides metric statistics at 5 minutes intervals for the most recent 5 days. ## Examples @@ -33,7 +33,8 @@ select sample_count from azure_compute_disk_metric_read_ops -where average > 10 +where + average > 10 order by name, timestamp; diff --git a/docs/tables/azure_compute_disk_metric_read_ops_daily.md b/docs/tables/azure_compute_disk_metric_read_ops_daily.md index 5e94fb37..bb89e58d 100644 --- a/docs/tables/azure_compute_disk_metric_read_ops_daily.md +++ b/docs/tables/azure_compute_disk_metric_read_ops_daily.md @@ -1,6 +1,6 @@ # Table: azure_compute_disk_metric_read_ops_daily -GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_read_ops_daily` table provides metric statistics at 24 hours intervals for the most recent 1 year. +GCP Monitoring metrics provide data about the performance of your systems. The `azure_compute_disk_metric_read_ops_daily` table provides metric statistics at 24 hours intervals for the most recent 1 year. ## Examples @@ -33,7 +33,8 @@ select sample_count from azure_compute_disk_metric_read_ops_daily -where average > 10 +where + average > 10 order by name, timestamp; diff --git a/docs/tables/azure_compute_disk_metric_read_ops_hourly.md b/docs/tables/azure_compute_disk_metric_read_ops_hourly.md index a5b50a53..9c4ebed6 100644 --- a/docs/tables/azure_compute_disk_metric_read_ops_hourly.md +++ b/docs/tables/azure_compute_disk_metric_read_ops_hourly.md @@ -1,6 +1,6 @@ # Table: azure_compute_disk_metric_read_ops_hourly -GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_read_ops_hourly` table provides metric statistics at 60 minute intervals for the most recent 60 days. +GCP Monitoring metrics provide data about the performance of your systems. The `azure_compute_disk_metric_read_ops_hourly` table provides metric statistics at 1 hour intervals for the most recent 60 days. ## Examples @@ -33,7 +33,8 @@ select sample_count from azure_compute_disk_metric_read_ops_hourly -where average > 10 +where + average > 10 order by name, timestamp; diff --git a/docs/tables/azure_compute_disk_metric_write_ops.md b/docs/tables/azure_compute_disk_metric_write_ops.md index 5ef9e392..c1d223d8 100644 --- a/docs/tables/azure_compute_disk_metric_write_ops.md +++ b/docs/tables/azure_compute_disk_metric_write_ops.md @@ -1,6 +1,6 @@ # Table: azure_compute_disk_metric_write_ops -GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_write_ops` table provides metric statistics at 5 minute intervals for the most recent 5 days. +GCP Monitoring metrics provide data about the performance of your systems. The `azure_compute_disk_metric_write_ops` table provides metric statistics at 5 minutes intervals for the most recent 5 days. ## Examples diff --git a/docs/tables/azure_compute_disk_metric_write_ops_daily.md b/docs/tables/azure_compute_disk_metric_write_ops_daily.md index 740ab2c4..2de1b536 100644 --- a/docs/tables/azure_compute_disk_metric_write_ops_daily.md +++ b/docs/tables/azure_compute_disk_metric_write_ops_daily.md @@ -1,6 +1,6 @@ # Table: azure_compute_disk_metric_write_ops_daily -GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_write_ops_daily` table provides metric statistics at 24 hour intervals for the most recent 1 year. +GCP Monitoring metrics provide data about the performance of your systems. The `azure_compute_disk_metric_write_ops_daily` table provides metric statistics at 24 hours intervals for the most recent 1 year. ## Examples @@ -33,7 +33,8 @@ select sample_count from azure_compute_disk_metric_write_ops_daily -where average > 10 +where + average > 10 order by name, timestamp; diff --git a/docs/tables/azure_compute_disk_metric_write_ops_hourly.md b/docs/tables/azure_compute_disk_metric_write_ops_hourly.md index b5791448..d879792b 100644 --- a/docs/tables/azure_compute_disk_metric_write_ops_hourly.md +++ b/docs/tables/azure_compute_disk_metric_write_ops_hourly.md @@ -1,6 +1,6 @@ # Table: azure_compute_disk_metric_write_ops_hourly -GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_disk_metric_write_ops_hourly` table provides metric statistics at 60 minute intervals for the most recent 60 days. +GCP Monitoring metrics provide data about the performance of your systems. The `azure_compute_disk_metric_write_ops_hourly` table provides metric statistics at 1 hour intervals for the most recent 60 days. ## Examples @@ -33,7 +33,8 @@ select sample_count from azure_compute_disk_metric_write_ops_hourly -where average > 10 +where + average > 10 order by name, timestamp; diff --git a/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization.md b/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization.md index 07c31976..d6fa0c7c 100644 --- a/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization.md +++ b/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization.md @@ -1,6 +1,6 @@ # Table: azure_compute_virtual_machine_metric_cpu_utilization -GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_virtual_machine_metric_cpu_utilization` table provides metric statistics at 5 minute intervals for the most recent 5 days. +GCP Monitoring metrics provide data about the performance of your systems. The `azure_compute_virtual_machine_metric_cpu_utilization` table provides metric statistics at 5 minutes intervals for the most recent 5 days. ## Examples diff --git a/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_daily.md b/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_daily.md index 14ee3e64..2d4f1a9f 100644 --- a/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_daily.md +++ b/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_daily.md @@ -1,6 +1,6 @@ # Table: azure_compute_virtual_machine_metric_cpu_utilization_daily -GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_virtual_machine_metric_cpu_utilization_daily` table provides metric statistics at 24 hours intervals for the most recent 1 year. +GCP Monitoring metrics provide data about the performance of your systems. The `azure_compute_virtual_machine_metric_cpu_utilization_daily` table provides metric statistics at 24 hours intervals for the most recent 1 year. ## Examples @@ -33,7 +33,8 @@ select sample_count from azure_compute_virtual_machine_metric_cpu_utilization_daily -where average > 80 +where + average > 80 order by name, timestamp; diff --git a/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_hourly.md b/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_hourly.md index af4df716..43d81a2a 100644 --- a/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_hourly.md +++ b/docs/tables/azure_compute_virtual_machine_metric_cpu_utilization_hourly.md @@ -1,6 +1,6 @@ # Table: azure_compute_virtual_machine_metric_cpu_utilization_hourly -GCP Monitoring Metrics provide data about the performance of your systems. The `azure_compute_virtual_machine_metric_cpu_utilization_hourly` table provides metric statistics at 1 hour intervals for the most recent 60 days. +GCP Monitoring metrics provide data about the performance of your systems. The `azure_compute_virtual_machine_metric_cpu_utilization_hourly` table provides metric statistics at 1 hour intervals for the most recent 60 days. ## Examples @@ -33,7 +33,8 @@ select sample_count from azure_compute_virtual_machine_metric_cpu_utilization_hourly -where average > 80 +where + average > 80 order by name, timestamp; From 24a4e6afff3954918c808cd3e88b3b531e1af0c5 Mon Sep 17 00:00:00 2001 From: cbruno10 Date: Thu, 8 Jul 2021 14:42:11 -0400 Subject: [PATCH 14/14] Update monitoring_metric.go --- azure/monitoring_metric.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure/monitoring_metric.go b/azure/monitoring_metric.go index 11e7083c..ceacc165 100644 --- a/azure/monitoring_metric.go +++ b/azure/monitoring_metric.go @@ -12,7 +12,7 @@ import ( ) type monitoringMetric struct { - // Resource Name + // Resource Name DimensionValue string // MetadataValue represents a metric metadata value. MetaData *insights.MetadataValue