Skip to content
This repository has been archived by the owner on Oct 20, 2020. It is now read-only.

Prometheus SQL Remote Storage Adapter for sqlite3/mysql

License

Notifications You must be signed in to change notification settings

ledyba/prometheus_sql_adapter

Repository files navigation

Prometheus SQL Remote Storage Adapter for sqlite/mysql

Build on Linux Build on macOS Build on Windows
Build single binary on Linux

Prometheus remote storage adapter, which stores timeseries data into RDBMS.

Currently, it suports only write operation.

Building and running

From gitpod

Gitpod ready-to-code

with Makefile

You need to install golang for building.

make

then run,

./prometheus_sql_adapter web \
    --listen '0.0.0.0:8080' \
 # to use sqlite,
    --db 'sqlite://file:/var/lib/sqlite/prometheus.db?cache=shared&mode=rwc'
#   --db 'sqlite://file::memory:?cache=shared' # use in-memory db(for debugging)
# to use mysql,
#   --db 'mysql://root:root@tcp(mysql-server-addr:3306)/db'

with Docker

Write a docker-compose.yml like:

---
version: '3.7'

services:
  prometheus_sql_adapter:
    container_name: prometheus_sql_adapter
    hostname: prometheus_sql_adapter
    image: prometheus_sql_adapter
    build:
      context: ./
    restart: always
    command:
      - 'web'
      - '--listen'
      - '0.0.0.0:8080'
      - '--db'
 # to use sqlite,
      - 'sqlite://file:/var/lib/sqlite/prometheus.db?cache=shared&mode=rwc'
#     - 'sqlite://file::memory:?cache=shared' # use in-memory db(for debugging)
# to use mysql,
#     - 'mysql://root:root@tcp(mysql-server-addr:3306)/db'

then,

docker-comopse build # It takes long time. Be patient....
docker-comopse up -d

Using from Prometheus

Write these line to /etc/prometheus/config.yml

remote_write:
  - url: 'http://<hostname>:8080/write'
remote_read:
  - url: 'http://<hostname>:8080/read'