5 months ago
Is there a way I can query memory per replica for a specific service with graphql? I have a way of checking the total ram across all the replicas for a specific service(see below) but was wondering if there was a way to find it for each individual replica
'''query metrics($startDate: DateTime!, $projectId: String!, $serviceId: String! = "", $environmentId: String = "") {
metrics(
projectId: $projectId
measurements: MEMORY_USAGE_GB
startDate: $startDate
serviceId: $serviceId
environmentId: $environmentId
) {
values {
ts
value
}
measurement
}
}
'''
Pinned Solution
5 months ago
You can query by replica by adding the argument groupBy: DEPLOYMENT_INSTANCE_ID to the query. Note that the replicas are named by their IDs, so if you want to match that to each replica, you'd want to log the variable RAILWAY_REPLICA_ID or something similar to that.
5 Replies
5 months ago
No.
That GraphQL metrics API only exposes aggregated service-level memory, not per-replica/pod memory. There’s no argument to break it down by replica.
To get per-replica memory, you’d need infra-level metrics (e.g. Kubernetes/Prometheus, Datadog, etc.), not this GraphQL query.
ekipchirchir
No. That GraphQL metrics API only exposes **aggregated service-level memory**, not **per-replica/pod** memory. There’s no argument to break it down by replica. To get per-replica memory, you’d need infra-level metrics (e.g. Kubernetes/Prometheus, Datadog, etc.), not this GraphQL query.
5 months ago
That is not true. Please make sure to validate your answers for bounty threads.
5 months ago
You can query by replica by adding the argument groupBy: DEPLOYMENT_INSTANCE_ID to the query. Note that the replicas are named by their IDs, so if you want to match that to each replica, you'd want to log the variable RAILWAY_REPLICA_ID or something similar to that.
0x5b62656e5d
You can query by replica by adding the argument `groupBy: DEPLOYMENT_INSTANCE_ID` to the query. Note that the replicas are named by their IDs, so if you want to match that to each replica, you'd want to log the variable `RAILWAY_REPLICA_ID` or something similar to that.
4 months ago
The groupBy: DEPLOYMENT_INSTANCE_ID worked. Thanks for this! By chance do you know if there is a way to restart one specific replica or would I have to restart all of them?
4 months ago
I don't think you're able to restart one specific replica. You'd need to restart the entire service.
Status changed to Solved brody • 4 months ago
