Shiladitya Mukherjee
Shiladitya Mukherjee

Reputation: 65

Can I just parse my log files and expose it to a http API for Prometheus to scrape?

I am new to Prometheus so pardon if this is a silly question.

I have several log files from which I can extract stats/metrics by some easy parser logic. If I just parse this and expose these metrics on a http API like the following: enter image description here

and add the http address to the Prometheus config file, will my Prometheus instance be able to scrape the metrics?

Also, another question: how does the server/database know that a particular type of metric is counter/histogram/gauge? Is it just nomenclature that is not really used by the server for queries or storage?

Upvotes: 0

Views: 1519

Answers (1)

DazWilkin
DazWilkin

Reputation: 40296

Yes. As long as the scrape target is formatted per Prometheus exposition format, you can generate the metrics however you wish. I was unable to find the document I thought existed but, Writing Exporters covers much of the same ground.

Prometheus data model is basically time-series (timestamp, float64) by labels (dimension). The SDK metrics, counter, gauge, histogram and summary are higher-level abstractions implemented by the SDKs for developer convenience.

Upvotes: 1

Related Questions