I know QuestDB exposes metrics in Prometheus format, but I've never used Prometheus, so I was wondering what would be the best way to scrape the metrics QuestDB exposes, so I can store the metrics in a table on QuestDB itself.
That way I can reuse what I already know about QuestDB and I can easily integrate with a Grafana dashboard as I already have one setup and connected to other QuestDB tables.
Is this possible?
By default, QuestDB doesn't expose any metrics, but setting up the
metrics.enabledconfig variable, or setting up an env variableQDB_METRICS_ENABLED=TRUEwill make them available onlocalhost:9003/metrics.You could use Prometheus to scrape those metrics, but you can also use any server agent that understands the Prometheus format. It turns out telegraf has input plugins for Prometheus and output plugins for QuestDB, so you can use it to get the metrics from the endpoint and insert them into a QuestDB table.
This is a
telegraf.confconfiguration which works for me (using default ports)A few things to note:
url_tagto blank because of the same reason. By default the Prometheus plugin for Telegraf adds the url as an extra column and we don't need it.metric_version2 for the input plugin. This is to make sure I get all the metrics into a single table, rather than one table for each different metric, which I find annoying.drop_originalto discard all the sparse rows and output just the merged version.