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
nerdylive6mo ago
Hmm no i dont think thats possible Except you try to track it manually or automatically using external application
Asad Cognify
Asad CognifyOP6mo ago
Any idea how to track it? Either manually or is there an app that can do that?
nerdylive
nerdylive6mo 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 Cognify
Asad CognifyOP6mo ago
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
nerdylive6mo ago
Try checking the graphql api https://graphql-spec.runpod.io/#query-myself and the pod graphql query Those can be used
Asad Cognify
Asad CognifyOP6mo ago
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
nerdylive6mo ago
Uhh that's graphql i think that's not how you query it Try using postman I'll check
Asad Cognify
Asad CognifyOP6mo ago
I haven't used graphql queries before
nerdylive
nerdylive6mo 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 Cognify
Asad CognifyOP6mo ago
Can you share a doc for reference or examples
nerdylive
nerdylive6mo ago
Hmm search graphql im using postman for this
Asad Cognify
Asad CognifyOP6mo ago
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
nerdylive6mo ago
I think use params instead of headers for authorization 'https://api.runpod.io/graphql?api_key=pewpew Like this
Asad Cognify
Asad CognifyOP6mo ago
Okay. But even with this how will I get the running time of pods?
Asad Cognify
Asad CognifyOP6mo ago
No description
Asad Cognify
Asad CognifyOP6mo ago
can you help how to query for this?
nerdylive
nerdylive6mo ago
Hmm Check the pod query ?
Asad Cognify
Asad CognifyOP6mo ago
Okay
Asad Cognify
Asad CognifyOP6mo ago
I wonder what will this return in a team account. Because I want to query for a specific user
No description
nerdylive
nerdylive6mo ago
Hmm not sure im rarely using graphql
Asad Cognify
Asad CognifyOP6mo ago
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 Cognify
Asad CognifyOP6mo ago
This helped What would be the input
query pod($input: PodFilter) {
pod(input: $input) {
uptimeSeconds
}
}
query pod($input: PodFilter) {
pod(input: $input) {
uptimeSeconds
}
}
nerdylive
nerdylive6mo ago
oh nice
Asad Cognify
Asad CognifyOP6mo ago
Any idea what could be the $input? or how to set it?
nerdylive
nerdylive6mo 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 Cognify
Asad CognifyOP6mo ago
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
nerdylive6mo ago
yeah
digigoblin
digigoblin6mo ago
You can get most things by inspecting your browser
nerdylive
nerdylive6mo ago
might work
Asad Cognify
Asad CognifyOP6mo ago
such as?
digigoblin
digigoblin6mo ago
runtime { uptimeInSeconds } Should work But you can only get runtime when the pod is actually running, otherwise the GraphQL query fails
nerdylive
nerdylive6mo 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
nerdylive6mo ago
Oh there
No description
Asad Cognify
Asad CognifyOP6mo ago
Inspect in browser? Or via the graphql query using postman and/or curl
Asad Cognify
Asad CognifyOP6mo ago
@digigoblin @nerdylive
No description
No description
nerdylive
nerdylive6mo ago
Graphql postman works Hmm why is runtime null
Asad Cognify
Asad CognifyOP6mo ago
not sure. are you able to get a value?
digigoblin
digigoblin6mo ago
I get a value Is your pod actually running?
Asad Cognify
Asad CognifyOP6mo ago
it was not running at the time. Does it only give the runtime for that session or for its entire life, until terminated?
digigoblin
digigoblin6mo ago
runtime only returns results for pods that are actually running And doesn't include total life of the pod
Asad Cognify
Asad CognifyOP6mo ago
Yes I am getting a value as well while the pod is running
nerdylive
nerdylive6mo ago
Oh alright then
Want results from more Discord servers?
Add your server