lib/pghero/methods/system.rb in pghero-3.3.2 vs lib/pghero/methods/system.rb in pghero-3.3.3

- old
+ new

@@ -100,11 +100,12 @@ else raise Error, "Unsupported period" end client = Azure::Monitor::Profiles::Latest::Mgmt::Client.new - timespan = "#{start_time.iso8601}/#{end_time.iso8601}" + # call utc to convert +00:00 to Z + timespan = "#{start_time.utc.iso8601}/#{end_time.utc.iso8601}" results = client.metrics.list( azure_resource_id, metricnames: metric_name, aggregation: "Average", timespan: timespan, @@ -267,22 +268,27 @@ if metric_key == :free_space quota = azure_stats("storage_limit", **options) used = azure_stats("storage_used", **options) free_space(quota, used) else - # no read_iops, write_iops - # could add io_consumption_percent + replication_lag_stat = azure_flexible_server? ? "physical_replication_delay_in_seconds" : "pg_replica_log_delay_in_seconds" metrics = { cpu: "cpu_percent", connections: "active_connections", - replication_lag: "pg_replica_log_delay_in_seconds" + replication_lag: replication_lag_stat, + read_iops: "read_iops", # flexible server only + write_iops: "write_iops" # flexible server only } raise Error, "Metric not supported" unless metrics[metric_key] azure_stats(metrics[metric_key], **options) end else raise NotEnabled, "System stats not enabled" end + end + + def azure_flexible_server? + azure_resource_id.include?("/Microsoft.DBforPostgreSQL/flexibleServers/") end # only use data points included in both series # this also eliminates need to align Time.now def free_space(quota, used)