An admin's tool to get quick information about your instance entities like databases, fields, collections, cards and dashboards
- install Python
- install dependencies with pip3 install -r metagraph/requirements.txt
- configure the environment variables: user & password, or session_cookie in case you use sso, and host
- run python metagraph/main.py cypher
You'll get a metagraph.cypher file that you can enter in a Neo4j database to visualize the dependencies
A graph database will allow you to do impact analyses like: "what happens if I delete a certain card?" or "which cards are connected to a dashboard?"
Simply enter the session token as an environment variable and run the program as:
session_cookie=xxxxx python main.py cypher
Simply pass the --fields argument to the script. I added this but it's not being used at all, for now
Use the --database-list parameter, which accepts as a parameter a comma separated list of databases. For example, if you use "--database-list 1,3,5,10", it will get only the questions from those databases only (please take into account that this won't make the process faster, it only ignores the questions from those databases when it runs)
Starting from the new version (Jan-2024), the script does not write the cards on the archive. If you want to get which cards are archived, use the flag --no-skip-archived
Match (n)-[r]->(m) Return n,r,m;
Simply do
docker run --rm -it -p 7474:7474 -p 7687:7687 -e NEO4J_AUTH=none neo4j:5.12.0
and go to localhost:7474 (no authentication)
NOTE: if you run python metagraph/main.py neo4j the script will connect to the neo4j database and insert the nodes automatically. No need to copy and paste the cypher
After you populated the neo4j db, you can run queries like:
MATCH (n {key: 'dashboard8'}) return n
(dashboard8 is dashboard with the ID of 8 inside Metabase, so change it to anything you want here: table, card, collection)
...and you'll get the single node you're looking for. From there you can start navigating the graph to see the dependencies
- can't parse questions with snippets
- can't parse questions with CTEs
- Dockerize this
- Add tests
- Probably many refactors
- track better the references to cards, e.g. we can track if the card references are {{#something}}, but we don't when cards have variations of this
- the sqlglot library doesn't parse very well when there are foreign data wrappers or comments
- ignore questions that are from mongodb or h2, we're ignoring if there are databases of these types, but we don't ignore the questions




