I created an account on grafana.com to check out the hosted Grafana.
I have added a connection to a server named “Linux”. Steps I did:
- Created a token with the name “test-token”
- The command with the token I was given after creating the token, I ran on my server, it installed alloy (I clicked on Test Alloy connection and this worked)
- I followed the instructions to add the required snippets to the configuration file (/etc/alloy/config.alloy)
- I pressed “Test connection” and this worked, so my server is connected
- I installed the dashboard
So far, everything is working as expected, BUT, …
I have a postgresql database running on my server and I want to monitor this. So I added a new connection named “PostgreSQL”. Steps I did:
- Grafana alloy was already running on my server so I did not create a new token or ran the jnstall command again
- I copied the given snippet to my /etc/alloy/config.alloy-file (NOTE: this already had a snippet for the linux connection)
- I created a non-superuser database user named “postgres_exporter” (with password “password”) and granted the necessary permissions (as stated here) (connect to database postgres and pg_monitor)
- I edited the snippet I pasted in the configuration-file, especially in the beginning:
prometheus.exporter.postgres "integrations_postgres_exporter" {
data_source_names = ["postgresql://postgres_exporter:password@localhost:5432/postgres?sslmode=disable"]
}
As you can see, I added the username and password to the snippet.
I have tested the user credentials. Through psql, I can login to the database with these credentials! (psql -U postgres_exporter postgres)
I have restarted alloy: sudo systemctl reload alloy
Now, when clicking “Test connection” on the setup page, I runs for like a minute and then gives me an error that the connection failed. I have set this up yesterday, today I tested it again but still no connection (and no data in my dashboard).
Do I have to open a port on my server for these data? Ports 22, 80, 443 and 9187 are open.
What could possibly be wrong?
Edit: to added, I checked the journald logs. No errors, no warnings, one notice (that alloy is running) and some info logs. When checking the ui (port 12345), I see the postgres_exporter listed and healthy.