79 lines
2.3 KiB
Markdown
79 lines
2.3 KiB
Markdown
# Budget Exporter
|
|
|
|
Export Firefly-iii budget data for prometheus consumption.
|
|
|
|
## Usage
|
|
|
|
Install `Flask` and `requests` in your python environment:
|
|
|
|
pip install -r requirements.txt
|
|
|
|
Create a personal access token in your firefly installation:
|
|
|
|
Go to
|
|
[https://your-firefly-installation/profile](https://your-firefly-installation/profile)
|
|
, create a token and copy the (very long) string.
|
|
|
|
Put your personal access token and your API host in your environment:
|
|
|
|
export FIREFLY_PERSONAL_ACCESS_TOKEN="abcd.....1234"
|
|
export FIREFLY_API_HOST="https://your-firefly-installation"
|
|
|
|
Run the exporter:
|
|
|
|
FLASK_APP=exporter.py python -m flask run -h 127.0.0.1 -p 5000
|
|
|
|
Now scrape `/metrics` on port localhost:5000.
|
|
|
|
## Docker
|
|
|
|
Or use the prebuilt docker image:
|
|
|
|
docker run -e FIREFLY_API_HOST="https://your-firefly-installation" -e FIREFLY_PERSONAL_ACCESS_TOKEN="abcd....1234" -p 9449:5000 zknt/firefly-exporter
|
|
|
|
and scrape port 9449 on your docker host.
|
|
|
|
## XMPP Bot
|
|
|
|
There is a simple XMPP / Jabber bot which responds to budget queries.
|
|
|
|
### Installation
|
|
|
|
Install requirements:
|
|
|
|
pip install -r requirements-xmppbot.txt
|
|
|
|
Use your personal access token from above, setting the following variables
|
|
to your environment:
|
|
|
|
export FIREFLY_JABBER_ID="firefly@example.com" # The bots JID
|
|
export FIREFLY_JABBER_PASSWORD="abcd...1234" # The bots xmpp password
|
|
export FIREFLY_API_HOST="https://yout-firefly-installation"
|
|
export FIREFLY_PERSONAL_ACCESS_TOKEN="1234...abcd"
|
|
|
|
### Preparation
|
|
|
|
Register a XMPP / Jabber account for your bot.
|
|
*Caveat*: The bot does not support E2E and handles your financial data, so make
|
|
sure the account resides on the same server as your personal account which you will
|
|
use for querying.
|
|
|
|
Log into your bot account with a XMPP client and add your personal JID to your roster.
|
|
Querying will only work with a two-way subscription.
|
|
|
|
## Bot usage
|
|
|
|
Run `python xmppbot.py`.
|
|
|
|
From your personal account, send a normal chat message to your bot.
|
|
Available commands:
|
|
|
|
* `budgets` - list all budgets names
|
|
* `budget <budget>` - query data for given budget
|
|
|
|
### Docker
|
|
|
|
Run the prebuilt image:
|
|
|
|
docker run -e FIREFLY_JABBER_ID="firefly@example.com" -e FIREFLY_JABBER_PASSWORD="abcd...1234" -e FIREFLY_API_HOST="https://yout-firefly-installation" -e FIREFLY_PERSONAL_ACCESS_TOKEN="1234...abcd" zknt/firefly-xmppbot
|