# How to expose a metric for the fdbmonitor count of restarts?

**URL:** <https://forums.foundationdb.org/t/how-to-expose-a-metric-for-the-fdbmonitor-count-of-restarts/4445>\
**Category:** Using FoundationDB\
**Created:** [April 19, 2024, 11:29am UTC](https://forums.foundationdb.org/t/how-to-expose-a-metric-for-the-fdbmonitor-count-of-restarts/4445 "2024-04-19T11:29:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gm42](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/gm42/32/1784_2.png) [@gm42](https://forums.foundationdb.org/u/gm42)\
**Post date:** [April 19, 2024, 11:29am UTC](https://forums.foundationdb.org/t/how-to-expose-a-metric-for-the-fdbmonitor-count-of-restarts/4445/1 "2024-04-19T11:29:16Z")

</div>

Is there a better way to count the number of restarts which `fdbmonitor` performs, other than parsing its logged output?

---

<div class="post-metadata">

**Author:** ![PierreZ](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/pierrez/32/866_2.png) [@PierreZ](https://forums.foundationdb.org/u/PierreZ)\
**Post date:** [April 20, 2024, 9:17am UTC](https://forums.foundationdb.org/t/how-to-expose-a-metric-for-the-fdbmonitor-count-of-restarts/4445/2 "2024-04-20T09:17:08Z")

</div>

In my company, we are exporting metrics in [Prometheus format](https://github.com/CleverCloud/foundationdb-exporter/). `status json` is exporting the `uptime_seconds` per process. A reset in the counter means that fdbserver has been restarted. This info has been pretty useful for us to detect OOM from misconfigured StorageServers

---

<div class="post-metadata">

**Author:** ![gm42](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/gm42/32/1784_2.png) [@gm42](https://forums.foundationdb.org/u/gm42)\
**Post date:** [April 20, 2024, 9:21am UTC](https://forums.foundationdb.org/t/how-to-expose-a-metric-for-the-fdbmonitor-count-of-restarts/4445/3 "2024-04-20T09:21:52Z")

</div>

Thanks, that is a great idea!

I am actually using a fork of your older Go version for the metrics: [GitHub - PierreZ/fdb-prometheus-exporter: A FoundationDB Prometheus metrics exporter](https://github.com/PierreZ/fdb-prometheus-exporter)

---

<div class="post-metadata">

**Author:** ![PierreZ](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/pierrez/32/866_2.png) [@PierreZ](https://forums.foundationdb.org/u/PierreZ)\
**Post date:** [April 20, 2024, 12:33pm UTC](https://forums.foundationdb.org/t/how-to-expose-a-metric-for-the-fdbmonitor-count-of-restarts/4445/4 "2024-04-20T12:33:26Z")

</div>

aha, I wrote this a looooong time ago, when I was discovering fdb. It is not really maintained anymore, whereas the CleverCloud one is used internally and maintained 🙂

---

<div class="post-metadata">

**Author:** ![newhook](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/newhook/32/1684_2.png) [@newhook](https://forums.foundationdb.org/u/newhook)\
**Post date:** [April 20, 2024, 4:33pm UTC](https://forums.foundationdb.org/t/how-to-expose-a-metric-for-the-fdbmonitor-count-of-restarts/4445/5 "2024-04-20T16:33:05Z")

</div>

> [@PierreZ](#):
>
> CleverCloud

This one? [GitHub - CleverCloud/foundationdb-exporter: A FoundationDB metrics Exporter with Prometheus compatibility](https://github.com/CleverCloud/foundationdb-exporter)

---

<div class="post-metadata">

**Author:** ![PierreZ](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/pierrez/32/866_2.png) [@PierreZ](https://forums.foundationdb.org/u/PierreZ)\
**Post date:** [April 22, 2024, 8:14am UTC](https://forums.foundationdb.org/t/how-to-expose-a-metric-for-the-fdbmonitor-count-of-restarts/4445/6 "2024-04-22T08:14:19Z")

</div>

Yes, maintained by @AlexandreBrg which has most(if not all) of the commits

---

<div class="post-metadata">

**Author:** ![gm42](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/gm42/32/1784_2.png) [@gm42](https://forums.foundationdb.org/u/gm42)\
**Post date:** [July 4, 2024, 7:37am UTC](https://forums.foundationdb.org/t/how-to-expose-a-metric-for-the-fdbmonitor-count-of-restarts/4445/7 "2024-07-04T07:37:32Z")

</div>

> [@PierreZ](#):
>
> `status json` is exporting the `uptime_seconds` per process. A reset in the counter means that fdbserver has been restarted

FYI, when there is a crash or termination (via SIGKILL) a new metric will be generated. In this case Prometheus will not count it as a reset.

---

<div class="post-metadata">

**Author:** ![ellacosta](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/ellacosta/32/1828_2.png) [@ellacosta](https://forums.foundationdb.org/u/ellacosta)\
**Post date:** [July 5, 2024, 4:53am UTC](https://forums.foundationdb.org/t/how-to-expose-a-metric-for-the-fdbmonitor-count-of-restarts/4445/8 "2024-07-05T04:53:09Z")

</div>

Hello,  
According me to count the number of restarts performed by fdbmonitor more efficiently than parsing its logged output, consider using the FoundationDB status API, which can fetch and monitor restart metrics directly, providing real-time data without log parsing. You can also use another option is to integrate fdbmonitor with external monitoring tools like Prometheus or Grafana, which can be configured to track restart events and display them on a dashboard for easier monitoring.

---

<div class="post-metadata">

**Author:** ![gm42](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/gm42/32/1784_2.png) [@gm42](https://forums.foundationdb.org/u/gm42)\
**Post date:** [July 5, 2024, 6:45am UTC](https://forums.foundationdb.org/t/how-to-expose-a-metric-for-the-fdbmonitor-count-of-restarts/4445/9 "2024-07-05T06:45:04Z")

</div>

> [@ellacosta](#):
>
> consider using the FoundationDB status API, which can fetch and monitor restart metrics directly

Which status API are you referring to? The JSON status? It does not contain a count of restarts; can you please provide an example of the information you are referring to?
