My team once had to deal with this exact problem and I've written an article about how we came up with a solution for this.
You can read it here.
I know it has been almost 3 years since this question was made, but I hope it can help people that might have this problem in the future.
In short, we added a new statement to all the write (create, update, delete) transactions in all our services. That statement is nothing more than an emission of an outbox event (a write in a table/collection named "outbox" that describes what is being written). Then, that event gets caught by a Kafka Source Connector and put into a topic that is being consumed by a new microservice which has a Neo4j database and builds the knowledge graph of the whole system. That service can then provide an API (REST, GraphQL, ...) to tell whether an entity is being used and/or referenced by others, even if that reference is not direct, e.g. A->B vs A->B->C, in the former case, A uses B, in the latter, A uses B directly and C indirectly because B uses C, and it works with even a greater relationship length (e. g. A->B->C->D->...) thanks to the potentialities of a graph database.