How to get the count of queued jobs #23868
Answered
by
garethbrickman
chrishiste
asked this question in
Q&A
-
What's the issue or suggestion?I'm looking for a way to retrieve the count of queued jobs in Dagster. Specifically, I need to monitor the number of jobs waiting to be processed in the queue. Any guidance or examples would be appreciated. Thanks! Additional informationNo response Message from the maintainersImpacted by this issue? Give it a 👍! We factor engagement into prioritization. |
Beta Was this translation helpful? Give feedback.
Answered by
garethbrickman
Aug 23, 2024
Replies: 1 comment
-
You can query the GraphQL API to get all the runs with a import requests
def get_queued_jobs_count():
url = "http://<your-dagster-instance>/graphql"
query = """
{
pipelineRunsOrError(filter: {statuses: [QUEUED]}) {
... on PipelineRuns {
results {
runId
status
}
}
}
}
"""
response = requests.post(url, json={'query': query})
data = response.json()
queued_jobs = data['data']['pipelineRunsOrError']['results']
return len(queued_jobs)
queued_jobs_count = get_queued_jobs_count()
print(f"Number of queued jobs: {queued_jobs_count}") |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
chrishiste
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can query the GraphQL API to get all the runs with a
QUEUED
status and use a script to count them: