Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ permissions:
id-token: write

jobs:
release:
release-sql-to-logsql:
runs-on: ubuntu-latest
steps:

Expand Down Expand Up @@ -90,3 +90,50 @@ jobs:
args: release --clean --verbose --timeout 60m -f .goreleaser.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

release-logsql-jdbc:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: '0'
fetch-tags: 'true'

- name: Install JDK and Maven
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'
cache: 'maven'

- name: Fetch tags
run: |
if [[ "${{ github.ref_type }}" != "tag" ]]; then
git fetch --tags
else
echo "Skipping tag fetch - already on tag ${{ github.ref_name }}"
fi

- name: Update Configuration
working-directory: logsql-jdbc
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
TAG_VERSION=$(echo "${{ github.ref_name }}" | sed 's/^v//')
else
LATEST_TAG=$(git tag --sort=-version:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$' | head -n 1)
[ -z "$LATEST_TAG" ] && { echo "No release tag found"; exit 1; }
TAG_VERSION=$(echo "$LATEST_TAG" | sed 's/^v//')
echo "Using latest tag: $LATEST_TAG"
fi
mvn versions:set versions:commit -DnewVersion="${TAG_VERSION}";

- name: Publish package
working-directory: logsql-jdbc
run: |
mvn -s ${{ github.workspace }}/.github/workflows/settings.xml -DskipTests --batch-mode deploy
rm -rf */target/logsql-jdbc-*.jar
env:
USERNAME: ${{ secrets.USERNAME }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30 changes: 30 additions & 0 deletions .github/workflows/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>

<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/victoriametrics/sql-to-logsql</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>

<servers>
<server>
<id>github</id>
<username>${env.USERNAME}</username>
<password>${env.GITHUB_TOKEN}</password>
</server>
</servers>
</settings>
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ dist-ssr
*.njsproj
*.sln
*.sw?
/sql-to-logsql
/sql-to-logsql
/logsql-jdbc/target/
6 changes: 0 additions & 6 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
version: 2
project_name: sql-to-logsql

#before:
# hooks:
# - make ui-build

builds:
- env:
- CGO_ENABLED=0
Expand All @@ -17,8 +13,6 @@ builds:
- arm64
- arm
- "386"
# hooks:
# pre: make ui-build
main: ./cmd/sql-to-logsql/main.go
binary: sql-to-logsql
ldflags:
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
UI_DIR=cmd/sql-to-logsql/web/ui

.PHONY: ui-install ui-build build backend-build run test
.PHONY: ui-install ui-build build backend-build run test all jdbc-build jdbc-test

ui-install:
cd $(UI_DIR) && npm install
Expand All @@ -26,3 +26,9 @@ lint:
bash ./scripts/lint-all.sh

all: test check lint build

jdbc-build:
bash ./scripts/jdbc-build.sh

jdbc-test:
bash ./scripts/jdbc-build.sh
50 changes: 50 additions & 0 deletions logsql-jdbc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# LogSQL JDBC Driver

This module provides a JDBC 4.0 compatible driver for the VictoriaLogs (via `sql-to-logsql` service).
The driver interacts http(s) with sql-to-logsql API and exposes query results as regular JDBC result sets,
making it possible to integrate VictoriaLogs with the broader JVM ecosystem (BI tools, JDBC-based frameworks, etc.).

## Connection URL

```
jdbc:logsql://host[:port][/basePath]?property=value&...
```

Supported properties:

- `scheme` – `http` (default) or `https`.
- `endpoint` – optional VictoriaLogs endpoint URL override.
- `bearerToken` – optional bearer token sent to the translation service.
- `timeout` – request timeout in milliseconds (default 60000).
- `verify` – when `false`, TLS certificate validation is disabled.
- `header.<name>` – additional HTTP headers to include with every request.

Example:

```
jdbc:logsql://localhost:8080?scheme=https&endpoint=https%3A%2F%2Fvictorialogs.example.com&bearerToken=secret
```

Properties provided through `java.util.Properties` when creating the connection are merged with the URL query parameters (query parameters take precedence).

## Building

```
mvn -DskipTests package
```

The standard artifact is placed in `target/logsql-jdbc-<version>.jar`, and a fat jar with all dependencies is available as `target/logsql-jdbc-<version>-all.jar`.

## Testing

```
mvn test
```

These integration tests connect to https://play-sql.victoriametrics.com. They will be marked as skipped automatically if the playground cannot be reached (for example, when outbound network access is disabled).

## Notes

- The driver performs a health check against `/healthz` when establishing a connection.
- Result sets are fully buffered in memory to simplify cursor navigation and metadata reporting. Avoid query patterns that return unbounded result sets.
- HTTPS certificate verification can be disabled for testing by setting `verify=false`, but this is not recommended for production use.
150 changes: 150 additions & 0 deletions logsql-jdbc/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.victoriametrics</groupId>
<artifactId>logsql-jdbc</artifactId>
<version>0.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>LogsQL JDBC Driver</name>
<description>JDBC driver for VictoriaLogs (via sql-to-logsql service)</description>
<url>https://github.com/VictoriaMetrics/sql-to-logsql/tree/main/logsql-jdbc</url>

<organization>
<name>VictoriaMetrics Inc.</name>
<url>https://victoriametrics.com/</url>
</organization>

<licenses>
<license>
<name>Apache License 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>

<developers>
<developer>
<name>VictoriaMetrics</name>
<url>https://victoriametrics.com</url>
</developer>
</developers>

<issueManagement>
<system>Github</system>
<url>https://github.com/VictoriaMetrics/sql-to-logsql/issues</url>
</issueManagement>

<ciManagement>
<system>Github</system>
<url>https://github.com/VictoriaMetrics/sql-to-logsql/actions</url>
</ciManagement>

<distributionManagement>
<repository>
<id>github</id>
<name>GitHub VictoriaMetrics Apache Maven Packages</name>
<url>https://maven.pkg.github.com/VictoriaMetrics/sql-to-logsql</url>
</repository>
</distributionManagement>

<properties>
<spec.title>JDBC</spec.title>
<spec.version>4.2</spec.version>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jackson.version>2.17.2</jackson.version>
<junit.jupiter.version>5.10.2</junit.jupiter.version>
</properties>

<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>com.victoriametrics.logsql.jdbc</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>all</shadedClassifierName>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Automatic-Module-Name>com.victoriametrics.logsql.jdbc</Automatic-Module-Name>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
<configuration>
<useModulePath>false</useModulePath>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading