Skip to content

Conversation

@Fissium
Copy link
Contributor

@Fissium Fissium commented May 10, 2025

Add two new roles to deploy and configure Prometheus exporters:

@vitabaks
Copy link
Owner

vitabaks commented May 10, 2025

I myself prefer my version of pgwatch instead of the prometheus exporter, but maybe it will be useful to someone, thanks for the contribution.

I suggest moving the variables to main.yml under Netdata (monitoring section).

@vitabaks
Copy link
Owner

vitabaks commented May 10, 2025

It may be worth combining the tasks into one "prometeus" role.

@Fissium
Copy link
Contributor Author

Fissium commented May 10, 2025

Argee

@Fissium Fissium changed the title WIP: feat: add node_exporter and postgres_exporter roles WIP: feat: add prometheus role May 10, 2025
@Fissium
Copy link
Contributor Author

Fissium commented May 11, 2025

@vitabaks I’ve refactored the PR—could you take a look and let me know if everything’s good now?


######################################################################
# Copied from
# https://github.com/wrouesnel/postgres_exporter/blob/1afbd62ab194c045a88488d77de2f116400dedb7/queries.yaml
Copy link
Owner

Choose a reason for hiding this comment

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

It looks like the data state of this commit was 8 years ago. Perhaps newer metrics should be used?

Latest version 0.17.1 / 2025-02-26

Copy link
Owner

Choose a reason for hiding this comment

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

let's update this part, we would not like to add old versions of metrics.

Comment on lines +153 to +160
# node exporter
node_exporter_version: "1.9.1"
node_exporter_package_repo: "https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/node_exporter-{{ node_exporter_version }}.linux-{{ prometheus_architecture_map[ansible_architecture] }}.tar.gz"

# postgres exporter
postgres_exporter_version: "0.17.1"
postgres_exporter_package_repo: "https://github.com/prometheus-community/postgres_exporter/releases/download/v{{ postgres_exporter_version }}/postgres_exporter-{{ postgres_exporter_version }}.linux-{{ prometheus_architecture_map[ansible_architecture] }}.tar.gz"

Copy link
Owner

Choose a reason for hiding this comment

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

I think _version variables can be moved to main.yml, and _package_repo variables we can define them in the task (I don't think anyone will need to redefine this).

# More options you can specify in the roles/netdata/templates/netdata.conf.j2
# https://learn.netdata.cloud/docs/netdata-agent/configuration

### Metric ###
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
### Metric ###
### Prometheus ###

postgres_exporter_data_source_name: "user={{ postgres_exporter_user }} dbname={{ postgres_exporter_db }} host={{ postgresql_unix_socket_dir }} sslmode=disable"
postgres_exporter_query_filenames:
- queries-default.yml
# - queries-pg_stat_statements.yml
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
# - queries-pg_stat_statements.yml
- queries-pg_stat_statements.yml

I suggest setting pg_stat_statements by default

postgresql_extensions:
  - { ext: "pg_stat_statements", db: "postgres" }

Comment on lines +742 to +743
# - queries-pg_stat_statements.yml
# - queries-pg_statio_user_tables.yml
Copy link
Owner

Choose a reason for hiding this comment

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

why do we disable these metrics?

# {{ ansible_managed }}

# This requires the pg_stat_statements module (disabled by default)
# https://www.postgresql.org/docs/9.6/static/pgstatstatements.html
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
# https://www.postgresql.org/docs/9.6/static/pgstatstatements.html
# https://www.postgresql.org/docs/current/pgstatstatements.html

- role: netdata

- role: prometheus
when: with_metric_exporters | bool
Copy link
Owner

Choose a reason for hiding this comment

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

perhaps it is better to rename with_metric_exporters to prometheus_metrics or prometheus_exporters.

@vitabaks
Copy link
Owner

@Fissium Please note that refactoring has been performed #992 (for migration to the collection structure) and now all variables are in the roles/common/defaults/main.yml file.

@vitabaks vitabaks marked this pull request as draft June 30, 2025 15:50
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.

2 participants