{"id":21032505,"url":"https://github.com/majkinetor/psinflux","last_synced_at":"2025-08-25T16:12:19.885Z","repository":{"id":76786916,"uuid":"89629275","full_name":"majkinetor/psinflux","owner":"majkinetor","description":"InfluxDb Powershell HTTP API client","archived":false,"fork":false,"pushed_at":"2020-06-15T13:23:07.000Z","size":674,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-13T12:05:16.479Z","etag":null,"topics":["influxdb","powershell"],"latest_commit_sha":null,"homepage":null,"language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/majkinetor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2017-04-27T18:40:20.000Z","updated_at":"2023-11-08T09:47:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"18f81d2d-3bf2-40f5-92c4-1a4829c879b1","html_url":"https://github.com/majkinetor/psinflux","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/majkinetor%2Fpsinflux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/majkinetor%2Fpsinflux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/majkinetor%2Fpsinflux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/majkinetor%2Fpsinflux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/majkinetor","download_url":"https://codeload.github.com/majkinetor/psinflux/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254349284,"owners_count":22056314,"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":["influxdb","powershell"],"created_at":"2024-11-19T12:43:26.436Z","updated_at":"2025-05-15T13:31:12.262Z","avatar_url":"https://github.com/majkinetor.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PSInflux\n\nThis PowerShell 3+ module uses Influx DB [HTTP API](https://docs.influxdata.com/influxdb/v1.2/guides/querying_data) to query and send data.\n\nTo install, clone this project then run: `./install.ps1`. To be able to use templated queries in interactive manner, you also need CLI tool [fzf](https://github.com/junegunn/fzf) that you can install via Chocolatey: [`cinst fzf`](https://chocolatey.org/packages/fzf)\n\n## How to use\n\nSet the following environment variables or put them in $PROFILE:\n\n```powershell\n$ENV:INFLUX_SERVER = \"http://influxdb.server.com:8086\"\n$ENV:INFLUX_DB     = \"mydb\"\n```\n\nLoad with `import-module psinflux`. You can use normal PowerShell commands to get help:\n\n* List of functions: `gcm -Module psinflux`\n* Help for function: `man iq`\n\n### Query\n\nUse `iq` (alias for `Send-Query`) to query the database:\n\n```powershell\niq select value,tag from measure limit 20\n```\n\nFor convenience, you don't generally have to put a query inside a PowerShell string.\n\n`iq` (influx query) function parses returned data into PowerShell objects which can be slow for large number of points. Use `iqr` (raw query) to get large collections.\n\n### Templates\n\nUse `itemplate` (alias for `Invoke-Template`) to send predefined queries. Predefined queries can be added by the user and can contain PowerShell placeholders for getting the user input, for example metric or database name. Integrated templates use [fzf](https://github.com/junegunn/fzf) (install via chocolatey: [`cinst fzf`](https://chocolatey.org/packages/fzf)) fuzzy finder as input selector.\n\n[Default template](https://github.com/majkinetor/psinflux/blob/master/templates.txt) is always used and has several predefined queries and selectors/input methods. You can add your own template by using a `$FilePath` parameter or setting `$Env:INFLUX_TEMPLATE` environment variable. User template is then merged with the default one.\n\nQuery templates are text files that contain two sections: powershell code and query sentences. Two sections are separated by '---' line. Comments are marked with #.\n\nUser can define small Powershell helper scriptblocks and Powershell variables that serve to replace query placeholders, marked with `$PLACEHOLDER` keywords. There are 2 specially named placeholders, those starting with `SELECT_` or `INPUT_` that are replaced with scriptblock invocations. Other $ prefixed words are simple PowerShell variables. Default template defines few generally useful selectors can be reused in user template.\n\nFor example, user template can look like this:\n\n```\n$SELECT_CPU_FIELDS = { ( iq show field keys from cpu  | % fieldkey | fzf \"Select 1 or more CPU (with TAB key) fields\") -join ',' }\n\n---\n\nselect $SELECT_CPU_FIELDS from cpu limit 50    # Select field from the CPU metric\n```\n\n![screen.gif](https://cdn.rawgit.com/majkinetor/psinflux/1cd398bc/screen.gif)\n\n### Writing data\n\nTo write data points to the database use `Send-Data` function:\n\n```powershell\n$cpu_load = Get-Counter '\\Processor(_Total)\\% Processor Time' | % CounterSamples | % CookedValue\nSend-Data \"cpu,host=$Env:COMPUTERNAME,user=$Env:USERNAME value=$cpu_load\"\n```\n\nYou can use `[DateTime]::UtcNow.ToString('o')` to send date time instead of nanoseconds until Unix epoch. If you do that, pass parameter `$UseRoundTripTime` to make function automatically convert time points to correct format.\n\nYou can also send an array of strings:\n\n```powershell\n$time = [DateTime]::UtcNow.ToString('o')\nSend-Data \"test1 value=1 $time\", \"test2 value=2 $time\" -RoundTripTime\n```\n\n\nHere is another example:\n\n```powershell\nPS\u003e 1..10 | % { $x = 10*$_ + (Get-Random 10); Send-Data \"test1 value=$x\"; sleep 1 }\n\nStatusCode StatusDescription Headers\n---------- ----------------- -------\n       204 No Content        {[Request-Id, 03fed428-2fee-11e7-8c50-000000000000], [X-Influxdb-Version, 1.2.2], [Content-Type, application/json], [Date, Wed, 03 May 2017 10:48:17 GMT]}\n       204 No Content        {[Request-Id, 04997ca0-2fee-11e7-8c51-000000000000], [X-Influxdb-Version, 1.2.2], [Content-Type, application/json], [Date, Wed, 03 May 2017 10:48:18 GMT]}\n       ...\n\n\nPS\u003e iq select value from test1 order by time desc\n\ntime                           value\n----                           -----\n2017-05-03T10:48:26.893855822Z   109\n2017-05-03T10:48:25.841784978Z    94\n2017-05-03T10:48:24.789887277Z    85\n2017-05-03T10:48:23.729787415Z    78\n2017-05-03T10:48:22.673721527Z    66\n2017-05-03T10:48:21.617741836Z    56\n2017-05-03T10:48:20.561755378Z    40\n2017-05-03T10:48:19.497824954Z    38\n2017-05-03T10:48:18.437837385Z    23\n2017-05-03T10:48:17.384615849Z    17\n```\n\n![test graph](https://cdn.rawgit.com/majkinetor/psinflux/2537038c/test1.png)\n\n\n#### Send to StatsD\n\nYou can use `Send-Statsd` to write to Statsd server. The following example uses [Telegraf](https://www.influxdata.com/getting-started-with-sending-statsd-metrics-to-telegraf-influxdb/) as StatsD server so sending tags is supported:\n\n```powershell\nSend-Statsd \"mycounter,host=${Env:COMPUTERNAME}:10|c\", \"mycounter,host=MEH:100|c\" -Ip 127.0.0.1\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmajkinetor%2Fpsinflux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmajkinetor%2Fpsinflux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmajkinetor%2Fpsinflux/lists"}