Skip to content

Commit 75ea3f7

Browse files
aaijaziclaude
andauthored
Improve get_metrics tools (#29)
- Gracefully handle a 400 when trying to request HTTP latency on a Hobby tier plan - Support aggregating HTTP response counts - Support filtering on path and host for HTTP counts and latencies - Support HTTP latency quantile - Support more metrics endpoints: CPU/mem limit and targets, which helps LLMs tune autoscaling - A bit of code clean up (renaming variables, getting rid of some unneeded params and return values) 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 12ef503 commit 75ea3f7

7 files changed

Lines changed: 1053 additions & 193 deletions

File tree

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,15 @@ feedback or would like to report a bug or feature request, please [create a GitH
220220

221221
- **get_metrics** - Get performance metrics for any Render resource (services, Postgres databases, key-value stores). Metrics may be empty if the metric is not valid for the given resource
222222
- `resourceId`: The ID of the resource to get metrics for (service ID, Postgres ID, or key-value store ID) (string, required)
223-
- `metricTypes`: Which metrics to fetch (array of strings, required). Accepted values: 'cpu', 'memory', 'http', 'connections', 'instancecount', 'httperrors', 'responsetime'. CPU and memory are available for all resources. HTTP, instance count, HTTP error, and response time metrics are only available for services. Connection metrics are only available for databases and key-value stores
224-
- `startTime`: Start time for metrics query (RFC3339 format), defaults to 1 hour ago (string, optional)
225-
- `endTime`: End time for metrics query (RFC3339 format), defaults to now (string, optional)
226-
- `resolution`: Time resolution for data points in seconds, minimum 30 seconds. API defaults to 60 seconds if not provided (number, optional)
227-
- `aggregationMethod`: Data aggregation method. Accepted values: 'AVG', 'MAX', 'MIN', defaults to 'AVG' (string, optional)
223+
- `metricTypes`: Which metrics to fetch (array of strings, required). Accepted values: 'cpu_usage', 'cpu_limit', 'cpu_target', 'memory_usage', 'memory_limit', 'memory_target', 'http_request_count', 'active_connections', 'instance_count', 'http_latency'. CPU usage/limits/targets, memory usage/limits/targets, and instance count metrics are available for all resources. HTTP request counts and response time metrics are only available for services. Active connection metrics are only available for databases and key-value stores. Limits show resource constraints, targets show autoscaling thresholds
224+
- `startTime`: Start time for metrics query in RFC3339 format (e.g., '2024-01-01T12:00:00Z'), defaults to 1 hour ago. The start time must be within the last 30 days (string, optional)
225+
- `endTime`: End time for metrics query in RFC3339 format (e.g., '2024-01-01T13:00:00Z'), defaults to the current time. The end time must be within the last 30 days (string, optional)
226+
- `resolution`: Time resolution for data points in seconds. Lower values provide more granular data. Higher values provide more aggregated data points. API defaults to 60 seconds if not provided, minimum 30 seconds (number, optional)
227+
- `cpuUsageAggregationMethod`: Method for aggregating CPU usage metric values over time intervals. Accepted values: 'AVG', 'MAX', 'MIN', defaults to 'AVG' (string, optional)
228+
- `aggregateHttpRequestCountsBy`: Field to aggregate HTTP request count metrics by. Accepted values: 'host' (aggregate by request host), 'statusCode' (aggregate by HTTP status code). When not specified, returns total request counts (string, optional)
229+
- `httpLatencyQuantile`: The quantile/percentile of HTTP latency to fetch. Only supported for http_latency metric. Common values: 0.5 (median), 0.95 (95th percentile), 0.99 (99th percentile). Defaults to 0.95 if not specified (number, optional, min: 0.0, max: 1.0)
230+
- `httpHost`: Filter HTTP metrics to specific request hosts. Supported for http_request_count and http_latency metrics. Example: 'api.example.com' or 'myapp.render.com'. When not specified, includes all hosts (string, optional)
231+
- `httpPath`: Filter HTTP metrics to specific request paths. Supported for http_request_count and http_latency metrics. Example: '/api/users' or '/health'. When not specified, includes all paths (string, optional)
228232

229233
### Postgres Databases
230234

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ require (
2424
github.com/maxbrunsfeld/counterfeiter/v6 v6.11.2 // indirect
2525
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
2626
github.com/spf13/cast v1.9.2 // indirect
27+
github.com/stretchr/objx v0.5.2 // indirect
2728
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
2829
github.com/yuin/gopher-lua v1.1.1 // indirect
2930
golang.org/x/crypto v0.39.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
5757
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
5858
github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0=
5959
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
60+
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
61+
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
6062
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
6163
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
6264
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=

0 commit comments

Comments
 (0)