{"id":17212410,"url":"https://github.com/facetoe/promformat","last_synced_at":"2025-04-13T22:32:29.321Z","repository":{"id":44350548,"uuid":"451076709","full_name":"facetoe/promformat","owner":"facetoe","description":"PromQL formatter","archived":false,"fork":false,"pushed_at":"2023-03-12T01:29:49.000Z","size":290,"stargazers_count":36,"open_issues_count":2,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T13:04:21.515Z","etag":null,"topics":["formatter","promql"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/facetoe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-01-23T10:58:24.000Z","updated_at":"2025-02-11T20:41:18.000Z","dependencies_parsed_at":"2024-03-21T01:15:11.440Z","dependency_job_id":null,"html_url":"https://github.com/facetoe/promformat","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facetoe%2Fpromformat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facetoe%2Fpromformat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facetoe%2Fpromformat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/facetoe%2Fpromformat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/facetoe","download_url":"https://codeload.github.com/facetoe/promformat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248790729,"owners_count":21162081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["formatter","promql"],"created_at":"2024-10-15T02:59:58.346Z","updated_at":"2025-04-13T22:32:27.997Z","avatar_url":"https://github.com/facetoe.png","language":"Python","readme":"# Promformat\n\nPromformat is a PromQL formatter written in Python. It works by building an AST from the CST provided by ANTLR4, and then using that to produce formatted code.\n\nThe result should be semantically identical to the unformatted version as promval compares the parse tree of the original and formatted expression and fails if they are not identical.\n\n# Usage\n\nFrom command line:\n```text\n# Format a file containing PromQL\npromformat \u003cpath to file\u003e\n\n# No arguments enters interpreter\npromformat\n```\n\nAs library:\n```text\nfrom promformat import format_query\nprint(format_query(\"1+1\"))\n```\n\n# Example\n\nGiven the PromQL:\n\n```\njob:request_latency_seconds:mean5m{job=\"myjob\"} \u003e 0.5\n```\n\nit will be formatted:\n\n```\njob:request_latency_seconds:mean5m\n{\n  job=\"myjob\"\n} \u003e 0.5\n```\n\nA more complex example:\n\n```text\n(\n  node_filesystem_avail_bytes * 100\n) / node_filesystem_size_bytes \u003c 10 and ON\n(\n  instance,\n  device,\n  mountpoint\n)\npredict_linear\n(\n  node_filesystem_avail_bytes\n  {\n    # We don't care about tmpfs\n    fstype!~\"tmpfs\"\n  } [1h],\n  24 * 3600\n) \u003c 0 and ON\n(\n  instance,\n  device,\n  mountpoint\n)\nnode_filesystem_readonly == 0\n```\n","funding_links":[],"categories":["Other"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffacetoe%2Fpromformat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffacetoe%2Fpromformat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffacetoe%2Fpromformat/lists"}