This repository contains an example of configuring a Postgres database and a Steampipe database using postgres_fwd
- then exploring it using Evidence.
Evidence is a Business Intelligence as Code framework, using markdown + sql to make it easy to build rich reports and analyses.
Steampipe is a postgres-based tool that connects to external APIs and lets you query them with SQL, creating an ergonomic method of getting data from over 100 popular APIs.
- Ensure docker and docker-compose are installed
- Ensure node is installed (min version v16)
- If you are using linux, I recommend using nvm to install node
- The scripts in this project make a few assumptions
- They assume they are being run on Linux
- This may work on MacOS, but you may need to execute them differently
e.g. instead of
./scripts/x.sh
, usezsh ./scripts/x.sh
- This may work on Windows, if run within
WSL2
- This may work on MacOS, but you may need to execute them differently
e.g. instead of
bash
,sudo
,unzip
,wget
, andpsql
are installed
- They assume they are being run on Linux
- Run
./scripts/prepare.sh
- Creates
./postgres
directory - Creates
./steampipe
directory- Changes ownership of
./steampipe
to userid9193
- This step asks for sudo premissions, it is the only sudo step in the project. Steampipe will not start without this step.
- Changes ownership of
- Creates
- Copy
steampipe.env.example
->steampipe.env
- Add your Github Personal Access Token
- Start the databases with
docker compose up
- Wait for both steampipe and postgres to become available
- Postgres will log:
database system is ready to accept connections
- Steampipe will log:
Steampipe service is running
- Postgres will log:
- Wait for both steampipe and postgres to become available
- Run
./scripts/add-remote-schemas.sh
- Installs the
github
plugin in steampipe - Executes
./scripts/sql/remote-schema.sql
- Enables
postgres_fdw
- Sets up the connection to steampipe
- Imports the github schema
- Enables
- Executes
./scripts/sql/test-query.sql
- Verifies that the
evidence-dev
organization can be selected frompostgres
(notsteampipe
)
- Verifies that the
- Installs the
- Run
npm install
- Run
npm run dev
- Open http://localhost:3000
- Configure the Database
- You can use the connection string
postgres://postgres:postgres@localhost:5432/postgres
- You can use the connection string
- ???
- Profit
Using Steampipe with postgres_fdw
provides a pretty straightforward way to immediately enrich a Postgres database with a wide variety of external APIs, without the need for ETL software.
Evidence plays nicely with API rate limits, data is only pulled from the database when the project is built. This makes it a great choice for reports where you may join to an API, which could result in many API calls; or reports that may see a lot of traffic. In the (near) future, Evidence will support multiple data sources (and a SQL runtime to query across them), so postgres_fdw
will no longer be required, and the same fundamental approach will work with any Evidence supported data source.
The Evidence report is written in a single file (./pages/index.md
), and demonstrates the ability to query APIs, existing data, and both in a single query, done with a (relatively) straightforward method of enriching a Postgres data warehouse with live API data.