[PR #1465] WIP: add initial support for prometheus metrics. #3813

Open
opened 2026-03-14 07:40:17 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/amidaware/tacticalrmm/pull/1465
Author: @ykuksenko
Created: 3/29/2023
Status: 🔄 Open

Base: developHead: prom_metrics


📝 Commits (1)

  • 15c155b feat: add initial prometheus metrics support

📊 Changes

3 files changed (+309 additions, -48 deletions)

View changed files

📝 api/tacticalrmm/core/decorators.py (+25 -13)
📝 api/tacticalrmm/core/tests.py (+139 -0)
📝 api/tacticalrmm/core/views.py (+145 -35)

📄 Description

Could someone look over this and let me know if this okay for adding initial support for Prometheus metrics?

  1. At the moment this includes a minimal amount of metrics as examples. I may tweak the metric names a bit after I review the Prometheus metrics best practices document again.
  2. The endpoint /metrics is used as that is traditional for Prometheus environments. I can change it back to /core/metrics if required.
  3. Do I need to add any tests for this?
  4. I am not sure if @csrf_exempt is actually needed or wanted here; the monitoring endpoint made it seem so, to me.
  5. Is the for loop at the end okay or should I do this differently? (ie direct calls each time, or should it be a comprehension?)
  6. Is there are reason not to expose some of the version info? The reason it is there now is to track updates in my metrics environment. I think this may be useful if I find clients dropping off after an upgrade for example.
  7. Is there any other feedback?

Use instructions:

  1. Setup MON_TOKEN as in Tips and Tricks.
  2. Test with curl command curl -s -H "Authorization: Bearer $MON_TOKEN" https://api.trmm.example.com/metrics
  3. Setup Prometheus job with:
- job_name: trmm
  scrape_interval: 60s
  #metrics_path: /core/status/
  scheme: https
  bearer_token: $MON_TOKEN
  static_configs:
  - targets:
    - api.trmm.example.com

edit: updated instructions to share json status endpoint. instructions also in commit message now.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/amidaware/tacticalrmm/pull/1465 **Author:** [@ykuksenko](https://github.com/ykuksenko) **Created:** 3/29/2023 **Status:** 🔄 Open **Base:** `develop` ← **Head:** `prom_metrics` --- ### 📝 Commits (1) - [`15c155b`](https://github.com/amidaware/tacticalrmm/commit/15c155b1e5067d8b1ac878aab3afce159ef6c76c) feat: add initial prometheus metrics support ### 📊 Changes **3 files changed** (+309 additions, -48 deletions) <details> <summary>View changed files</summary> 📝 `api/tacticalrmm/core/decorators.py` (+25 -13) 📝 `api/tacticalrmm/core/tests.py` (+139 -0) 📝 `api/tacticalrmm/core/views.py` (+145 -35) </details> ### 📄 Description Could someone look over this and let me know if this okay for adding initial support for Prometheus metrics? 1. At the moment this includes a minimal amount of metrics as examples. I may tweak the metric names a bit after I review the Prometheus metrics best practices document again. 2. The endpoint `/metrics` is used as that is traditional for Prometheus environments. I can change it back to `/core/metrics` if required. 3. Do I need to add any tests for this? 4. I am not sure if `@csrf_exempt` is actually needed or wanted here; the monitoring endpoint made it seem so, to me. 5. Is the for loop at the end okay or should I do this differently? (ie direct calls each time, or should it be a comprehension?) 6. Is there are reason not to expose some of the version info? The reason it is there now is to track updates in my metrics environment. I think this may be useful if I find clients dropping off after an upgrade for example. 7. Is there any other feedback? --- Use instructions: 1. Setup `MON_TOKEN` as in [Tips and Tricks](https://docs.tacticalrmm.com/tipsntricks/#monitor-your-trmm-instance-via-the-built-in-monitoring-endpoint). 2. Test with curl command `curl -s -H "Authorization: Bearer $MON_TOKEN" https://api.trmm.example.com/metrics` 3. Setup Prometheus job with: ``` - job_name: trmm scrape_interval: 60s #metrics_path: /core/status/ scheme: https bearer_token: $MON_TOKEN static_configs: - targets: - api.trmm.example.com ``` edit: updated instructions to share json status endpoint. instructions also in commit message now. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tacticalrmm#3813
No description provided.