I don’t personally use this, but you can use loki.process and stage.metrics to turn logs into metrics. See loki.process | Grafana Alloy documentation
Your comment here though:
sounds a lot more dynamic. Like any sort of log parsing, the logs need some structure to them and you’d need to know what you are parsing for from alloy configuration standpoint. If you are looking to parse ad-hoc JSON files and generate metrics dynamically might be easier for you to just write a script to do that.