Giter Club home page Giter Club logo

rediseen's Introduction

Rediseen

"Latest Release" action travis codecov License Go Report Card Docker Pull

Start a REST-like API service for your Redis database, without writing a single line of code.

  • Allows clients to query records in Redis database via HTTP conveniently
  • Allows you to specify which logical DB(s) to expose, and what key patterns to expose
  • Expose results of Redis INFO command in a nice format, so you can use Rediseen as a connector between your Redis DB and monitoring dashboard as well.
  • Supports API Key authentication

(Inspired by sandman2; Built on shoulder of go-redis/redis ; CLI implemented with Cobra)

drawing

Quick Start

Let's assume that your Redis database URI is redis://:@localhost:6379, and you want to expose keys with prefix key: in logical database 0.

Quick Start with go get

If you have Go (1.11+) installed, you can install Rediseen easily by running

go get github.com/xd-deng/rediseen

If your GOPATH is added to PATH, you should be able to run command rediseen now.

# Configuration
export REDISEEN_REDIS_URI="redis://:@localhost:6379"
export REDISEEN_DB_EXPOSED=0
export REDISEEN_KEY_PATTERN_EXPOSED="^key:([0-9a-z]+)"

# Start the service
rediseen start

Now you should be able to query against your Redis database, like http://localhost:8000/0, http://localhost:8000/0/key:1, http://localhost:8000/info or http://localhost:8000/info/server (say you have keys key:1 (string) and key:2 (hash) set in your logical DB 0). Sample responses follow below.

GET /0

{
    "count": 2,
    "total": 2,
    "keys": [
        {
            "key": "key:1",
            "type": "string"
        },
        {
            "key": "key:2",
            "type": "hash"
        }
    ]
}
GET /0/key:1

{
    "type": "string",
    "value": "rediseen"
}
GET /info

{
    Server: {
        redis_version: "5.0.6",
        ...
    },
    Clients: {
        ...
    },
    ...
}
GET /info/server

{
    Server: {
        redis_version: "5.0.6",
        ...
    }
}

For more details, please refer to the rest of the documentation.

Quick Start with Homebrew

# Install using Homebrew
brew install XD-DENG/rediseen/rediseen

Then you can configure and start the service as described above.

Quick Start with Docker

docker run \
    -e REDISEEN_REDIS_URI="redis://:@[YOUR REDIS HOST]:6379" \
    -e REDISEEN_DB_EXPOSED=0 \
    -e REDISEEN_KEY_PATTERN_EXPOSED="^key:([0-9a-z]+)" \
    -p 8000:8000 \
    xddeng/rediseen:latest

Please note:

  • REDISEEN_REDIS_URI above should be a specific host address. If you are running Redis database using Docker too, you can consider using Docker's link or network feature to ensure connectivity between Rediseen and your Redis database (refer to the complete example below).
  • You can choose the image tag among:
    • latest (the latest release version)
    • nightly (the latest code in master branch)
    • unstable (latest dev branch)
    • release tags (like 2.2.0. Check Docker Hub/xddeng/rediseen for full list)

A complete example using Docker follows below

docker network create test-net

docker run -d --network=test-net --name=redis-server redis

docker run \
    -d --network=test-net \
    -e REDISEEN_REDIS_URI="redis://:@redis-server:6379" \
    -e REDISEEN_DB_EXPOSED=0 \
    -e REDISEEN_KEY_PATTERN_EXPOSED="^key:([0-9a-z]+)" \
    -p 8000:8000 \
    xddeng/rediseen:latest

curl -s http://localhost:8000/0

Result is like

{
  "count": 0,
  "total": 0,
  "keys": null
}

Then you can execute

docker exec -i redis-server redis-cli set key:0 100

curl -s http://localhost:8000/0

and you can expect output below

{
  "count": 1,
  "total": 1,
  "keys": [
    {
      "key": "key:0",
      "type": "string"
    }
  ]
}

Documentation

License

Apache-2.0

Reference

[1] https://swagger.io/docs/specification/authentication/api-keys/

[2] Prometheus Exposition Formats, https://prometheus.io/docs/instrumenting/exposition_formats/

rediseen's People

Contributors

xd-deng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rediseen's Issues

not getting any keys while using a compose file

when running the whole bundle :

version: '3.7'
services:
  rediseen:
    container_name: rediseen-test
    restart: always
    image: xddeng/rediseen:latest
    environment:
      - REDISEEN_REDIS_URI=redis://:@redis-volatile:6379
      - REDISEEN_DB_EXPOSED=0-5
      - REDISEEN_KEY_PATTERN_EXPOSED="^key:([0-9a-z]+)"
      - REDISEEN_HOST=0.0.0.0
    ports:
      - '8000:8000'
    networks:
      - 'default'

  redis-volatile:
    container_name: redis-volatile
    restart: always
    image: redis:6.2.1-buster
    environment:
      - REDIS_REPLICATION_MODE=master
    ports:
      - '6379:6379'
    networks:
      - 'default'

networks:
  default:
    name: rediseen-network

I am not able to get any key from the redisDB..any thoughts about that ?

$ curl -s http://localhost:8000/0 | jq 
{
  "count": 0,
  "total": 1,
  "keys": null
}
$ curl -s http://localhost:8000/0/0 | jq
{
  "error": "Key pattern is forbidden from access"
}

thanks in advance...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.