简体   繁体   中英

Creating an API to connect between ArangoDB and Prometheus to get the metrics of the data inside ArangoDB and expose it in Prometheus

I am trying to creating an API to connect between ArangoDB and Prometheus. I have a statistics of the data in the ArangoDB for example, how many times the simulation has been launched that I want to see in Prometheus. Therefore I would like to confirm the following questions if it is correct as I understood:

  1. I checked the getting started guide of Prometheus ( https://prometheus.io/docs/prometheus/latest/getting_started/ ) where we use node_exporter metrics in Prometheus. We need to launch this node_exporter and expose it on a specific IP address and port (listen address) then we need to configure the target in Prometheus config to target these ports that node_exporter is running on. Therefore, for my API, I need to create an API and app in Golang and this API/App need to be exposed in the specific HTTP port (for example 8001), then in Prometheus, I need to add the target for 8001 port in order for Prometheus to be able to scrape on my API. Is that correct?
  2. I need to find out the data format that Prometheus understand. I need to define the data format between my API (coming out from API) and Prometheus (coming into Prometheus). I found from this documentation ( https://prometheus.io/docs/instrumenting/exposition_formats/ ) that it's the text format in this form:
metric_name [ "{" label_name "=" `"` label_value `"` { "," label_name "=" `"` label_value `"` } [ "," ] "}" ] value [ timestamp ]

Is this correct? Could you please confirm my understanding?

Finally, it would be great if you can recommend me a source where someone has already done this kind of API to connect between ArangoDB and Prometheus. It would really help me to get started on this project. Thank you so much in advance.

It may be that you need only find a system that allows you to graph data. Prometheus has a sibling technology called Grafana .

Prometheus is a tool that is configured to periodically scrape (read) measurements from endpoints (==targets) of systems. These measurements describe the state of the system at the time it is scraped. Prometheus records these measurements in time-series databases(s) and provides an expressive query language that enables insights to be found in the data. Prometheus includes basic charting of this time-series data too. Frequently Prometheus is combined with Grafana.

Your question suggests that you're not looking to monitor the state of the database but to rather graph the (statistics) data contained in database tables. If so, Prometheus may not be what you need.

To answer your questions, Prometheus' requires systems to publish sets of metrics in a simple text format called Exposition Format. Any system that generates data in this format and can serve the metrics on an HTTP endpoint can be scraped by Prometheus.

Node Exporter is one example of such a system that publishes metrics that can be scraped by Prometheus. It publishes node (==host) metrics.

ArangoDB is another system that can publish metrics (about its state; the state of the database system) in Prometheus' Exposition Format, see:

https://www.arangodb.com/2020/03/monitoring-arangodb-prometheus-grafana/

I suspect, what you need is a solution to graph a set of data that you already have stored in ArangoDB tables. For this, you may be able to connect a system like Grafana to your database and then use SQL queries to surface the data in a form that can be graphed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM