All Projects → minio → Minsql

minio / Minsql

Licence: agpl-3.0
High-performance log search engine.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Minsql

Manticoresearch
Database for search
Stars: ✭ 610 (+71.35%)
Mutual labels:  search, sql, search-engine
Searchcode Server
The offical home of searchcode-server where you can run searchcode locally. Note that master is generally unstable in the sense that it is not a release. Check releases for release versions https://github.com/boyter/searchcode-server/releases
Stars: ✭ 262 (-26.4%)
Mutual labels:  search, search-engine
Roapi
Create full-fledged APIs for static datasets without writing a single line of code.
Stars: ✭ 253 (-28.93%)
Mutual labels:  sql, analytics
Trino
Official repository of Trino, the distributed SQL query engine for big data, formerly known as PrestoSQL (https://trino.io)
Stars: ✭ 4,581 (+1186.8%)
Mutual labels:  sql, analytics
open-semantic-desktop-search
Virtual Machine for Desktop Search with Open Semantic Search
Stars: ✭ 22 (-93.82%)
Mutual labels:  search-engine, analytics
indieweb-search
Source code for the IndieWeb search engine.
Stars: ✭ 16 (-95.51%)
Mutual labels:  search, search-engine
Go Cyber
Your 🔵 Superintelligence
Stars: ✭ 270 (-24.16%)
Mutual labels:  search, search-engine
Vectorai
Vector AI — A platform for building vector based applications. Encode, query and analyse data using vectors.
Stars: ✭ 195 (-45.22%)
Mutual labels:  search, search-engine
Toshi
A full-text search engine in rust
Stars: ✭ 3,373 (+847.47%)
Mutual labels:  search, search-engine
Concourse
Distributed database warehouse for transactions, search and analytics across time.
Stars: ✭ 310 (-12.92%)
Mutual labels:  search, analytics
Alfred Npms
Alfred 3 workflow to search for npm packages with npms.io
Stars: ✭ 312 (-12.36%)
Mutual labels:  search, search-engine
Search Engine Parser
Lightweight package to query popular search engines and scrape for result titles, links and descriptions
Stars: ✭ 216 (-39.33%)
Mutual labels:  search, search-engine
Scout
RESTful search server written in Python, powered by SQLite.
Stars: ✭ 213 (-40.17%)
Mutual labels:  search, search-engine
Darksearch
🔍 Search engine for hidden material. Scraping dark web onions, irc logs, deep web etc...
Stars: ✭ 260 (-26.97%)
Mutual labels:  search, search-engine
Tntsearch
A fully featured full text search engine written in PHP
Stars: ✭ 2,693 (+656.46%)
Mutual labels:  search, search-engine
Redisearch
A query and indexing engine for Redis, providing secondary indexing, full-text search, and aggregations.
Stars: ✭ 3,393 (+853.09%)
Mutual labels:  search, search-engine
Hexo Generator Search
A plugin to generate search data for Hexo.
Stars: ✭ 318 (-10.67%)
Mutual labels:  search, search-engine
Rusticsearch
Lightweight Elasticsearch compatible search server.
Stars: ✭ 171 (-51.97%)
Mutual labels:  search, search-engine
Lolcate Rs
Lolcate -- A comically fast way of indexing and querying your filesystem. Replaces locate / mlocate / updatedb. Written in Rust.
Stars: ✭ 191 (-46.35%)
Mutual labels:  search, search-engine
Crate
CrateDB is a distributed SQL database that makes it simple to store and analyze massive amounts of data in real-time.
Stars: ✭ 3,254 (+814.04%)
Mutual labels:  sql, analytics

NOTE: This project is under development, please do not depend on it yet as things may break.

MinSQL

MinSQL is a log search engine designed with simplicity in mind to the extent that no SDK is needed to interact with it, most programming languages and tools have some form of http request capability (ie: curl) and that's all you need to interact with MinSQL.

To build

docker build . -t minio/minsql
docker run --rm minio/minsql --help

OR

make
./minsql --help

Running the project

An instance of MinIO is needed as the storage engine for MinSQL. To keep things easier we have a docker-compose example for MinIO and MinSQL.

To run the project you need to provide the access details for a Meta Bucket to store the shared configuration between multiple MinSQL instances, the location and access to it should be configured via environment variables when starting MinSQL .

Binary:
export MINSQL_METABUCKET_NAME=minsql-meta
export MINSQL_METABUCKET_ENDPOINT=http://localhost:9000
export MINSQL_METABUCKET_ACCESS_KEY=minio
export MINSQL_METABUCKET_SECRET_KEY=minio123
export MINSQL_ROOT_ACCESS_KEY=minsqlaccesskeyx
export MINSQL_ROOT_SECRET_KEY=minsqlsecretkeypleasechangexxxx
./minsql

Then go to http://127.0.0.1:9999/ui/ and login with the provided MINSQL_ROOT_ACCESS_KEY and MINSQL_ROOT_SECRET_KEY.

Docker

Create the compose file

cat > docker-compose.yml <<EOF
version: '2'

services:
 minio-engine:
  image: minio/minio
  volumes:
   - data:/data
  environment:
   MINIO_ACCESS_KEY: minio
   MINIO_SECRET_KEY: minio123
  command: server /data
 mc:
  image: minio/mc
  depends_on:
   - minio
  entrypoint: >
    /bin/sh -c "
    echo /usr/bin/mc config host a http://minio-engine:9000 minio minio123;
    /usr/bin/mc mb a/minsql-meta;
    "
 minsql:
  image: minio/minsql
  depends_on:
   - minio
   - mc
  ports:
   - "9999:9999"
  environment:
   MINSQL_METABUCKET_NAME: minsql-meta
   MINSQL_METABUCKET_ENDPOINT: http://minio-engine:9000
   MINSQL_ACCESS_KEY: minio
   MINSQL_SECRET_KEY: minio123
   MINSQL_ROOT_ACCESS_KEY: minsqlaccesskeyx
   MINSQL_ROOT_SECRET_KEY: minsqlsecretkeypleasechangexxxx

volumes:
  data:
EOF
docker-compose up

Environment variables

Environment Description
MINSQL_METABUCKET_NAME Name of the meta bucket
MINSQL_METABUCKET_ENDPOINT Name of the endpoint, ex: http://localhost:9000
MINSQL_METABUCKET_ACCESS_KEY Meta Bucket Access key
MINSQL_METABUCKET_SECRET_KEY Meta Bucket Secret key
MINSQL_PKCS12_CERT Optional: location to a pkcs12 certificate.
MINSQL_PKCS12_PASSWORD Optional: password to unlock the certificate.
MINSQL_ROOT_ACCESS_KEY Optional: 16 digit access key to bootstrap minsql
MINSQL_ROOT_SECRET_KEY Optional: 32 digit secret key to bootstrap minsql

Configuring

To start storing logs you need to setup a DataStore, Log, Token and a Authorization on MinSQL, this can be done using the admin REST APIs.

To get our sample code going we are going to:

  1. minioplay datastore
  2. mylog log
  3. a token
  4. authorize the token to our log

Add a sample datastore

Our sample datastore will be pointing to play, a demo instance of MinIO.

curl -X POST \
  http://127.0.0.1:9999/api/datastores \
  -H 'Content-Type: application/json' \
  -d '{
  "bucket" : "play-minsql",
  "endpoint" : "https://play.minio.io:9000",
  "prefix" : "",
  "name" : "minioplay",
  "access_key" : "Q3AM3UQ867SPQQA43P2F",
  "secret_key" : "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
}'

