Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> We could select for this using jq, but promql already lets us filter by metric names so we'll do that instead

I think it would have been much better to do this via jq instead, for the sake of demonstration. This is, after all, an article on jq, not on promql...



Good call, I will update the post.

It would look like this, for posterity:

jq '.data.result[].metric | select(.app == "toodle-app").task_name'

The reason I was putting the querying into promql where possible is that it is (I assume) more efficient to do that filtering on the server & only return matching values rather than returning "everything" & filtering locally. But your point stands, it's tangential here. Thanks for the feedback this will definitely improve the post!

Edit: updated!


I think it makes sense to point out that it could be done better using just promql, but it's useful to show how to do it in just jq for those using other tools!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: