Skip to content

Comments

docs: Fix PostgreSQL DSN example [skip ci]#434

Merged
burningalchemist merged 1 commit intoburningalchemist:masterfrom
rc5hack:patch-1
Jan 29, 2024
Merged

docs: Fix PostgreSQL DSN example [skip ci]#434
burningalchemist merged 1 commit intoburningalchemist:masterfrom
rc5hack:patch-1

Conversation

@rc5hack
Copy link
Contributor

@rc5hack rc5hack commented Jan 29, 2024

Fix DSN example for PostgreSQL db in Readme + fix yaml indentation (2 spaces per level).

Copy link
Owner

@burningalchemist burningalchemist left a comment

Choose a reason for hiding this comment

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

Good catch, thank you! 👍

@burningalchemist burningalchemist changed the title Fix PostgreSQL DSN example docs: Fix PostgreSQL DSN example Jan 29, 2024
@burningalchemist burningalchemist changed the title docs: Fix PostgreSQL DSN example docs: Fix PostgreSQL DSN example [skip ci] Jan 29, 2024
@burningalchemist burningalchemist merged commit 79575c8 into burningalchemist:master Jan 29, 2024
@burningalchemist
Copy link
Owner

burningalchemist commented Jan 29, 2024

@rc5hack Hold on, it's actually incorrect. targets is a map. In your change indentation broke inheritance and turned named targets into the array items.

What was the original problem with the example?

I'll revert it for now.

@rc5hack
Copy link
Contributor Author

rc5hack commented Jan 29, 2024

My fault. Indentation inside of targets: (4 spaces) was correct (2 spaces per level, 2 levels), but between static_configs: and targets: it is redundant (4 spaces, while only 2 needed). It would work as is, but better to be reduced.

This works for me:

jobs:
  - job_name: db_targets
    collectors: [dummy]
    enable_ping: true
    static_configs:
      - targets:
          db-foo: 'postgresql://user:passw0rd@hostname:5432/dummy?sslmode=disable'
          db-bar: 'postgresql://user:passw0rd@other-host:5432/dummy?sslmode=disable'

Original problem is that pg://db1@127.0.0.1:25432/postgres?sslmode=disable DSN has db1 as user and no password, which is uncommon/frustrating, and also uses pg:// scheme instead of postgres://, which is also unusual (but, TIL, is compatible).

@burningalchemist
Copy link
Owner

Yeah, it works fine since we use dburl dependency, which helps picking the right driver for the chosen protocol - https://github.com/xo/dburl. And there are multiple drivers available for Postgres. Have a look whenever you have some free time. 🙂👍

Other than that, no objections. Do you mind creating one more PR? 🙂

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