{"id":19092416,"url":"https://github.com/p7g/wealthsimple-prometheus","last_synced_at":"2025-11-12T11:33:53.041Z","repository":{"id":136445661,"uuid":"277978079","full_name":"p7g/wealthsimple-prometheus","owner":"p7g","description":"Get your Wealthsimple into your Prometheus","archived":false,"fork":false,"pushed_at":"2020-07-08T04:28:28.000Z","size":20,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-22T07:42:02.338Z","etag":null,"topics":["money","prometheus","prometheus-metrics","wealthsimple"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/p7g.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":"2020-07-08T03:15:30.000Z","updated_at":"2025-02-11T00:12:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"b5a6f74a-4292-4959-bf8d-da0fc0ddc999","html_url":"https://github.com/p7g/wealthsimple-prometheus","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/p7g/wealthsimple-prometheus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p7g%2Fwealthsimple-prometheus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p7g%2Fwealthsimple-prometheus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p7g%2Fwealthsimple-prometheus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p7g%2Fwealthsimple-prometheus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p7g","download_url":"https://codeload.github.com/p7g/wealthsimple-prometheus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p7g%2Fwealthsimple-prometheus/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284028079,"owners_count":26935272,"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-11-12T02:00:06.336Z","response_time":59,"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":["money","prometheus","prometheus-metrics","wealthsimple"],"created_at":"2024-11-09T03:19:39.904Z","updated_at":"2025-11-12T11:33:53.036Z","avatar_url":"https://github.com/p7g.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wealthsimple-prometheus\n\n\u003e **Please note**: Do _not_ run this facing the internet, unless you're fine with\n\u003e the whole world seeing how much money you've got in the bank.\n\nThis is a pretty simple service thing that polls [Wealthsimple] for account data\nand makes it available for [Prometheus] to pull it in.\n\n[Wealthsimple]: https://wealthsimple.com\n[Prometheus]: https://prometheus.io\n\nCurrently, there are four [gauges]:\n\n- `wealthsimple_deposited`: The total amount of money that has been deposited\n- `wealthsimple_withdrawn`: The total amount of money that has been withdrawn\n- `wealthsimple_net_liquidation`: The value were all assets to be liquidated\n- `wealthsimple_gross_position`: The sum of all positions\n\nEach of these gauges is tagged with the following:\n\n- `account_id`: The account identifier within Wealthsimple\n- `account_type`: The type of account\n- `account_name`: The nickname of the account\n\n[gauges]: https://prometheus.io/docs/concepts/metric_types/#gauge\n\nThis is only scratching the surface, though. Take a look at the [api docs] to\nsee some of the other cool stuff that maybe works.\n\n[api docs]: https://developers.wealthsimple.com/\n\n## Usage\n\nTo use this, all you need to do is clone the repo and run `cargo run` inside it.\nYou could use a release build, but I don't think there's much concern about\nperformance here... (it spends most of the time sleeping).\n\nWhen you run it, it'll prompt you for your credentials. These aren't stored\nanywhere (which means you'll have to enter it every time you restart it), and\nthe password prompt is an actual password prompt (the text you type is not\ndisplayed). If you have 2FA set up (which you probably should), you'll be\nprompted for a one-time password as well. You shouldn't have to enter the a 2FA\ncode again for the life of the program (unless it runs more than 30 days), since\nit passes the same `remember=true` as the actual Wealthsimple browser client.\n\nOnce it's running, you can point Prometheus at it. Currently it always just runs\non port 8080.\n\nThis is how I've got it configured:\n\n```yaml\nscrape_configs:\n  - job_name: 'wealthsimple'\n    static_configs:\n    - targets: ['localhost:8080']\n```\n\n## How it works\n\nThere are two threads: One to poll Wealthsimple forever, and one to serve\nrequests to the `/metrics` resource forever.\n\nI've avoided `unwrap()`-ing anything so that this will be reliable, but there\nare plenty of places where errors are propagated, which will instantly\nterminate the program. We'll consider improving this a TODO.\n\nIn the polling loop, the following happens:\n\n1. A request is made to `https://api.production.wealthsimple.com/v1/accounts` to\n   get a list of the user's accounts.\n1. If the request came back as a 401, the auth token probably expired, so get a\n   new one and try again.\n1. Some choice information is shoved into the gauges we mentioned earlier.\n1. Sleep for 5 minutes.\n\nThe server loop is even simpler:\n\n1. Get the next request.\n1. Return a 404 status if it's not for `/metrics`.\n1. Encode the gauge data into Prometheus-speech.\n1. Send it back.\n\n## Why?\n\nI'm not a fan of how Wealthsimple graphs your accounts by default. I don't\nreally care that the value of my account has increased due to my deposits; it\njust makes it more difficult to read the changes in returns.\n\nKeep in mind I'm no [financier], I mostly just like pretty graphs. If you're\nanything like me, this is the query you're looking for (probably; I'm a data\nnoob):\n\n```promql\n(((wealthsimple_net_liquidation - wealthsimple_withdrawn) / (wealthsimple_deposited - wealthsimple_withdrawn)) - 1) * 100\n```\n\n[financier]: https://en.wikipedia.org/wiki/Financier_(cake)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp7g%2Fwealthsimple-prometheus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp7g%2Fwealthsimple-prometheus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp7g%2Fwealthsimple-prometheus/lists"}