Add a Sample log

We are going to add a log mylog that stores it's contents on the minioplay datastore.

curl -X POST \
  http://127.0.0.1:9999/api/logs \
  -H 'Content-Type: application/json' \
  -d '{
  "name" : "mylog",
  "datastores" : [
    "minioplay",
  ],
  "commit_window" : "5s"
}'

Create a sample token

We are going to generate a token with a hardcoded token abcdefghijklmnopabcdefghijklmnopabcdefghijklmnop

curl -X POST \
  http://127.0.0.1:9999/api/tokens \
  -H 'Content-Type: application/json' \
  -d '{
  "access_key" : "abcdefghijklmnop",
  "secret_key" : "abcdefghijklmnopabcdefghijklmnop",
  "description" : "test",
  "is_admin" : true,
  "enabled" : false
}'

Authorize token to log

Finally, we are going to authorize our new token to access mylog

curl -X POST \
  http://127.0.0.1:9999/api/auth/abcdefghijklmnop \
  -H 'Content-Type: application/json' \
  -d '{
  "log_name" : "mylog",
  "api" : ["search","store"]
}'

Storing logs

For a log mylog defined on the configuration we can store logs on MinSQL by performing a PUT to your MinSQL instance

curl -X PUT \
  http://127.0.0.1:9999/mylog/store \
  -H 'MINSQL-TOKEN: TOKEN1' \
  -d '10.8.0.1 - - [16/May/2019:23:02:56 +0000] "GET / HTTP/1.1" 400 256 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0"'

