Billing for separate users or pods

Hi is there any way to track usage (in terms of cost) for pods (for example based on ID) or better if there is a way to see how much each of my team user has cost?
43 Replies
nerdylive
nerdylive2mo ago
Hmm no i dont think thats possible Except you try to track it manually or automatically using external application
Asad Jamal Cognify
Any idea how to track it? Either manually or is there an app that can do that?
nerdylive
nerdylive2mo ago
Yes, by noting who uses that, calculate by the price time running on the pod I don't know what app is available for that yet for example
In a db
* User A ->
* Pod XXXXX (from Runpod ) ->
* Running time XXXXX (from Runpod ) ->
* Calculate the price $XX.XX Consumed
In a db
* User A ->
* Pod XXXXX (from Runpod ) ->
* Running time XXXXX (from Runpod ) ->
* Calculate the price $XX.XX Consumed
You get the basic idea now yeah
Asad Jamal Cognify
Thanks yeah that helps! How do I get the running time of a pod? I can get pod ID from runpodctl get pod <pod-id> is there a way to get the running time of the pod?
nerdylive
nerdylive2mo ago
Try checking the graphql api https://graphql-spec.runpod.io/#query-myself and the pod graphql query Those can be used
Asad Jamal Cognify
So
https://api.runpod.io/graphql?api_key=pewpew&query=myself
https://api.runpod.io/graphql?api_key=pewpew&query=myself
Will allow me to get the data on myself as a user?
No description
nerdylive
nerdylive2mo ago
Uhh that's graphql i think that's not how you query it Try using postman I'll check
Asad Jamal Cognify
I haven't used graphql queries before
nerdylive
nerdylive2mo ago
curl --location 'https://api.runpod.io/graphql?api_key=pewpew' \ --header 'Content-Type: application/json' \ --data '{"query":"query cpuTypes {\r\n cpuTypes {\r\n id\r\n displayName\r\n manufacturer\r\n cores\r\n threadsPerCore\r\n }\r\n}","variables":{}}' So basically thats how you use graphql the query in body
Asad Jamal Cognify
Can you share a doc for reference or examples
nerdylive
nerdylive2mo ago
Hmm search graphql im using postman for this
Asad Jamal Cognify
import requests

url = 'https://api.runpod.io/graphql'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
}
query = """
query {
user {
id
name
email
createdAt
}
}
"""
response = requests.post(url, headers=headers, json={'query': query})
if response.status_code == 200:
print(response.json())
else:
raise Exception(f"Query failed to run with a {response.status_code}.")
import requests

url = 'https://api.runpod.io/graphql'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_ACCESS_TOKEN'
}
query = """
query {
user {
id
name
email
createdAt
}
}
"""
response = requests.post(url, headers=headers, json={'query': query})
if response.status_code == 200:
print(response.json())
else:
raise Exception(f"Query failed to run with a {response.status_code}.")
chatgpt generated this. Maybe this can work too
nerdylive
nerdylive2mo ago
I think use params instead of headers for authorization 'https://api.runpod.io/graphql?api_key=pewpew Like this
Asad Jamal Cognify
Okay. But even with this how will I get the running time of pods?
Asad Jamal Cognify
can you help how to query for this?
nerdylive
nerdylive2mo ago
Hmm Check the pod query ?
Asad Jamal Cognify
Okay
Asad Jamal Cognify
I wonder what will this return in a team account. Because I want to query for a specific user
No description
nerdylive
nerdylive2mo ago
Hmm not sure im rarely using graphql
Asad Jamal Cognify
It returned for the main account only. And it gives uptimeseconds: 0 if the pod is in exited state. I dont think it gives the total uptime for a pod or specifc to a user
Asad Jamal Cognify
This helped What would be the input
query pod($input: PodFilter) {
pod(input: $input) {
uptimeSeconds
}
}
query pod($input: PodFilter) {
pod(input: $input) {
uptimeSeconds
}
}
nerdylive
nerdylive2mo ago
oh nice
Asad Jamal Cognify
Any idea what could be the $input? or how to set it?
nerdylive
nerdylive2mo ago
let me try wait {"input": {"podId": "jdw3kl6vcaaz8x"}}
curl --location 'https://api.runpod.io/graphql?api_key=pewpeeew' \
--header 'Content-Type: application/json' \
--data '{"query":"query pod($input: PodFilter) {\r\n pod(input: $input) {\r\n uptimeSeconds\r\n }\r\n}","variables":{"input":{"podId":"jdw3kl6vcaaz8x"}}}'
curl --location 'https://api.runpod.io/graphql?api_key=pewpeeew' \
--header 'Content-Type: application/json' \
--data '{"query":"query pod($input: PodFilter) {\r\n pod(input: $input) {\r\n uptimeSeconds\r\n }\r\n}","variables":{"input":{"podId":"jdw3kl6vcaaz8x"}}}'
not sure why the uptimeseconds is always 0 lol
Asad Jamal Cognify
Yeah I am getting 0 as well. Wait.. even when the pod is running it shows 0? Is there any way to query audit logs other than the console?
nerdylive
nerdylive2mo ago
yeah
digigoblin
digigoblin2mo ago
You can get most things by inspecting your browser
nerdylive
nerdylive2mo ago
might work
Asad Jamal Cognify
such as?
digigoblin
digigoblin2mo ago
runtime { uptimeInSeconds } Should work But you can only get runtime when the pod is actually running, otherwise the GraphQL query fails
nerdylive
nerdylive2mo ago
curl --location 'https://api.runpod.io/graphql?api_key=Pewpew' \ --header 'Content-Type: application/json' \ --data '{"query":"query GetAuditLogs($input:AuditLogInput!){auditLogs(input:$input){edges{ownerId,actorId,email,resourceType,resourceId,action}}}","variables":{"input":{"ownerId":"user_XXXXX","limit":202}}}'
nerdylive
nerdylive2mo ago
Oh there
No description
Asad Jamal Cognify
Inspect in browser? Or via the graphql query using postman and/or curl
Asad Jamal Cognify
@digigoblin @nerdylive
No description
No description
nerdylive
nerdylive2mo ago
Graphql postman works Hmm why is runtime null
Asad Jamal Cognify
not sure. are you able to get a value?
digigoblin
digigoblin2mo ago
I get a value Is your pod actually running?
Asad Jamal Cognify
it was not running at the time. Does it only give the runtime for that session or for its entire life, until terminated?
digigoblin
digigoblin2mo ago
runtime only returns results for pods that are actually running And doesn't include total life of the pod
Asad Jamal Cognify
Yes I am getting a value as well while the pod is running
nerdylive
nerdylive2mo ago
Oh alright then