Database

This page describes configuring the database connection for the Lenses Agent.

Once you have created a role for the agent to use you can then configure the Agent in the lenses.conf file:

lenses.conf
lenses.storage.postgres.host="my-postgres-server"
lenses.storage.postgres.port=5432
lenses.storage.postgres.username="lenses_agent"
lenses.storage.postgres.database="lenses_agent"
lenses.storage.postgres.password="changeme"

Additional configurations for the PostgreSQL database connection can be passed under the lenses.storage.postgres.properties configuration prefix.

One Postgres server can be used for all agents by using a separate database or schema each.

For the Agent see lenses.storage.postgres.schema or lenses.storage.postgres.database

The supported parameters can be found in the PostgreSQL documentation. For example:

lenses.conf
# require SSL encryption with full host verification
lenses.storage.postgres.properties.ssl=true
lenses.storage.postgres.properties.sslmode="verify-full"
lenses.storage.postgres.properties.sslcert="/path/to/certs/lenses.crt.pem"
lenses.storage.postgres.properties.sslkey="/path/to/certs/lenses.key.pk8"
lenses.storage.postgres.properties.sslpassword="mypassword"
lenses.storage.postgres.properties.sslrootcert="/path/to/certs/CA.crt.pem"

Database Role

terminal
# login as superuser and add Lenses role and database
psql -U postgres -d postgres <<EOF
CREATE ROLE lenses_agent WITH LOGIN PASSWORD 'changeme';
CREATE DATABASE lenses_agent OWNER lenses_agent;
EOF

Connection pooling

The Agent uses the HikariCP library for high-performance database connection pooling.

The default settings should perform well but can be overridden via the lenses.storage.hikaricp configuration prefix. The supported parameters can be found in the HikariCP documentation.

Camelcase configuration keys are not supported in agent configuration and should be translated to dot notation.

For example:

# set maximumPoolSize to 25
lenses.storage.hikaricp.maximum.pool.size=25

Last updated

Logo

2024 © Lenses.io Ltd. Apache, Apache Kafka, Kafka and associated open source project names are trademarks of the Apache Software Foundation.