You can send multiple log lines separated by new line

Querying logs

To get data out of MinSQL you can use SQL. Note that MinSQL is a data layer and not a computation layer, therefore certain SQL statements that need computations (SUM, MAX, GROUP BY, JOIN, etc...) are not supported.

All the query statements must be sent via POST to your MinSQL instance.

SELECT

To select all the logs for a particular log you can perform a simple SELECT statement

SELECT * FROM mylog

And send that to MinSQL via POST

curl -X POST \
  http://127.0.0.1:9999/search \
  -H 'MINSQL-TOKEN: TOKEN1' \
  -d 'SELECT * FROM mylog'

This will return you all the raw log lines stored for that log.

67.164.164.165 - - [24/Jul/2017:00:16:46 +0000] "GET /info.php HTTP/1.1" 200 24564 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"
67.164.164.165 - - [24/Jul/2017:00:16:48 +0000] "GET /favicon.ico HTTP/1.1" 404 209 "http://104.236.9.232/info.php" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"
24.26.204.22 - - [24/Jul/2017:00:17:16 +0000] "GET /info.php HTTP/1.1" 200 24579 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"
45.23.126.92 - - [24/Jul/2017:00:16:18 +0000] "GET /info.php HTTP/1.1" 200 24589 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"

Select parts of the data

We can get only parts of the data by using any of the supported MinSQL entities, which start with a $ sign.

Positional

We can select from the data by its position, for example to get the first column and the fourth we can use $1 and $4

SELECT $1, $4 FROM mylog;

To which MinSQL will reply

67.164.164.165 [24/Jul/2017:00:16:46
67.164.164.165 [24/Jul/2017:00:16:48
24.26.204.22 [24/Jul/2017:00:17:16
45.23.126.92 [24/Jul/2017:00:16:18

You can see that the data was selected as is, however the selected date column is not clean enough, MinSQL provides other entities to deal with this.

By Type

MinSQL provides a nice list of entities that make the extraction of data chunks from your raw data easy thanks to our powerful Schema on Read approach. For example we can select any ip in our data by using the entity $ip and any date using $date.

SELECT $ip, $date FROM mylog

To which MinSQL will reply

67.164.164.165 24/Jul/2017
67.164.164.165 24/Jul/2017
24.26.204.22 24/Jul/2017
45.23.126.92 24/Jul/2017

If your data contains more than one ip address you can access the subsequent ip's using positional entities.

SELECT $ip, $ip2, $ip3, $date FROM mylog

Please note that if no positional number is specified on an entity, it will default to the first position, in this case $ip == $ip1

Filtering

Using the powerful select engine of MinSQL you can also filter the data so only the relevant information that you need to extract from your logs is returned.

For example, to filter out a single ip from your logs you could select by $ip

SELECT * FROM mylog WHERE $ip = '67.164.164.165'

To which MinSQL will reply only with the matched lines

67.164.164.165 - - [24/Jul/2017:00:16:46 +0000] "GET /info.php HTTP/1.1" 200 24564 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"
67.164.164.165 - - [24/Jul/2017:00:16:48 +0000] "GET /favicon.ico HTTP/1.1" 404 209 "http://104.236.9.232/info.php" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"

By value

You can select log lines that contain a value by using the LIKE operator or NOT NULL for any entity.

SELECT * FROM mylog WHERE $line LIKE 'Intel' AND $email IS NOT NULL

This query would return all the log lines conaining the word Intel that also contain an email address.

Entities

A list of supported entities by MinSQL :

  • $line: Represents the whole log line
  • $ip: Selects any format of ipv4
  • $date: Any format of date containing date, month and year.
  • $email: Any [email protected]
  • $quoted: any text that is within single quotes (') or double quotes (")
  • $url: any url starting with http
  • $phone: any valid 10 digit phone.
  • $user_agent: A quoted user agent found in the logs
    • $user_agent.name: Browser name
    • $user_agent.category: type of machine (pc, mac)
    • $user_agent.os: Operative System name
    • $user_agent.os_version: Operative System version
    • $user_agent.browser_type: Type of browser
    • $user_agent.version: version of browser
    • $user_agent.vendor: browser vendor
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].