{"id":16826253,"url":"https://github.com/jorturfer/xk6-input-prometheus","last_synced_at":"2026-07-02T03:31:29.426Z","repository":{"id":185309576,"uuid":"673293402","full_name":"JorTurFer/xk6-input-prometheus","owner":"JorTurFer","description":"Read data from Prometheus","archived":false,"fork":false,"pushed_at":"2024-06-10T17:37:27.000Z","size":12589,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-03T19:07:14.396Z","etag":null,"topics":["prometheus","xk6","xk6-extension"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JorTurFer.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-01T09:57:57.000Z","updated_at":"2024-06-10T17:36:26.000Z","dependencies_parsed_at":"2024-10-24T05:19:42.305Z","dependency_job_id":"665a1df9-4e09-4642-a111-a96fdd41d66c","html_url":"https://github.com/JorTurFer/xk6-input-prometheus","commit_stats":{"total_commits":8,"total_committers":2,"mean_commits":4.0,"dds":0.125,"last_synced_commit":"369679f89ec026e187d53c77478284a1e24d1f89"},"previous_names":["jorturfer/xk6-input-prometheus"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/JorTurFer/xk6-input-prometheus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JorTurFer%2Fxk6-input-prometheus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JorTurFer%2Fxk6-input-prometheus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JorTurFer%2Fxk6-input-prometheus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JorTurFer%2Fxk6-input-prometheus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JorTurFer","download_url":"https://codeload.github.com/JorTurFer/xk6-input-prometheus/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JorTurFer%2Fxk6-input-prometheus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35032145,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-02T02:00:06.368Z","response_time":173,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["prometheus","xk6","xk6-extension"],"created_at":"2024-10-13T11:16:49.972Z","updated_at":"2026-07-02T03:31:29.052Z","avatar_url":"https://github.com/JorTurFer.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prometheus reader k6 extension\n\nK6 extension to read data from prometheus\n\n## Build\n\nTo build a custom `k6` binary with this extension, first ensure you have the prerequisites:\n\n- [Go toolchain](https://go101.org/article/go-toolchain.html)\n- Git\n\n1. Download [xk6](https://github.com/grafana/xk6):\n\n    ```bash\n    go install go.k6.io/xk6/cmd/xk6@latest\n    ```\n\n2. [Build the k6 binary](https://github.com/grafana/xk6#command-usage):\n\n    ```bash\n    xk6 build --with  github.com/JorTurFer/xk6-input-prometheus\n    ```\n\n   This will create a k6 binary that includes the xk6-input-prometheus extension in your local folder. This k6 binary can now run a k6 test.\n\n### Development\nTo make development a little smoother, use the `Makefile` in the root folder. The default target will format your code, run tests, and create a `k6` binary with your local code rather than from GitHub.\n\n```shell\ngit clone git@github.com/JorTurFer/xk6-input-prometheus.git\ncd xk6-input-prometheus\nmake build\n```\n\nUsing the `k6` binary with `xk6-input-prometheus`, run the k6 test as usual:\n\n```bash\n./k6 run example.js\n\n```\n\n## Examples: \n\n### Document Insertion Test\n```js\nimport prometheus from 'k6/x/prometheusread';\n\nexport default function () {\n    query()\n    queryRange()\n}\n\nfunction query (){\n    console.log(\"Query Sample\")\n    var client = prometheus.newPrometheusClient(\"http://demo.robustperception.io:9090\", \"user\", \"password\")\n    var response = client.query(\"alertmanager_notifications_total\")\n    \n    response.forEach(item =\u003e {   \n      var jsonBytes = item.marshalJSON()\n      var {metric, value} = JSON.parse(String.fromCharCode(...jsonBytes))\n  \n      console.log(metric.__name__) // show metric name\n      console.log(value[1]) // show metric value\n    });\n}\n\nfunction queryRange (){\n    console.log(\"QueryRange Sample\")\n    var client = prometheus.newPrometheusClient(\"http://demo.robustperception.io:9090\", \"user\", \"password\")\n    var end = new Date()\n    var start = new Date(end.getTime() - 5 * 60000)\n    var period = \"minute\"\n\n    var response = client.queryRange(\"rate(prometheus_tsdb_head_samples_appended_total[5m])\", start.toISOString(), end.toISOString(), period)\n\n    response.forEach(item =\u003e {   \n        var jsonBytes = item.marshalJSON()\n        var {metric, values} = JSON.parse(String.fromCharCode(...jsonBytes))\n    \n        console.log(metric) // show metric\n        console.log(values) // show metric values\n    });\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjorturfer%2Fxk6-input-prometheus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjorturfer%2Fxk6-input-prometheus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjorturfer%2Fxk6-input-prometheus/lists"}