Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add 'namespace' parameter to GCCollector and PlatformCollector#788

Closed
arthurlm wants to merge 1 commit intoprometheus:masterprometheus/client_python:masterfrom
arthurlm:masterarthurlm/client_python:masterCopy head branch name to clipboard
Closed

Add 'namespace' parameter to GCCollector and PlatformCollector#788
arthurlm wants to merge 1 commit intoprometheus:masterprometheus/client_python:masterfrom
arthurlm:masterarthurlm/client_python:masterCopy head branch name to clipboard

Conversation

@arthurlm
Copy link

This allow setting custom namespace when you need to export data using pushgateway.

Parameter was already there in ProcessCollector.

This allow setting custom namespace when you need to export data
using pushgateway.

Parameter was already there in ProcessCollector.

Signed-off-by: Arthur LE MOIGNE <arthur.lemoigne@gmail.com>
Copy link
Member

@csmarchbanks csmarchbanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR.

It is considered an anti-pattern to add a namespace in front of python for these metrics so I am hesitant to accept this pull request. It is best to differentiate the GC/python info using labels instead of adding a prefix so that you can compare across jobs, as well as avoid exploding the number of metric names loaded by typeahead in the Prometheus UI/Grafana.

The reason namespace is a parameter on the process collector is that it can be used to also collect information about other processes running on the host.

@arthurlm
Copy link
Author

arthurlm commented Apr 6, 2022

Thanks for your answer !
Actually, I have indeed fix the issue I was facing using dedicated labels.


The reason of this PR is that in my Prometheus there are thousands of different metrics.

There is few "system" processes running, which export standard metrics like python_... / java_... / go_... / kube_... / ...
A lot of "business" processes are running and exporting metrics like myapp1_... / myapp2_... / ...

In the case I was facing, a lot of distinct python application are running but there is no point to compare them together (since they are doing completely different things).

Prefixing python_ with myapp_ make sens to me in this case since:

  • myapp_ is the primary namespace
  • _python_ it the secondary namespace

As I said above, I have address this issue using labels (so now I am comparing python_...{app="myapp"}), but I have to filter unwanted system metrics not comming from myapp in all my PromQL queries / dashboard.

You are totally free to close or merge this PR 😀

  • in case it is close, other people will be able to find it and know why namespace is missing in GCCollector and PlatformCollector
  • in case you merge it, people will be able to create namespaced metrics for python info / GC

@csmarchbanks
Copy link
Member

Glad the dedicated labels are working for you, python_...{app="myapp"} is the recommended way to differentiate applications so I am going to close this. As you say, hopefully the reasonings and discussion will help others in the future.

@ChristianTackeGSI
Copy link

Well, I am using the textfile collector pattern (so my python apps write to a textfile for node exporter to scrape).

I first thought "okay, let's namespace / prefix" my daemons (like explained above). Okay, learned that this is not the recommended way. The way to go is using additional labels. Fine.

Now I need help: How to add those labels in my case?

  • node exporter can't do it. It only slurps the textfile.
  • I could create a dedicated tool that reads my textfile and creates a fixed up one. Workaround and not elegant.
  • So I should do it in my app
  • write_to_textfile has no options to add labels
  • The Registry neither
  • Both collectors miss this as well

Is there a recommended way to add labels to existing collectors when using the textfile collector pattern?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.