Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The feature Adding new metrics exists in README but not implemented #1069

Open
Sasasu opened this issue Sep 20, 2024 · 6 comments
Open

The feature Adding new metrics exists in README but not implemented #1069

Sasasu opened this issue Sep 20, 2024 · 6 comments

Comments

@Sasasu
Copy link

Sasasu commented Sep 20, 2024

What did you do?

Read the README about how to add a new metric.

What did you expect to see?

Find the method about how to add a new metric.

What did you see instead? Under which circumstances?

In the README:

### Adding new metrics
The exporter will attempt to dynamically export additional metrics if they are added in the
future, but they will be marked as "untyped". Additional metric maps can be easily created
from Postgres documentation by copying the tables and using the following Python snippet:

x = """tab separated raw text of a documentation table"""
for l in StringIO(x):
    column, ctype, description = l.split('\t')
    print """"{0}" : {{ prometheus.CounterValue, prometheus.NewDesc("pg_stat_database_{0}", "{2}", nil, nil) }}, """.format(column.strip(), ctype, description.strip())

Adjust the value of the resultant prometheus value type appropriately. This helps build
rich self-documenting metrics for the exporter.

And I cannot find any way to add this Python code. And checked the code, there is no there method to add new metric except Adding new metrics via a config file.

Check the commit, the document comes from the very early commit 2a08787#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R31 looks it means I need to create a new view in PostgreSQL using PL/Python, then add a new metric type in metricMaps and recompile postgres_exporter.

I think this is a document mistake.

@jamius19
Copy link

I also second this.
Adding new metrics via a config file is deprecated but there's no clear guideline as to how we can implement custom queries.

@fguiet
Copy link

fguiet commented Oct 25, 2024

I also third this :)
Since PG_EXPORTER_EXTEND_QUERY_PATH is deprecated how can we implement custom queries/metrics now?

Is the answer is :

Use this exporter For generic SQL database monitoring see the [sql_exporter](https://github.com/burningalchemist/sql_exporter)

@jamius19
Copy link

@fguiet I'm currently using this to good effect.
Vonng/pg_exporter

@fguiet
Copy link

fguiet commented Oct 26, 2024

Thank you @jamius19 , I will give it a try :)

@RSchindler93
Copy link

I am also looking for way to implement custom metrics since the old way was deprecated.
Will there be a replacement implementation with collectors of this feature or do I have to resort to using other collectors?
I try to maintain as few different deployments as possible, so a configurable Postgres exporter would be much better for us than another third party tool

@dgeissl
Copy link

dgeissl commented Feb 11, 2025

Any plans on providing custom metrics at all?

  • the only way to do it right now being documented as deprecated
  • the new metrics documentation is more of a hint for developers
  • users are pointed to another tool that basically does the same as this project, just with built in support for custom metrics

I don't like to say it but it seems like anyone with custom requirements is shied away from the project.

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

No branches or pull requests

5 participants