blazer
This commit is contained in:
parent
f643434918
commit
4677f90bb2
6 changed files with 196 additions and 1 deletions
2
Gemfile
2
Gemfile
|
@ -3,6 +3,8 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
||||||
|
|
||||||
ruby '2.7.3'
|
ruby '2.7.3'
|
||||||
|
|
||||||
|
# Blazer: 'blazer', github: https://github.com/ankane/blazer
|
||||||
|
gem 'blazer'
|
||||||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
|
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
|
||||||
gem 'rails', '~> 6.1.4'
|
gem 'rails', '~> 6.1.4'
|
||||||
# Use postgresql as the database for Active Record
|
# Use postgresql as the database for Active Record
|
||||||
|
|
10
Gemfile.lock
10
Gemfile.lock
|
@ -65,6 +65,11 @@ GEM
|
||||||
ast (2.4.2)
|
ast (2.4.2)
|
||||||
bcrypt (3.1.16-x86_64-linux-musl)
|
bcrypt (3.1.16-x86_64-linux-musl)
|
||||||
bindex (0.8.1-x86_64-linux-musl)
|
bindex (0.8.1-x86_64-linux-musl)
|
||||||
|
blazer (2.4.2)
|
||||||
|
activerecord (>= 5)
|
||||||
|
chartkick (>= 3.2)
|
||||||
|
railties (>= 5)
|
||||||
|
safely_block (>= 0.1.1)
|
||||||
bootsnap (1.7.5-x86_64-linux-musl)
|
bootsnap (1.7.5-x86_64-linux-musl)
|
||||||
msgpack (~> 1.0)
|
msgpack (~> 1.0)
|
||||||
brakeman (5.0.4)
|
brakeman (5.0.4)
|
||||||
|
@ -78,6 +83,7 @@ GEM
|
||||||
rack-test (>= 0.6.3)
|
rack-test (>= 0.6.3)
|
||||||
regexp_parser (>= 1.5, < 3.0)
|
regexp_parser (>= 1.5, < 3.0)
|
||||||
xpath (~> 3.2)
|
xpath (~> 3.2)
|
||||||
|
chartkick (4.0.3)
|
||||||
childprocess (3.0.0)
|
childprocess (3.0.0)
|
||||||
concurrent-ruby (1.1.9)
|
concurrent-ruby (1.1.9)
|
||||||
crass (1.0.6)
|
crass (1.0.6)
|
||||||
|
@ -89,6 +95,7 @@ GEM
|
||||||
warden (~> 1.2.3)
|
warden (~> 1.2.3)
|
||||||
devise-i18n (1.10.0)
|
devise-i18n (1.10.0)
|
||||||
devise (>= 4.8.0)
|
devise (>= 4.8.0)
|
||||||
|
errbase (0.2.1)
|
||||||
erubi (1.10.0)
|
erubi (1.10.0)
|
||||||
ffi (1.15.3-x86_64-linux-musl)
|
ffi (1.15.3-x86_64-linux-musl)
|
||||||
globalid (0.4.2)
|
globalid (0.4.2)
|
||||||
|
@ -178,6 +185,8 @@ GEM
|
||||||
parser (>= 3.0.1.1)
|
parser (>= 3.0.1.1)
|
||||||
ruby-progressbar (1.11.0)
|
ruby-progressbar (1.11.0)
|
||||||
rubyzip (2.3.2)
|
rubyzip (2.3.2)
|
||||||
|
safely_block (0.3.0)
|
||||||
|
errbase (>= 0.1.1)
|
||||||
sass-rails (6.0.0)
|
sass-rails (6.0.0)
|
||||||
sassc-rails (~> 2.1, >= 2.1.1)
|
sassc-rails (~> 2.1, >= 2.1.1)
|
||||||
sassc (2.4.0-x86_64-linux-musl)
|
sassc (2.4.0-x86_64-linux-musl)
|
||||||
|
@ -235,6 +244,7 @@ PLATFORMS
|
||||||
x86_64-linux-musl
|
x86_64-linux-musl
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
|
blazer
|
||||||
bootsnap (>= 1.4.4)
|
bootsnap (>= 1.4.4)
|
||||||
brakeman
|
brakeman
|
||||||
byebug
|
byebug
|
||||||
|
|
79
config/blazer.yml
Normal file
79
config/blazer.yml
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
# see https://github.com/ankane/blazer for more info
|
||||||
|
|
||||||
|
data_sources:
|
||||||
|
main:
|
||||||
|
url: <%= ENV["BLAZER_DATABASE_URL"] %>
|
||||||
|
|
||||||
|
# statement timeout, in seconds
|
||||||
|
# none by default
|
||||||
|
# timeout: 15
|
||||||
|
|
||||||
|
# caching settings
|
||||||
|
# can greatly improve speed
|
||||||
|
# off by default
|
||||||
|
# cache:
|
||||||
|
# mode: slow # or all
|
||||||
|
# expires_in: 60 # min
|
||||||
|
# slow_threshold: 15 # sec, only used in slow mode
|
||||||
|
|
||||||
|
# wrap queries in a transaction for safety
|
||||||
|
# not necessary if you use a read-only user
|
||||||
|
# true by default
|
||||||
|
use_transaction: true
|
||||||
|
|
||||||
|
smart_variables:
|
||||||
|
# zone_id: "SELECT id, name FROM zones ORDER BY name ASC"
|
||||||
|
# period: ["day", "week", "month"]
|
||||||
|
# status: {0: "Active", 1: "Archived"}
|
||||||
|
|
||||||
|
linked_columns:
|
||||||
|
# user_id: "/admin/users/{value}"
|
||||||
|
|
||||||
|
smart_columns:
|
||||||
|
# user_id: "SELECT id, name FROM users WHERE id IN {value}"
|
||||||
|
|
||||||
|
# create audits
|
||||||
|
audit: true
|
||||||
|
|
||||||
|
# change the time zone
|
||||||
|
time_zone: <%= ENV["TIME_ZONE"] %>
|
||||||
|
|
||||||
|
# class name of the user model
|
||||||
|
user_class: User
|
||||||
|
|
||||||
|
# method name for the current user
|
||||||
|
user_method: current_user
|
||||||
|
|
||||||
|
# method name for the display name
|
||||||
|
user_name: email
|
||||||
|
|
||||||
|
# custom before_action to use for auth
|
||||||
|
before_action_method: require_user
|
||||||
|
|
||||||
|
# email to send checks from
|
||||||
|
from_email: <%= ENV["DEFAULT_FROM"] %>
|
||||||
|
|
||||||
|
# webhook for Slack
|
||||||
|
# slack_webhook_url: <%= ENV["BLAZER_SLACK_WEBHOOK_URL"] %>
|
||||||
|
|
||||||
|
check_schedules:
|
||||||
|
- "1 day"
|
||||||
|
- "1 hour"
|
||||||
|
- "5 minutes"
|
||||||
|
|
||||||
|
# enable anomaly detection
|
||||||
|
# note: with trend, time series are sent to https://trendapi.org
|
||||||
|
# anomaly_checks: trend / r
|
||||||
|
|
||||||
|
# enable forecasting
|
||||||
|
# note: with trend, time series are sent to https://trendapi.org
|
||||||
|
# forecasting: trend / prophet
|
||||||
|
|
||||||
|
# enable map
|
||||||
|
# mapbox_access_token: <%= ENV["MAPBOX_ACCESS_TOKEN"] %>
|
||||||
|
|
||||||
|
# enable uploads
|
||||||
|
# uploads:
|
||||||
|
# url: <%= ENV["BLAZER_UPLOADS_URL"] %>
|
||||||
|
# schema: uploads
|
||||||
|
# data_source: main
|
|
@ -4,4 +4,5 @@ Rails.application.routes.draw do
|
||||||
resources :sensors, only: [] do
|
resources :sensors, only: [] do
|
||||||
resources :measurements, only: [:create]
|
resources :measurements, only: [:create]
|
||||||
end
|
end
|
||||||
|
mount Blazer::Engine, at: 'blazer'
|
||||||
end
|
end
|
||||||
|
|
47
db/migrate/20210726182544_install_blazer.rb
Normal file
47
db/migrate/20210726182544_install_blazer.rb
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
class InstallBlazer < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
create_table :blazer_queries do |t|
|
||||||
|
t.references :creator
|
||||||
|
t.string :name
|
||||||
|
t.text :description
|
||||||
|
t.text :statement
|
||||||
|
t.string :data_source
|
||||||
|
t.string :status
|
||||||
|
t.timestamps null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table :blazer_audits do |t|
|
||||||
|
t.references :user
|
||||||
|
t.references :query
|
||||||
|
t.text :statement
|
||||||
|
t.string :data_source
|
||||||
|
t.datetime :created_at
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table :blazer_dashboards do |t|
|
||||||
|
t.references :creator
|
||||||
|
t.string :name
|
||||||
|
t.timestamps null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table :blazer_dashboard_queries do |t|
|
||||||
|
t.references :dashboard
|
||||||
|
t.references :query
|
||||||
|
t.integer :position
|
||||||
|
t.timestamps null: false
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table :blazer_checks do |t|
|
||||||
|
t.references :creator
|
||||||
|
t.references :query
|
||||||
|
t.string :state
|
||||||
|
t.string :schedule
|
||||||
|
t.text :emails
|
||||||
|
t.text :slack_channels
|
||||||
|
t.string :check_type
|
||||||
|
t.text :message
|
||||||
|
t.datetime :last_run_at
|
||||||
|
t.timestamps null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
58
db/schema.rb
generated
58
db/schema.rb
generated
|
@ -10,11 +10,67 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2021_07_26_174833) do
|
ActiveRecord::Schema.define(version: 2021_07_26_182544) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
||||||
|
create_table "blazer_audits", force: :cascade do |t|
|
||||||
|
t.bigint "user_id"
|
||||||
|
t.bigint "query_id"
|
||||||
|
t.text "statement"
|
||||||
|
t.string "data_source"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.index ["query_id"], name: "index_blazer_audits_on_query_id"
|
||||||
|
t.index ["user_id"], name: "index_blazer_audits_on_user_id"
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "blazer_checks", force: :cascade do |t|
|
||||||
|
t.bigint "creator_id"
|
||||||
|
t.bigint "query_id"
|
||||||
|
t.string "state"
|
||||||
|
t.string "schedule"
|
||||||
|
t.text "emails"
|
||||||
|
t.text "slack_channels"
|
||||||
|
t.string "check_type"
|
||||||
|
t.text "message"
|
||||||
|
t.datetime "last_run_at"
|
||||||
|
t.datetime "created_at", precision: 6, null: false
|
||||||
|
t.datetime "updated_at", precision: 6, null: false
|
||||||
|
t.index ["creator_id"], name: "index_blazer_checks_on_creator_id"
|
||||||
|
t.index ["query_id"], name: "index_blazer_checks_on_query_id"
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "blazer_dashboard_queries", force: :cascade do |t|
|
||||||
|
t.bigint "dashboard_id"
|
||||||
|
t.bigint "query_id"
|
||||||
|
t.integer "position"
|
||||||
|
t.datetime "created_at", precision: 6, null: false
|
||||||
|
t.datetime "updated_at", precision: 6, null: false
|
||||||
|
t.index ["dashboard_id"], name: "index_blazer_dashboard_queries_on_dashboard_id"
|
||||||
|
t.index ["query_id"], name: "index_blazer_dashboard_queries_on_query_id"
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "blazer_dashboards", force: :cascade do |t|
|
||||||
|
t.bigint "creator_id"
|
||||||
|
t.string "name"
|
||||||
|
t.datetime "created_at", precision: 6, null: false
|
||||||
|
t.datetime "updated_at", precision: 6, null: false
|
||||||
|
t.index ["creator_id"], name: "index_blazer_dashboards_on_creator_id"
|
||||||
|
end
|
||||||
|
|
||||||
|
create_table "blazer_queries", force: :cascade do |t|
|
||||||
|
t.bigint "creator_id"
|
||||||
|
t.string "name"
|
||||||
|
t.text "description"
|
||||||
|
t.text "statement"
|
||||||
|
t.string "data_source"
|
||||||
|
t.string "status"
|
||||||
|
t.datetime "created_at", precision: 6, null: false
|
||||||
|
t.datetime "updated_at", precision: 6, null: false
|
||||||
|
t.index ["creator_id"], name: "index_blazer_queries_on_creator_id"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "measurements", force: :cascade do |t|
|
create_table "measurements", force: :cascade do |t|
|
||||||
t.decimal "temperature"
|
t.decimal "temperature"
|
||||||
t.decimal "level"
|
t.decimal "level"
|
||||||
|
|
Loading…
Reference in a new issue