diff --git a/acct-group/sql_exporter/metadata.xml b/acct-group/sql_exporter/metadata.xml
new file mode 100644
index 00000000..8bbd7586
--- /dev/null
+++ b/acct-group/sql_exporter/metadata.xml
@@ -0,0 +1,7 @@
+
+
+
+
+ ops@adjust.com
+
+
diff --git a/acct-group/sql_exporter/sql_exporter-0.ebuild b/acct-group/sql_exporter/sql_exporter-0.ebuild
new file mode 100644
index 00000000..ae90762e
--- /dev/null
+++ b/acct-group/sql_exporter/sql_exporter-0.ebuild
@@ -0,0 +1,8 @@
+# Copyright 2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit acct-group
+
+ACCT_GROUP_ID=-1
diff --git a/acct-user/sql_exporter/metadata.xml b/acct-user/sql_exporter/metadata.xml
new file mode 100644
index 00000000..8bbd7586
--- /dev/null
+++ b/acct-user/sql_exporter/metadata.xml
@@ -0,0 +1,7 @@
+
+
+
+
+ ops@adjust.com
+
+
diff --git a/acct-user/sql_exporter/sql_exporter-0.ebuild b/acct-user/sql_exporter/sql_exporter-0.ebuild
new file mode 100644
index 00000000..74f5b248
--- /dev/null
+++ b/acct-user/sql_exporter/sql_exporter-0.ebuild
@@ -0,0 +1,13 @@
+# Copyright 2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit acct-user
+
+DESCRIPTION="SQL Exporter for Prometheus"
+
+ACCT_USER_ID=-1
+ACCT_USER_GROUPS=( ${PN} )
+
+acct-user_add_deps
diff --git a/app-metrics/sql_exporter/Manifest b/app-metrics/sql_exporter/Manifest
new file mode 100644
index 00000000..1527b01b
--- /dev/null
+++ b/app-metrics/sql_exporter/Manifest
@@ -0,0 +1 @@
+DIST sql_exporter-0.5.3.tar.gz 11600200 BLAKE2B f249f54bae8c42984087f365530392d8dd3162a9314e4a58744de23463786833d452ed379b2f785871fbeca6c9feb312307d59f490677ce71df81b33c3f313f7 SHA512 e6f01bdd47e9cf43077662d42fb4500dc0dbfc2bd3462e8082595cfd810c104e6404334c272ecb3459dc604f85147089c88da73200b68543bc4473ab37c8c3e0
diff --git a/app-metrics/sql_exporter/files/sql_exporter.init.d b/app-metrics/sql_exporter/files/sql_exporter.init.d
new file mode 100644
index 00000000..a0ae4141
--- /dev/null
+++ b/app-metrics/sql_exporter/files/sql_exporter.init.d
@@ -0,0 +1,15 @@
+#!/sbin/openrc-run
+# Copyright 2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+name="sql_exporter daemon"
+description="SQL Exporter allows to run custom queries against a database"
+command="/usr/bin/sql_exporter"
+command_args="-config.file /etc/sql_exporter/sql_exporter.yml"
+output_log="/var/log/sql_exporter/sql_exporter.log"
+error_log="/var/log/sql_exporter/sql_exporter.log"
+start_stop_daemon_args="--background --user sql_exporter"
+
+depend() {
+ need net
+}
diff --git a/app-metrics/sql_exporter/files/sql_exporter.yml b/app-metrics/sql_exporter/files/sql_exporter.yml
new file mode 100644
index 00000000..f07ddce9
--- /dev/null
+++ b/app-metrics/sql_exporter/files/sql_exporter.yml
@@ -0,0 +1,47 @@
+---
+# jobs is a map of jobs, define any number but please keep the connection usage on the DBs in mind
+jobs:
+ # each job needs a unique name, it's used for logging and as an default label
+- name: "postgres"
+ # interval defined the pause between the runs of this job
+ interval: '1m'
+ # cron_schedule when to execute the job in the standard CRON syntax
+ # if specified, the interval is ignored
+ #cron_schedule: "0 0 * * *"
+ # connections is an array of connection URLs
+ # each query will be executed on each connection
+ connections:
+ - 'postgres://sql_exporter@/?host=/run/postgresql&dbname=postgres&sslmode=disable'
+ # startup_sql is an array of SQL statements
+ # each statements is executed once after connecting
+ startup_sql:
+ - 'SET lock_timeout = 1000'
+ - 'SET idle_in_transaction_session_timeout = 100'
+ # queries is a map of Metric/Query mappings
+ queries:
+ # name is prefied with sql_ and used as the metric name
+ - name: "running_queries"
+ # help is a requirement of the Prometheus default registry, currently not
+ # used by the Prometheus server. Important: Must be the same for all metrics
+ # with the same name!
+ help: "Number of running queries"
+ # Optional: Column to use as a metric timestamp source.
+ # Leave unset if it's not needed
+ timestamp: "created_at"
+ # Labels is an array of columns which will be used as additional labels.
+ # Must be the same for all metrics with the same name!
+ # All labels columns should be of type text, varchar or string
+ labels:
+ - "datname"
+ - "usename"
+ # Values is an array of columns used as metric values. All values should be
+ # of type float
+ values:
+ - "count"
+ # Query is the SQL query that is run unalterted on the each of the connections
+ # for this job
+ query: |
+ SELECT now() as created_at, datname::text, usename::text, COUNT(*)::float AS count
+ FROM pg_stat_activity GROUP BY created_at, datname, usename;
+ # Consider the query failed if it returns zero rows
+ allow_zero_rows: false
diff --git a/app-metrics/sql_exporter/metadata.xml b/app-metrics/sql_exporter/metadata.xml
new file mode 100644
index 00000000..8172f896
--- /dev/null
+++ b/app-metrics/sql_exporter/metadata.xml
@@ -0,0 +1,11 @@
+
+
+
+
+ ops@adjust.com
+ Adjust Ops
+
+
+ justwatchcom/sql_exporter
+
+
diff --git a/app-metrics/sql_exporter/sql_exporter-0.5.3.ebuild b/app-metrics/sql_exporter/sql_exporter-0.5.3.ebuild
new file mode 100644
index 00000000..f1bba514
--- /dev/null
+++ b/app-metrics/sql_exporter/sql_exporter-0.5.3.ebuild
@@ -0,0 +1,59 @@
+# Copyright 2024 @Leo
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+inherit golang-build golang-vcs-snapshot
+
+DESCRIPTION="Prometheus exporter for SQL database metrics."
+HOMEPAGE="https://github.com/justwatchcom/sql_exporter"
+SRC_URI="https://github.com/justwatchcom/sql_exporter/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~amd64"
+IUSE="doc"
+
+DEPEND="
+ dev-lang/go
+ acct-group/sql_exporter
+ acct-user/sql_exporter"
+
+RDEPEND="
+ ${DEPEND}"
+
+EGO_PN="github.com/justwatchcom/sql_exporter"
+
+src_prepare() {
+ default
+ cd "${S}"
+ export GO111MODULE=auto
+}
+
+src_compile() {
+ export GOPATH="${S}"
+ cd "${S}/src/${EGO_PN}"
+ echo "compiling from $(pwd)"
+ go build -o "${S}/bin/sql_exporter"
+}
+
+src_test() {
+ cd "${S}/src/${EGO_PN}"
+ go test -v ./...
+}
+
+src_install() {
+ dobin "${S}/bin/sql_exporter"
+ newinitd "${FILESDIR}/sql_exporter.init.d" sql_exporter
+ dosym /etc/init.d/sql_exporter /etc/runlevels/default/sql_exporter
+
+ insinto /etc/sql_exporter
+ doins "${FILESDIR}/sql_exporter.yml"
+
+ # Create log directory and file
+ dodir /var/log/sql_exporter
+ touch "${ED}"/var/log/sql_exporter/sql_exporter.log
+
+ # Change ownership of the log file to sql_exporter
+ chown sql_exporter:sql_exporter "${ED}"/var/log/sql_exporter/sql_exporter.log
+}