{"id":13541288,"url":"https://github.com/drbrain/nu_plugin_prometheus","last_synced_at":"2026-01-08T00:14:06.097Z","repository":{"id":242310868,"uuid":"809223967","full_name":"drbrain/nu_plugin_prometheus","owner":"drbrain","description":"A nushell plugin for querying prometheus","archived":false,"fork":false,"pushed_at":"2025-03-17T00:27:58.000Z","size":626,"stargazers_count":8,"open_issues_count":7,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-18T11:38:09.719Z","etag":null,"topics":["nushell","prometheus"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drbrain.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2024-06-02T04:20:50.000Z","updated_at":"2025-02-16T19:22:57.000Z","dependencies_parsed_at":"2024-06-02T06:23:42.036Z","dependency_job_id":"948fd795-0cc7-4ccd-952c-536f0ffa69f3","html_url":"https://github.com/drbrain/nu_plugin_prometheus","commit_stats":null,"previous_names":["drbrain/nu_plugin_prometheus"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drbrain%2Fnu_plugin_prometheus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drbrain%2Fnu_plugin_prometheus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drbrain%2Fnu_plugin_prometheus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drbrain%2Fnu_plugin_prometheus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drbrain","download_url":"https://codeload.github.com/drbrain/nu_plugin_prometheus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244959446,"owners_count":20538625,"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":["nushell","prometheus"],"created_at":"2024-08-01T10:00:43.121Z","updated_at":"2026-01-08T00:14:06.090Z","avatar_url":"https://github.com/drbrain.png","language":"Rust","readme":"# nu_plugin_prometheus\n\nA nushell plugin for querying prometheus\n\nSupports:\n* nushell 0.109.1\n* Prometheus API\n  * Instant queries\n  * Range queryies\n  * Target status\n  * Series\n  * Label names\n  * Label values\n* Saved sources for convenience or mutual TLS authentication\n* Parsing Prometheus output\n* Scraping Prometheus targets\n\n## Usage\n\n### Sources\n\nA prometheus plugin can be queried directly with `--url`:\n\n```nushell\n\"up\" | prometheus query --source https://test.prometheus.example/\n```\n\nNushell plugin configuration can be used to save configure prometheus sources\nincluding mTLS.\n\n```nushell\n$env.config.plugins.prometheus = {\n  sources: {\n    prod: {\n      url: \"https://prod.prometheus.example/\"\n      cert: ( $env.HOME | path join \".config/nu_plugin_prometheus/user.crt\" )\n      key: ( $env.HOME | path join \".config/nu_plugin_prometheus/user.pk8.key\" )\n      cacert: ( $env.HOME | path join \".config/nu_plugin_prometheus/ca.crt\" )\n    }\n  }\n}\n```\n\nThe key must be in PKCS#8 format. You can convert a PEM key with:\n\n```nushell\nopenssl pkcs8 -topk8 -inform PEM -outform DER -in user.key -out user.pk8.key\n```\n\nUse `--source` or `-s` to use a configured source:\n\n```nushell\n\"up\" | prometheus query --source prod\n```\n\n### Queries\n\n#### Instant\n\nPipe a prometheus query to `prometheus query` for an instant query:\n\n```nushell\n\"up\" | prometheus query --url https://prometheus.example:9090/\n```\n\nThis will output a table:\n\n|name|labels|value|timestamp|\n|-|-|-|-|\n|up|{job: prometheus, instance: prometheus.example:9090}|1|1435781451|\n|up|{job: node, instance: prometheus.example:9100}|0|1435781451|\n\n#### Range\n\nA range query requires `--start`, `--end` and `--step` arguments:\n\n```nushell\n\"up\" | prometheus query range --url https://prometheus.example:9090/ --start ((date now) - 30sec) --end (date now) --step 15sec\n```\n\n|name|labels|values|\n|-|-|-|\n|up|{job: prometheus, instance: prometheus.example:9090}|[{value: 1, timestamp: 1435781430}, {value: 1, timestamp: 1435781445} {value: 1, timestamp: 1435781460}]|\n|up|{job: node, instance: prometheus.example:9100}|[{value: 0, timestamp: 1435781430}, {value: 0, timestamp: 1435781445} {value: 1, timestamp: 1435781460}]|\n\n#### Flattening labels\n\nAdding `--flatten` will flatten labels into each row.\n\n```nushell\n\"up\" | prometheus query --url https://prometheus.example:9090/ --flatten\n```\n\nOutputs:\n\n|name|instance|job|value|timestamp|\n|-|-|-|-|-|\n|up|prometheus.example:9090|prometheus|1|1435781451|\n|up|prometheus.example:9100|job|0|1435781451|\n\nIf a metric uses \"name\" as a label it will overwrite the \"name\" column.\n\nFor a range query the values are not flattened.\n\n### Label names\n\nRetrieve labels names with:\n\n```nushell\nprometheus label names --url https://prometheus.example:9090/\n```\n\nLabel names can be filtered by selector as input, and by time with `--start`\nand `--end`.\n\nTo query \"up\" label names:\n\n```nushell\n\"up\" | prometheus label names --url https://prometheus.example:9090/\n```\n\n### Label values\n\nRetrieve labels values with:\n\n```nushell\n\"version\" | prometheus label values --url https://prometheus.example:9090/\n```\n\nLabel values can be filtered by name as input, by time with `--start` and\n`--end`, and by selector as extra arguments.\n\nTo query \"version\" label values for the \"postgres\" job:\n\n```nushell\n\"version\" | prometheus label values --url https://prometheus.example:9090/ 'job=\"postgres\"'\n```\n\n### Metric metadata\n\nRetrieve metric metadata with:\n\n```nushell\nprometheus metric metadata --url https://prometheus.example:9090/\n```\n\nThis may take some time, so supply a metric name as input or supply `--limit`\nto reduce the number of records retrieved.  Use `--limit-per-metric` to reduce\nthe number of metadata items retrieved per metric.\n\n## Series\n\nRetrieve series matching the given label set with:\n\n```nushell\n[up process_start_time_seconds{job=\"prometheus\"}] |\nprometheus series -s home\n```\n\nSeries are retrieved using a selector given as input.  Series retrived may be\nfiltered by time with `--start` and `--end`.\n\n## Targets\n\nRetreive prometheus target discovery with:\n\n```nushell\nprometheus targets --url https://prometheus.example:9090/\n```\n\nThis retrives targets in either the active or dropped states.  The `any`\nargument alse retrieves both states.\n\nUse `active`, or `dropped` to directly filter active or dropped targets.  This\nwill output only the selected state.\n\n## Scraping\n\nScrape a prometheus target with:\n\n```nushell\n\"https://target.example:1234/metrics\" | prometheus scrape\n```\n\n## Parsing\n\nParse text prometheus output with:\n\n```nushell\nopen saved.metrics | prometheus parse\n```\n\n","funding_links":[],"categories":["Plugins"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrbrain%2Fnu_plugin_prometheus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrbrain%2Fnu_plugin_prometheus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrbrain%2Fnu_plugin_prometheus/lists"}