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

SSL error even with sslmode=disable #1029

Closed
guenichone opened this issue May 7, 2024 · 2 comments
Closed

SSL error even with sslmode=disable #1029

guenichone opened this issue May 7, 2024 · 2 comments

Comments

@guenichone
Copy link

What did you do?

I run the command to use the exporter on my local postgres database.

What did you expect to see?

A successful connection when prometheus try to fetch the data using the scrapper configuration.

What did you see instead? Under which circumstances?

I'm getting an pq SSL error.

Environment

  • System information:

Darwin 23.4.0 arm64

  • postgres_exporter version:

postgres_exporter, version 0.15.0 (branch: HEAD, revision: 68c176b)
build user: root@7c5a76bc737a
build date: 20231027-14:38:04
go version: go1.21.3
platform: linux/arm64
tags: unknown

  • postgres_exporter flags:

No flags, just the existing command to run the docker image:

docker run
--net=host
-e DATA_SOURCE_NAME='postgresql://postgres:password@localhost:5432/testdb?sslmode=disable'
prometheuscommunity/postgres-exporter:v0.15.0

  • PostgreSQL version:

postgres (PostgreSQL) 13.2 (Debian 13.2-1.pgdg100+1)

  • Logs:
ts=2024-05-07T20:13:43.114Z caller=probe.go:41 level=info msg="no auth_module specified, using default"
ts=2024-05-07T20:13:43.114Z caller=server.go:74 level=info msg="Established new database connection" fingerprint=localhost:5432
ts=2024-05-07T20:13:43.118Z caller=probe.go:81 level=error target=localhost:5432 msg="Error opening connection to database" err="error querying postgresql version: pq: SSL is not enabled on the server"
ts=2024-05-07T20:13:44.121Z caller=postgres_exporter.go:682 level=error err="Error opening connection to database (postgresql://localhost:5432): pq: SSL is not enabled on the server"

Prometheus scrap config:

scrape_configs:
  - job_name: 'postgres'
    static_configs:
      - targets: ['localhost:5432']
    metrics_path: /probe
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: host.docker.internal:9187  # The postgres exporter's real hostname:port.
@ayush-rathore-quartic
Copy link

++
Same issue encountered when using v0.12.1-build-6.31.

@sysadmind
Copy link
Contributor

The scrape config you list is for the multi-target support as defined here: https://github.com/prometheus-community/postgres_exporter?tab=readme-ov-file#multi-target-support-beta
However, you don't define an auth module that would set the ssl configuration options. The environment variable DATA_SOURCE_NAME has no effect on the multi-target support.

You can:

  • Define and configure the auth module and continue using the mutlti-target endpoint
  • Change your prometheus configuration to not use the /probe endpoint (multi-target) and instead use the /metrics endpoint, removing the relabel_configs and just use the connection defined in the environment variable.

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

3 participants