prometheus / prometheus/client_python

Aggregate expired pid db files, control the number of files and improve scrape effectiveness

Offen
#443 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Python
Sterne
4.4k
Forks
876
Ø Merge
8 T. 4 Std.
Gemergte PRs (30 T.)
1

Beschreibung

history related issues: https://github.com/prometheus/client_python/pull/441
https://github.com/prometheus/client_python/pull/430

Can we aggregate all the db files from a period of time ago and non-current pid into a total db file, to control the number of pid files ?

I have realized this idea with golang,here are some details:

Project deploy info:
gunicorn django
128 workers
gunicorn max_requests:10000(create a new pid file almost every minute)

  1. I can't solve the problem that the pid file has been growing, and it can reach 6,000 in four days;
  2. Try to delete the expired pid regularly in the code, but it will cause the figure to drop with grafana;
  3. The time to request metric is getting longer as the program runs.

Improve scrape efficiency:
I used golang to rewrite the logic of python aggregate metrics(generate metric still using python). After rewriting, each scrape time is less than 1 second.

Solve the growing pid files:
Aggregate all the db files from a period of time ago and non-current pid into a total db file. Then delete these files. When calculating metric, history total db + curent pid = current pid db. (i do it every hour)

Now, num of pid files is <200 in my project. if we can do change this, it would be a big strengthen. Just like prometheus will also aggregate historical data

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie mit der Durchsicht der historienbezogenen Pull Requests #441 und #430 und verfolgen Sie anschließend das für die 128-Worker-Gunicorn-Bereitstellung beschriebene Python-Aggregations- und Scrape-Verhalten. Vergleichen Sie den vorgeschlagenen Ansatz zur regelmäßigen Aggregation und Löschung mit den aktuellen Metrikergebnissen in Grafana; abgeschlossen ist die Arbeit, wenn die pid-Datenbankdateien eine begrenzte Größe haben, historische Werte erhalten bleiben und die Scrape-Zeit unter einer Sekunde liegt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
django, go, grafana, prometheus, python
Bereich
backend, observability, performance
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.