{"id":15663943,"url":"https://github.com/rgl/powershellexporter","last_synced_at":"2025-07-30T14:33:37.404Z","repository":{"id":139753197,"uuid":"145040965","full_name":"rgl/PowerShellExporter","owner":"rgl","description":"Exports the results of PowerShell cmdlets as Prometheus Gauge Metrics","archived":false,"fork":false,"pushed_at":"2023-07-25T07:50:53.000Z","size":12,"stargazers_count":19,"open_issues_count":4,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-05T20:49:31.372Z","etag":null,"topics":["powershell","prometheus-exporter"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rgl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2018-08-16T21:29:52.000Z","updated_at":"2024-04-20T21:39:01.000Z","dependencies_parsed_at":null,"dependency_job_id":"6543404c-7ea5-400c-af18-370efe6d41c7","html_url":"https://github.com/rgl/PowerShellExporter","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/rgl/PowerShellExporter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgl%2FPowerShellExporter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgl%2FPowerShellExporter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgl%2FPowerShellExporter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgl%2FPowerShellExporter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rgl","download_url":"https://codeload.github.com/rgl/PowerShellExporter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rgl%2FPowerShellExporter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266673561,"owners_count":23966372,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":["powershell","prometheus-exporter"],"created_at":"2024-10-03T13:40:36.336Z","updated_at":"2025-07-23T12:03:58.783Z","avatar_url":"https://github.com/rgl.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"This PowerShell Exporter lets you export Prometheus Gauge Metrics from the result of a PowerShell cmdlet.\n\n**WARNING this is still a PoC; things will change for sure**\n\n\n# Usage\n\nThe cmdlets are defined inside `metrics.psm1` and are loaded at the application startup, e.g.:\n\n```powershell\n# count the number tcp connections grouped by their remote address, port, and state.\n# NB this must return PowerShellExporter.Metric objects.\nfunction Get-TcpConnectionsMetrics {\n    Get-NetTCPConnection `\n        | Where-Object {$_.RemotePort -ne 0} `\n        | Where-Object {$_.LocalAddress -ne '127.0.0.1' -and $_.LocalAddress -ne '::1'} `\n        | Group-Object -Property 'RemoteAddress','RemotePort','State' `\n        | ForEach-Object {\n            [PowerShellExporter.Metric]::new(\n                # metric value\n                $_.Count,\n                # metric labels\n                @{\n                    'remote_address' = $_.Group[0].RemoteAddress\n                    'remote_port' = $_.Group[0].RemotePort\n                    'state' = $_.Group[0].State\n                })\n        }\n}\n```\n\nThe metrics are defined inside `metrics.yml` and are evaluated at every prometheus scrape, e.g.:\n\n```yml\nmetrics:\n  # sample promql:\n  #   sum(pse_tcp_connections) by (state)\n  #   sum(pse_tcp_connections) by (remote_address)\n  - name: pse_tcp_connections\n    cmdlet: Get-TcpConnectionsMetrics\n```\n\nPrometheus can be configured with something alike:\n\n```yml\nglobal:\n  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.\n  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.\n  # scrape_timeout is set to the global default (10s).\n...\nscrape_configs:\n  ...\n  - job_name: pse\n    static_configs:\n      - targets:\n        - localhost:9360\n```\n\nThis exporter can be installed as a Windows service with something alike:\n\n```powershell\n.\\PowerShellExporter help         # show help.\n.\\PowerShellExporter install      # install with default settings.\nStart-Service PowerShellExporter  # start the service.\n```\n\n**NB** you can modify the default listening url `http://localhost:9360/metrics` with the `-url` command line argument, e.g., `-url http://localhost:9360/pse/metrics`.\n\n**NB** you need to make sure this exporter metrics are not taking too long to complete by observing the scrape durations with the promql `scrape_duration_seconds{job=\"pse\"}`.\n\n\n# Build\n\nType `make` and use what ends-up in the `dist` sub-directory.\n\nIf the PowerShell `System.Management.Automation.dll` assembly is not found, you need to get its location with the `[PSObject].Assembly.Location` snippet and modify the `PowerShellExporter.csproj` `\u003cHintPath\u003e`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frgl%2Fpowershellexporter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frgl%2Fpowershellexporter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frgl%2Fpowershellexporter/lists"}