sqlqueryreceiver

package module
v0.158.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2026 License: Apache-2.0 Imports: 21 Imported by: 10

README

SQL Query Receiver

The SQL Query Receiver uses custom SQL queries to generate logs and/or metrics from a database connection.

Status
Stability development: logs
alpha: metrics
Distributions contrib
Issues Open issues Closed issues
Code coverage codecov
Code Owners @dmitryax, @crobert-1
Emeritus @pmcollins

🚧 This receiver is in ALPHA. Behavior, configuration fields, and log or metric data model are subject to change.

Configuration

Connection Configuration (choose one approach):

Option 1: Individual connection parameters (cannot be used when datasource is set):

  • host (required): The hostname or IP address of the database server.
    • For the sqlserver driver, an instance appended to the hostname (e.g. hostname1/instance1) will be parsed properly into this connection string: sqlserver://username:password@host:port/instance.
  • port (required, except optional for sqlserver): The port number of the database server.
  • database (required): The name of the database to connect to.
  • username (optional): The username for database authentication.
    • The username will be properly escaped and securely handled when building the connection string. Special characters (such as #, @, %, etc.) are automatically URL-encoded to ensure proper connection string formatting.
    • For mysql: No URL encoding is applied
  • password (optional): The password for database authentication. Supports environment variable substitution.
    • The password field supports sensitive value handling through environment variables or other secure value sources. Special characters (such as #, @, %, etc.) are automatically URL-encoded to ensure proper connection string formatting.
    • For mysql: No URL encoding is applied
  • additional_params (optional): Additional driver-specific connection parameters.

Option 2: Datasource string:

  • datasource (required): The datasource value passed to sql.Open. This value is used instead of the individual connection parameters listed above and does not perform any special character escaping. This is a driver-specific string usually consisting of at least a database name and connection information. This is sometimes referred to as the "connection string" in driver documentation. Examples:

    • clickhouse - clickhouse://username:userpassword@localhost:9000/default?dial_timeout=200ms&read_timeout=30s&max_execution_time=60
    • hdb - hdb://<USER>:<PASSWORD>@something.hanacloud.ondemand.com:443?TLSServerName=something.hanacloud.ondemand.com
    • mysql - username:user_password@tcp(localhost:3306)/db_name
    • oracle - oracle://username:user_password@localhost:1521/FREEPDB1
    • postgres - host=localhost port=5432 user=username password=user_password sslmode=disable
    • snowflake - username[:password]@<account_identifier>/dbname/schemaname[?param1=value&...&paramN=valueN]
    • sqlserver - sqlserver://username:user_password@localhost:1433?database=db_name
    • tds - tds://username:user_password@localhost:5000/db_name

Other configuration fields:

  • driver (required): The name of the database driver: one of postgres,